From: Rasmus Villemoes Date: Sun, 12 Nov 2017 23:15:08 +0000 (+0100) Subject: net: core: check dev_valid_name in __dev_alloc_name X-Git-Tag: Ubuntu-5.4-5.4.0-11.14~6547^2~33^2~2 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=93809105cf9d43790839d8b8e29a8a505290ec68;p=mirror_ubuntu-focal-kernel.git net: core: check dev_valid_name in __dev_alloc_name We currently only exclude non-sysfs-friendly names via dev_get_valid_name; there doesn't seem to be a reason to allow such names when we're called via dev_alloc_name. This does duplicate the dev_valid_name check in the dev_get_valid_name() case; we'll fix that shortly. Signed-off-by: Rasmus Villemoes Signed-off-by: David S. Miller --- diff --git a/net/core/dev.c b/net/core/dev.c index 4cedc7595f1f..cb3d95edf58d 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1064,6 +1064,9 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf) unsigned long *inuse; struct net_device *d; + if (!dev_valid_name(name)) + return -EINVAL; + p = strchr(name, '%'); if (p) { /*