CVE-2021-47082: tun: avoid double free in tun_free_netdev

Published Mar 4, 2024
·
Updated

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

tun: avoid double free in tunfreenetdev

Avoid double free in tunfreenetdev() by moving the dev->tstats and tun->security allocs to a new ndoinit routine (tunnetinit()) that will be called by registernetdevice(). ndoinit is paired with the desctructor (tunfreenetdev()), so if there's an error in registernetdevice() the destructor will handle the frees.

BUG: KASAN: double-free or invalid-free in selinuxtundevfreesecurity+0x1a/0x20 security/selinux/hooks.c:5605

CPU: 0 PID: 25750 Comm: syz-executor416 Not tainted 5.16.0-rc2-syzk #1 Hardware name: Red Hat KVM, BIOS Call Trace: <TASK> dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0x89/0xb5 lib/dumpstack.c:106 printaddressdescription.constprop.9+0x28/0x160 mm/kasan/report.c:247 kasanreportinvalidfree+0x55/0x80 mm/kasan/report.c:372 kasanslabfree mm/kasan/common.c:346 [inline] kasanslabfree+0x107/0x120 mm/kasan/common.c:374 kasanslabfree include/linux/kasan.h:235 [inline] slabfreehook mm/slub.c:1723 [inline] slabfreefreelisthook mm/slub.c:1749 [inline] slabfree mm/slub.c:3513 [inline] kfree+0xac/0x2d0 mm/slub.c:4561 selinuxtundevfreesecurity+0x1a/0x20 security/selinux/hooks.c:5605 securitytundevfreesecurity+0x4f/0x90 security/security.c:2342 tunfreenetdev+0xe6/0x150 drivers/net/tun.c:2215 netdevruntodo+0x4df/0x840 net/core/dev.c:10627 rtnlunlock+0x13/0x20 net/core/rtnetlink.c:112 tunchrioctl+0x80c/0x2870 drivers/net/tun.c:3302 tunchrioctl+0x2f/0x40 drivers/net/tun.c:3311 vfsioctl fs/ioctl.c:51 [inline] dosysioctl fs/ioctl.c:874 [inline] sesysioctl fs/ioctl.c:860 [inline] x64sysioctl+0x19d/0x220 fs/ioctl.c:860 dosyscallx64 arch/x86/entry/common.c:50 [inline] dosyscall64+0x3a/0x80 arch/x86/entry/common.c:80 entrySYSCALL64afterhwframe+0x44/0xae

Affected Software

11 affected componentsFixes available
Linux Linux kernel<4.19.280
Linux Linux kernel>=4.20<5.4.240
Linux Linux kernel>=5.5<5.10.136
Linux Linux kernel>=5.11<5.15.12
Linux Linux kernel=5.16-rc1
Linux Linux kernel=5.16-rc2
Linux Linux kernel=5.16-rc3
Linux Linux kernel=5.16-rc4
Linux Linux kernel=5.16-rc5
Linux Linux kernel=5.16-rc6
debian/linux
5.10.223-15.10.234-16.1.129-16.1.135-16.12.25-16.12.27-1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade debian/linux to a version that resolves this vulnerability.

    Fixed in 5.10.223-1Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.25-1Fixed in 6.12.27-1
  2. Configuration

    Apply the kernel fix: avoid double free in tun_free_netdev() by moving dev->tstats and tun->security allocations to a new ndo_init routine named tun_net_init() that is called by register_netdevice(). Ensure tun_free_netdev() pairs with this ndo_init so destructor frees execute correctly, including when register_netdevice() errors.

    Linux kernel (tun driver) ndo_init/tun_net_init pairing with tun_free_netdev = Implement tun_net_init() and move dev->tstats and tun->security allocs to it so register_netdevice() calls ndo_init; ensure error paths in register_netdevice() rely on tun_free_netdev() destructor for frees

Event History

Mar 4, 2024
CVE Published
via MITRE·06:06 PM
Data Sourced
via MITRE·06:06 PM
DescriptionSeverity
Data Sourced
via NVD·06:15 PM
RemedyDescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is the severity of CVE-2021-47082?

The severity of CVE-2021-47082 is considered to be moderate, as it involves a double free vulnerability in the Linux kernel.

2

How do I fix CVE-2021-47082?

To fix CVE-2021-47082, you should upgrade your Linux kernel to a version that contains the patch addressing this vulnerability.

3

Which versions are affected by CVE-2021-47082?

CVE-2021-47082 affects various versions of the Linux kernel from 4.20 to 5.16-rc6.

4

Is CVE-2021-47082 being actively exploited?

As of now, there is no public evidence that CVE-2021-47082 is being actively exploited in the wild.

5

What systems are at risk from CVE-2021-47082?

Systems running vulnerable versions of the Linux kernel, specifically those within the specified version ranges, are at risk from CVE-2021-47082.

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