{"id":"CVE-2021-47082","state":"PUBLISHED","title":"tun: avoid double free in tun_free_netdev","description":"In the Linux kernel, the following vulnerability has been resolved:\n\ntun: avoid double free in tun_free_netdev\n\nAvoid double free in tun_free_netdev() by moving the\ndev->tstats and tun->security allocs to a new ndo_init routine\n(tun_net_init()) that will be called by register_netdevice().\nndo_init is paired with the desctructor (tun_free_netdev()),\nso if there's an error in register_netdevice() the destructor\nwill handle the frees.\n\nBUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605\n\nCPU: 0 PID: 25750 Comm: syz-executor416 Not tainted 5.16.0-rc2-syzk #1\nHardware name: Red Hat KVM, BIOS\nCall Trace:\n<TASK>\n__dump_stack lib/dump_stack.c:88 [inline]\ndump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106\nprint_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:247\nkasan_report_invalid_free+0x55/0x80 mm/kasan/report.c:372\n____kasan_slab_free mm/kasan/common.c:346 [inline]\n__kasan_slab_free+0x107/0x120 mm/kasan/common.c:374\nkasan_slab_free include/linux/kasan.h:235 [inline]\nslab_free_hook mm/slub.c:1723 [inline]\nslab_free_freelist_hook mm/slub.c:1749 [inline]\nslab_free mm/slub.c:3513 [inline]\nkfree+0xac/0x2d0 mm/slub.c:4561\nselinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605\nsecurity_tun_dev_free_security+0x4f/0x90 security/security.c:2342\ntun_free_netdev+0xe6/0x150 drivers/net/tun.c:2215\nnetdev_run_todo+0x4df/0x840 net/core/dev.c:10627\nrtnl_unlock+0x13/0x20 net/core/rtnetlink.c:112\n__tun_chr_ioctl+0x80c/0x2870 drivers/net/tun.c:3302\ntun_chr_ioctl+0x2f/0x40 drivers/net/tun.c:3311\nvfs_ioctl fs/ioctl.c:51 [inline]\n__do_sys_ioctl fs/ioctl.c:874 [inline]\n__se_sys_ioctl fs/ioctl.c:860 [inline]\n__x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860\ndo_syscall_x64 arch/x86/entry/common.c:50 [inline]\ndo_syscall_64+0x3a/0x80 arch/x86/entry/common.c:80\nentry_SYSCALL_64_after_hwframe+0x44/0xae","publishedAt":"2024-03-04T18:06:17.081Z","updatedAt":"2026-08-05T08:45:53.877Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"8eb43d635950e27c29f1e9e49a23b31637f37757","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"0c0e566f0387490d16f166808c72e9c772027681","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"a01a4e9f5dc93335c716fa4023b1901956e8c904","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"3cb5ae77799e8ed6ec3fec0b6b4cd07f01650cc5","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"158b515f703e75e7d68289bf4d98c664e1d632df","versionType":"git"},{"version":"a81a02460bdf054ca0c60c5aed29941f7134092d","status":"affected","versionType":"git"},{"version":"6fc265f7a86d81e052508d03da555188f5882c3e","status":"affected","versionType":"git"},{"version":"3.10.16","status":"affected","lessThan":"3.11","versionType":"semver"},{"version":"3.11.5","status":"affected","lessThan":"3.12","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/net/tun.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"3.12","status":"affected"},{"version":"0","status":"unaffected","lessThan":"3.12","versionType":"semver"},{"version":"4.19.280","status":"unaffected","lessThanOrEqual":"4.19.*","versionType":"semver"},{"version":"5.4.240","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.136","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.12","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.16","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/net/tun.c"]}],"references":["https://git.kernel.org/stable/c/8eb43d635950e27c29f1e9e49a23b31637f37757","https://git.kernel.org/stable/c/0c0e566f0387490d16f166808c72e9c772027681","https://git.kernel.org/stable/c/a01a4e9f5dc93335c716fa4023b1901956e8c904","https://git.kernel.org/stable/c/3cb5ae77799e8ed6ec3fec0b6b4cd07f01650cc5","https://git.kernel.org/stable/c/158b515f703e75e7d68289bf4d98c664e1d632df"],"weaknesses":[],"ingestedAt":"2026-10-29T19:49:19.404Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2021/47xxx/CVE-2021-47082.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2021-47082","state":"PUBLISHED","datePublished":"2024-03-04T18:06:17.081Z","dateUpdated":"2026-08-05T08:45:53.877Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2024-02-29T22:33:44.298Z"},"containers":{"cna":{"title":"tun: avoid double free in tun_free_netdev","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\ntun: avoid double free in tun_free_netdev\n\nAvoid double free in tun_free_netdev() by moving the\ndev->tstats and tun->security allocs to a new ndo_init routine\n(tun_net_init()) that will be called by register_netdevice().\nndo_init is paired with the desctructor (tun_free_netdev()),\nso if there's an error in register_netdevice() the destructor\nwill handle the frees.\n\nBUG: KASAN: double-free or invalid-free in selinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605\n\nCPU: 0 PID: 25750 Comm: syz-executor416 Not tainted 5.16.0-rc2-syzk #1\nHardware name: Red Hat KVM, BIOS\nCall Trace:\n<TASK>\n__dump_stack lib/dump_stack.c:88 [inline]\ndump_stack_lvl+0x89/0xb5 lib/dump_stack.c:106\nprint_address_description.constprop.9+0x28/0x160 mm/kasan/report.c:247\nkasan_report_invalid_free+0x55/0x80 mm/kasan/report.c:372\n____kasan_slab_free mm/kasan/common.c:346 [inline]\n__kasan_slab_free+0x107/0x120 mm/kasan/common.c:374\nkasan_slab_free include/linux/kasan.h:235 [inline]\nslab_free_hook mm/slub.c:1723 [inline]\nslab_free_freelist_hook mm/slub.c:1749 [inline]\nslab_free mm/slub.c:3513 [inline]\nkfree+0xac/0x2d0 mm/slub.c:4561\nselinux_tun_dev_free_security+0x1a/0x20 security/selinux/hooks.c:5605\nsecurity_tun_dev_free_security+0x4f/0x90 security/security.c:2342\ntun_free_netdev+0xe6/0x150 drivers/net/tun.c:2215\nnetdev_run_todo+0x4df/0x840 net/core/dev.c:10627\nrtnl_unlock+0x13/0x20 net/core/rtnetlink.c:112\n__tun_chr_ioctl+0x80c/0x2870 drivers/net/tun.c:3302\ntun_chr_ioctl+0x2f/0x40 drivers/net/tun.c:3311\nvfs_ioctl fs/ioctl.c:51 [inline]\n__do_sys_ioctl fs/ioctl.c:874 [inline]\n__se_sys_ioctl fs/ioctl.c:860 [inline]\n__x64_sys_ioctl+0x19d/0x220 fs/ioctl.c:860\ndo_syscall_x64 arch/x86/entry/common.c:50 [inline]\ndo_syscall_64+0x3a/0x80 arch/x86/entry/common.c:80\nentry_SYSCALL_64_after_hwframe+0x44/0xae"}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"8eb43d635950e27c29f1e9e49a23b31637f37757","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"0c0e566f0387490d16f166808c72e9c772027681","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"a01a4e9f5dc93335c716fa4023b1901956e8c904","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"3cb5ae77799e8ed6ec3fec0b6b4cd07f01650cc5","versionType":"git"},{"version":"662ca437e714caaab855b12415d6ffd815985bc0","status":"affected","lessThan":"158b515f703e75e7d68289bf4d98c664e1d632df","versionType":"git"},{"version":"a81a02460bdf054ca0c60c5aed29941f7134092d","status":"affected","versionType":"git"},{"version":"6fc265f7a86d81e052508d03da555188f5882c3e","status":"affected","versionType":"git"},{"version":"3.10.16","status":"affected","lessThan":"3.11","versionType":"semver"},{"version":"3.11.5","status":"affected","lessThan":"3.12","versionType":"semver"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/net/tun.c"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"3.12","status":"affected"},{"version":"0","status":"unaffected","lessThan":"3.12","versionType":"semver"},{"version":"4.19.280","status":"unaffected","lessThanOrEqual":"4.19.*","versionType":"semver"},{"version":"5.4.240","status":"unaffected","lessThanOrEqual":"5.4.*","versionType":"semver"},{"version":"5.10.136","status":"unaffected","lessThanOrEqual":"5.10.*","versionType":"semver"},{"version":"5.15.12","status":"unaffected","lessThanOrEqual":"5.15.*","versionType":"semver"},{"version":"5.16","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/net/tun.c"]}],"references":[{"url":"https://git.kernel.org/stable/c/8eb43d635950e27c29f1e9e49a23b31637f37757"},{"url":"https://git.kernel.org/stable/c/0c0e566f0387490d16f166808c72e9c772027681"},{"url":"https://git.kernel.org/stable/c/a01a4e9f5dc93335c716fa4023b1901956e8c904"},{"url":"https://git.kernel.org/stable/c/3cb5ae77799e8ed6ec3fec0b6b4cd07f01650cc5"},{"url":"https://git.kernel.org/stable/c/158b515f703e75e7d68289bf4d98c664e1d632df"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerability is triggered via TUNSETIFF ioctl on /dev/net/tun during local tun/tap device creation in tun_set_iff(); it is not reachable from network packets or adjacent-link protocols.\nAC:L - An attacker who can create tun devices can reliably force register_netdevice() to fail after NETDEV_REGISTER (e.g., by inducing memory pressure so ipv6_add_dev/devmap notifiers return errors), hitting the broken err_detach cleanup; no race or layout outside attacker influence is required.\nPR:L - Creating a new tun/tap device only requires ns_capable(net->user_ns, CAP_NET_ADMIN), which an unprivileged user obtains via user+net namespaces (unshare -Urn); /dev/net/tun itself is typically world-openable.\nUI:N - Exploitation needs only attacker-controlled open/ioctl syscalls on /dev/net/tun; no victim action is required.\nS:U - Impact is confined to the local kernel privilege boundary (standard local memory-corruption privilege escalation); this is not a VM escape, IOMMU bypass, or other cross-authority boundary.\nC:H - The bug double-frees kernel heap objects (SELinux tun security blob and/or percpu tstats) on the register_netdevice failure path, enabling heap reuse and arbitrary kernel read primitives.\nI:H - The same double-free of tun->security and/or dev->tstats is classic heap corruption that can be turned into arbitrary write and control-flow hijacking in the kernel.\nA:H - The double-free is reported by KASAN as an invalid free in tun_free_netdev via netdev_run_todo and can oops/panic the kernel even without full exploitation."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T08:45:53.877Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.12","versionEndExcluding":"4.19.280"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.12","versionEndExcluding":"5.4.240"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.12","versionEndExcluding":"5.10.136"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.12","versionEndExcluding":"5.15.12"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.12","versionEndExcluding":"5.16"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.10.16"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"3.11.5"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}},"adp":[{"title":"CISA ADP Vulnrichment","metrics":[{"other":{"type":"ssvc","content":{"id":"CVE-2021-47082","role":"CISA Coordinator","options":[{"Exploitation":"none"},{"Automatable":"no"},{"Technical Impact":"partial"}],"version":"2.0.3","timestamp":"2024-03-05T16:05:48.438280Z"}}}],"providerMetadata":{"shortName":"CISA-ADP","orgId":"134c704f-9b21-4f2e-91b3-4a467353bcc0","dateUpdated":"2024-06-04T17:14:25.499Z"}},{"title":"CVE Program Container","references":[{"url":"https://git.kernel.org/stable/c/8eb43d635950e27c29f1e9e49a23b31637f37757","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/0c0e566f0387490d16f166808c72e9c772027681","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/a01a4e9f5dc93335c716fa4023b1901956e8c904","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/3cb5ae77799e8ed6ec3fec0b6b4cd07f01650cc5","tags":["x_transferred"]},{"url":"https://git.kernel.org/stable/c/158b515f703e75e7d68289bf4d98c664e1d632df","tags":["x_transferred"]}],"providerMetadata":{"shortName":"CVE","orgId":"af854a3a-2127-422b-91ae-364da2661108","dateUpdated":"2024-08-04T05:24:39.695Z"}}]}}}