Netdev List
 help / color / mirror / Atom feed
* [PATCH net 0/2] tun, tap: fix use-after-free of the socket's file
@ 2026-11-28 17:48 Juan Agustin Niccolini
  2026-11-28 17:48 ` [PATCH net 1/2] tun: clear the socket file pointer on release to fix a struct file UAF Juan Agustin Niccolini
  2026-11-28 17:48 ` [PATCH net 2/2] tap: " Juan Agustin Niccolini
  0 siblings, 2 replies; 3+ messages in thread
From: Juan Agustin Niccolini @ 2026-11-28 17:48 UTC (permalink / raw)
  To: Willem de Bruijn, Jason Wang, Andrew Lunn, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, Simon Schippers, Michael S . Tsirkin, Dongli Zhang,
	Yuchung Cheng, Al Viro, Stanislav Kinsbursky, Sridhar Samudrala,
	Arnd Bergmann

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-28 17:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 17:48 [PATCH net 0/2] tun, tap: fix use-after-free of the socket's file Juan Agustin Niccolini
2026-11-28 17:48 ` [PATCH net 1/2] tun: clear the socket file pointer on release to fix a struct file UAF Juan Agustin Niccolini
2026-11-28 17:48 ` [PATCH net 2/2] tap: " Juan Agustin Niccolini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox