]> git.baikalelectronics.ru Git - kernel.git/commit
net: check all name nodes in __dev_alloc_name
authorJiri Bohac <jbohac@suse.cz>
Thu, 18 Mar 2021 03:42:53 +0000 (04:42 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Mar 2021 21:40:53 +0000 (14:40 -0700)
commit21d542133a96baa3440d5ab9c5f255572d422860
tree1edd60c501e1d98ce8dca9924bf18d4428b7c5be
parent228d0ae270bd48ccc1581a6124a4a28b1c0fae0a
net: check all name nodes in __dev_alloc_name

__dev_alloc_name(), when supplied with a name containing '%d',
will search for the first available device number to generate a
unique device name.

Since commit 25be6dea04db1cadb8b6172cdcc13962846db444 ("net:
introduce name_node struct to be used in hashlist") network
devices may have alternate names.  __dev_alloc_name() does take
these alternate names into account, possibly generating a name
that is already taken and failing with -ENFILE as a result.

This demonstrates the bug:

    # rmmod dummy 2>/dev/null
    # ip link property add dev lo altname dummy0
    # modprobe dummy numdummies=1
    modprobe: ERROR: could not insert 'dummy': Too many open files in system

Instead of creating a device named dummy1, modprobe fails.

Fix this by checking all the names in the d->name_node list, not just d->name.

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
Fixes: 25be6dea04db ("net: introduce name_node struct to be used in hashlist")
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c