# CVE-2023-53685: tun: Fix memory leak for detached NAPI queue.

> Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

- **Severity:** MEDIUM 5.5
- **CVSS:** 5.5 (v3.1, NVD) `CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H`
- **CVSS metrics:** Attack vector: Local; Attack complexity: Low; Privileges required: Low; User interaction: None; Scope: Unchanged; Confidentiality impact: None; Integrity impact: None; Availability impact: High
- **Exploited in the wild:** Not in CISA KEV
- **Public exploit / PoC:** None known
- **Remote exploitation:** Not remotely exploitable (local or adjacent access needed)
- **EPSS:** 0.22% (percentile 7, 2026-11-26)
- **CWE:** CWE-401
- **Published:** 2025-10-07T15:21:38.124Z
- **Modified:** 2026-11-05T21:17:32.243Z

## Who should check

- Anyone running Linux \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 9cae243b9ae25adfe468cd47ceca591f6725b79c; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 82b2bc279467c875ec36f8ef820f00997c2a4e8e
- Anyone running Linux 3.8

## 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---

## Affected and fixed versions

- Linux: \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 9cae243b9ae25adfe468cd47ceca591f6725b79c; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 82b2bc279467c875ec36f8ef820f00997c2a4e8e (cvelist)
- Linux: 3.8 (cvelist)

## Mitigation

- Upgrade Linux to 82b2bc279467c875ec36f8ef820f00997c2a4e8e or later.

## Check your systems with an agent

Paste this into a coding agent:

```text
Check whether anything I run is affected by CVE-2023-53685. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2023-53685.md
Affected: Linux >= cde8b15f1aabe327038ee4e0e11dd6b798572f69, < 9cae243b9ae25adfe468cd47ceca591f6725b79c; >= cde8b15f1aabe327038ee4e0e11dd6b798572f69, < 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5; >= cde8b15f1aabe327038ee4e0e11dd6b798572f69, < 82b2bc279467c875ec36f8ef820f00997c2a4e8e; Linux 3.8
Fixed in: Linux 9cae243b9ae25adfe468cd47ceca591f6725b79c, Linux 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5, Linux 82b2bc279467c875ec36f8ef820f00997c2a4e8e

Steps:
1. Search this machine and project for Linux: dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.
```

## FAQ

### Is CVE-2023-53685 being exploited?

There is no confirmed exploitation: CVE-2023-53685 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known. EPSS estimates a 0.22% chance of exploitation in the next 30 days (as of 2026-11-26).

### How serious is CVE-2023-53685?

Medium: CVSS 5.5 (v3.1, scored by NVD). Not remotely exploitable (local or adjacent access needed).

### Which versions are affected by CVE-2023-53685?

Linux \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 9cae243b9ae25adfe468cd47ceca591f6725b79c; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5; \>= cde8b15f1aabe327038ee4e0e11dd6b798572f69, \< 82b2bc279467c875ec36f8ef820f00997c2a4e8e; Linux 3.8.

### Is there a fix for CVE-2023-53685?

Yes. Fixed in Linux 9cae243b9ae25adfe468cd47ceca591f6725b79c, Linux 0d20210a190f76db9ec35ee4e0fc77e6c7a148f5, Linux 82b2bc279467c875ec36f8ef820f00997c2a4e8e. Upgrade Linux to 82b2bc279467c875ec36f8ef820f00997c2a4e8e or later.

### How do I check if I'm affected by CVE-2023-53685?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

## References

- patch: <https://git.kernel.org/stable/c/9cae243b9ae25adfe468cd47ceca591f6725b79c>
- patch: <https://git.kernel.org/stable/c/0d20210a190f76db9ec35ee4e0fc77e6c7a148f5>
- patch: <https://git.kernel.org/stable/c/82b2bc279467c875ec36f8ef820f00997c2a4e8e>

## Attribution

- CVE Program: CVE® is a registered trademark of The MITRE Corporation. CVE records © 1999–2026 The MITRE Corporation. <https://www.cve.org/Legal/TermsOfUse>
- NVD: This product uses data from the NVD API but is not endorsed or certified by the NVD. <https://nvd.nist.gov/vuln/detail/CVE-2023-53685>

HTML: <https://flawdb.com/CVE-2023-53685> · JSON: <https://flawdb.com/api/v1/entries/CVE-2023-53685>
