CVE-2021-46981: nbd: Fix NULL pointer in flush_workqueue

Published Feb 28, 2024
·
Updated

In the Linux kernel, the following vulnerability has been resolved:

nbd: Fix NULL pointer in flushworkqueue

Open /dev/nbdX first, the configrefs will be 1 and the pointers in nbddevice are still null. Disconnect /dev/nbdX, then reference a null recvworkq. The protection by configrefs in nbdgenldisconnect is useless.

[ 656.366194] BUG: kernel NULL pointer dereference, address: 0000000000000020 [ 656.368943] #PF: supervisor write access in kernel mode [ 656.369844] #PF: errorcode(0x0002) - not-present page [ 656.370717] PGD 10cc87067 P4D 10cc87067 PUD 1074b4067 PMD 0 [ 656.371693] Oops: 0002 [#1] SMP [ 656.372242] CPU: 5 PID: 7977 Comm: nbd-client Not tainted 5.11.0-rc5-00040-g76c057c84d28 #1 [ 656.373661] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014 [ 656.375904] RIP: 0010:mutexlock+0x29/0x60 [ 656.376627] Code: 00 0f 1f 44 00 00 55 48 89 fd 48 83 05 6f d7 fe 08 01 e8 7a c3 ff ff 48 83 05 6a d7 fe 08 01 31 c0 65 48 8b 14 25 00 6d 01 00 <f0> 48 0f b1 55 d [ 656.378934] RSP: 0018:ffffc900005eb9b0 EFLAGS: 00010246 [ 656.379350] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 656.379915] RDX: ffff888104cf2600 RSI: ffffffffaae8f452 RDI: 0000000000000020 [ 656.380473] RBP: 0000000000000020 R08: 0000000000000000 R09: ffff88813bd6b318 [ 656.381039] R10: 00000000000000c7 R11: fefefefefefefeff R12: ffff888102710b40 [ 656.381599] R13: ffffc900005eb9e0 R14: ffffffffb2930680 R15: ffff88810770ef00 [ 656.382166] FS: 00007fdf117ebb40(0000) GS:ffff88813bd40000(0000) knlGS:0000000000000000 [ 656.382806] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 656.383261] CR2: 0000000000000020 CR3: 0000000100c84000 CR4: 00000000000006e0 [ 656.383819] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 656.384370] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 656.384927] Call Trace: [ 656.385111] flushworkqueue+0x92/0x6c0 [ 656.385395] nbddisconnectandput+0x81/0xd0 [ 656.385716] nbdgenldisconnect+0x125/0x2a0 [ 656.386034] genlfamilyrcvmsgdoit.isra.0+0x102/0x1b0 [ 656.386422] genlrcvmsg+0xfc/0x2b0 [ 656.386685] ? nbdioctl+0x490/0x490 [ 656.386954] ? genlfamilyrcvmsgdoit.isra.0+0x1b0/0x1b0 [ 656.387354] netlinkrcvskb+0x62/0x180 [ 656.387638] genlrcv+0x34/0x60 [ 656.387874] netlinkunicast+0x26d/0x590 [ 656.388162] netlinksendmsg+0x398/0x6c0 [ 656.388451] ? netlinkrcvskb+0x180/0x180 [ 656.388750] syssendmsg+0x1da/0x320 [ 656.389038] ? sysrecvmsg+0x130/0x220 [ 656.389334] syssendmsg+0x8e/0xf0 [ 656.389605] ? sysrecvmsg+0xa2/0xf0 [ 656.389889] ? handlemmfault+0x1671/0x21d0 [ 656.390201] syssendmsg+0x6d/0xe0 [ 656.390464] x64syssendmsg+0x23/0x30 [ 656.390751] dosyscall64+0x45/0x70 [ 656.391017] entrySYSCALL64afterhwframe+0x44/0xa9

To fix it, just add if (nbd->recvworkq) to nbddisconnectandput().

Affected Software

6 affected componentsFixes available
Linux Linux kernel>=5.4<5.4.120
Linux Linux kernel>=5.5<5.10.38
Linux Linux kernel>=5.11<5.11.22
Linux Linux kernel>=5.12<5.12.5
Linux Linux kernel=5.13-rc1
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-16.12.27-1

Event History

Feb 28, 2024
CVE Published
via MITRE·08:13 AM
Data Sourced
via MITRE·08:13 AM
Description
May 17, 2024
Data Sourced
via Launchpad·08:17 AM
Description
May 4, 2025
Data Sourced
via Ubuntu·11:51 PM
RemedyDescriptionSeverityAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2021-46981?

The severity of CVE-2021-46981 is classified as moderate due to potential null pointer dereference issues in the Linux kernel.

2

How do I fix CVE-2021-46981?

To fix CVE-2021-46981, update your Linux kernel to a version that includes the patch, such as those released after version 5.12.5.

3

Which versions of the Linux kernel are affected by CVE-2021-46981?

CVE-2021-46981 affects Linux kernel versions between 5.4.x and 5.12.x, including specific release candidates.

4

What type of vulnerability is CVE-2021-46981?

CVE-2021-46981 is a null pointer dereference vulnerability that can lead to denial of service.

5

Is CVE-2021-46981 present in all Linux distributions?

CVE-2021-46981 may be present in various Linux distributions that utilize the affected versions of the Linux kernel.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203