In the Linux kernel, the following vulnerability has been resolved:
net/mlx5e: Fix netif state handling
mlx5esuspend cleans resources only if netifdevicepresent() returns true. However, mlx5eresume changes the state of netif, via mlx5enicenable, only if regstate == NETREGREGISTERED. In the below case, the above leads to NULL-ptr Oops[1] and memory leaks:
mlx5eprobe _mlx5eresume mlx5eattachnetdev mlx5enicenable <-- netdev not reg, not calling netifdeviceattach() registernetdev <-- failed for some reason. ERRORFLOW: mlx5esuspend <-- netifdevicepresent return false, resources aren't freed :(
Hence, clean resources in this case as well.
[1] BUG: kernel NULL pointer dereference, address: 0000000000000000 PGD 0 P4D 0 Oops: 0010 [#1] SMP CPU: 2 PID: 9345 Comm: test-ovs-ct-gen Not tainted 6.5.0forupstreammindebug202309051601 #1 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:0x0 Code: Unable to access opcode bytes at0xffffffffffffffd6. RSP: 0018:ffff888178aaf758 EFLAGS: 00010246 Call Trace: <TASK> ? _die+0x20/0x60 ? pagefaultoops+0x14c/0x3c0 ? excpagefault+0x75/0x140 ? asmexcpagefault+0x22/0x30 notifiercallchain+0x35/0xb0 blockingnotifiercallchain+0x3d/0x60 mlx5blockingnotifiercallchain+0x22/0x30 [mlx5core] mlx5coreuplinknetdeveventreplay+0x3e/0x60 [mlx5core] mlx5mdevnetdevtrack+0x53/0x60 [mlx5ib] mlx5ibroceinit+0xc3/0x340 [mlx5ib] _mlx5ibadd+0x34/0xd0 [mlx5ib] mlx5rprobe+0xe1/0x210 [mlx5ib] ? auxiliarymatchid+0x6a/0x90 auxiliarybusprobe+0x38/0x80 ? driversysfsadd+0x51/0x80 reallyprobe+0xc9/0x3e0 ? driverprobedevice+0x90/0x90 _driverprobedevice+0x80/0x160 driverprobedevice+0x1e/0x90 _deviceattachdriver+0x7d/0x100 busforeachdrv+0x80/0xd0 _deviceattach+0xbc/0x1f0 busprobedevice+0x86/0xa0 deviceadd+0x637/0x840 _auxiliarydeviceadd+0x3b/0xa0 addadev+0xc9/0x140 [mlx5core] mlx5rescandriverslocked+0x22a/0x310 [mlx5core] mlx5registerdevice+0x53/0xa0 [mlx5core] mlx5initonedevllocked+0x5c4/0x9c0 [mlx5core] mlx5initone+0x3b/0x60 [mlx5core] probeone+0x44c/0x730 [mlx5core] localpciprobe+0x3e/0x90 pcideviceprobe+0xbf/0x210 ? kernfscreatelink+0x5d/0xa0 ? sysfsdocreatelinksd+0x60/0xc0 reallyprobe+0xc9/0x3e0 ? driverprobedevice+0x90/0x90 _driverprobedevice+0x80/0x160 driverprobedevice+0x1e/0x90 _deviceattachdriver+0x7d/0x100 busforeachdrv+0x80/0xd0 _deviceattach+0xbc/0x1f0 pcibusadddevice+0x54/0x80 pciiovaddvirtfn+0x2e6/0x320 sriovenable+0x208/0x420 mlx5coresriovconfigure+0x9e/0x200 [mlx5core] sriovnumvfsstore+0xae/0x1a0 kernfsfopwriteiter+0x10c/0x1a0 vfswrite+0x291/0x3c0 ksyswrite+0x5f/0xe0 dosyscall64+0x3d/0x90 entrySYSCALL64afterhwframe+0x46/0xb0 CR2: 0000000000000000 ---[ end trace 0000000000000000 ]---