tun, tap: fix use-after-free of the socket's file
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | tun: clear the socket file pointer on release to fix a struct file UAFdrivers/ | +1 | 0 replies | |
| 2/2 | tap: clear the socket file pointer on release to fix a struct file UAFdrivers/ | +2 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH net 0/2] tun, tap: fix use-after-free of the socket's file
tun and tap store the opened file in a socket embedded in their own object, and never clear the pointer. A packet written to the fd keeps the socket alive, so the socket can outlive the file, and code that follows sk->sk_socket->file for a packet still in the stack after close() reads a freed struct file, a use-after-free.
With tun, an unprivileged user can reach this from a user namespace and turn it into an arbitrary kernel memory read via nfnetlink_queue, which reports the uid and gid it reads through the freed file's f_cred.
With tap a process needs to be able to access the /dev/tapN node to reach the bug.
Patch 1 fixes tun and patch 2 fixes tap, both by clearing the pointer when the file is released.
Both bugs were discovered during an LLM-based code review. Reproducers for both: github.com/AgusNicco/tun-tap-uaf
Juan Agustin Niccolini (2):
tun: clear the socket file pointer on release to fix a struct file UAF
tap: clear the socket file pointer on release to fix a struct file UAF
drivers/net/tap.c | 2 ++ drivers/net/tun.c | 1 + 2 files changed, 3 insertions(+)
base-commit: 28a371228d4eb4857cc31eeb1a0d7d01e9c3ea2f
Signature · 1 line
2.53.0