Netdev List
 help / color / mirror / Atom feed
From: Juan Agustin Niccolini <juanagusnicco@gmail.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Jason Wang <jasowangio@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org,
	Simon Schippers <simon.schippers@tu-dortmund.de>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Dongli Zhang <dongli.zhang@oracle.com>,
	Yuchung Cheng <ycheng@google.com>,
	Al Viro <viro@ZenIV.linux.org.uk>,
	Stanislav Kinsbursky <skinsbursky@parallels.com>,
	Sridhar Samudrala <sri@us.ibm.com>, Arnd Bergmann <arnd@arndb.de>
Subject: [PATCH net 0/2] tun, tap: fix use-after-free of the socket's file
Date: Sat, 28 Nov 2026 12:48:42 -0500	[thread overview]
Message-ID: <20261128174844.53113-1-juanagusnicco@gmail.com> (raw)

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


             reply	other threads:[~2026-11-28 17:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-28 17:48 Juan Agustin Niccolini [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261128174844.53113-1-juanagusnicco@gmail.com \
    --to=juanagusnicco@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=dongli.zhang@oracle.com \
    --cc=edumazet@kernel.org \
    --cc=jasowangio@gmail.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=simon.schippers@tu-dortmund.de \
    --cc=skinsbursky@parallels.com \
    --cc=sri@us.ibm.com \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=ycheng@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox