In the Linux kernel, the following vulnerability has been resolved:
net: avoid race between device unregistration and ethnl ops
The following trace can be seen if a device is being unregistered while its number of channels are being modified.
DEBUGLOCKSWARNON(lock->magic != lock) WARNING: CPU: 3 PID: 3754 at kernel/locking/mutex.c:564 mutexlock+0xc8a/0x1120 CPU: 3 UID: 0 PID: 3754 Comm: ethtool Not tainted 6.13.0-rc6+ #771 RIP: 0010:mutexlock+0xc8a/0x1120 Call Trace: <TASK> ethtoolcheckmaxchannel+0x1ea/0x880 ethnlsetchannels+0x3c3/0xb10 ethnldefaultsetdoit+0x306/0x650 genlfamilyrcvmsgdoit+0x1e3/0x2c0 genlrcvmsg+0x432/0x6f0 netlinkrcvskb+0x13d/0x3b0 genlrcv+0x28/0x40 netlinkunicast+0x42e/0x720 netlinksendmsg+0x765/0xc20 _syssendto+0x3ac/0x420 _x64syssendto+0xe0/0x1c0 dosyscall64+0x95/0x180 entrySYSCALL64after_hwframe+0x76/0x7e
This is because unregisternetdevicemanynotify might run before the rtnl lock section of ethnl operations, eg. setchannels in the above example. In this example the rss lock would be destroyed by the device unregistration path before being used again, but in general running ethnl operations while dismantle has started is not a good idea.
Fix this by denying any operation on devices being unregistered. A check was already there in ethnlopsbegin, but not wide enough.
Note that the same issue cannot be seen on the ioctl version (_devethtool) because the device reference is retrieved from within the rtnl lock section there. Once dismantle started, the net device is unlisted and no reference will be found.