From: Benjamin Coddington <ben.coddington@hammerspace.com>
To: Vasileios Almpanis <vasilisalmpanis@gmail.com>
Cc: Trond Myklebust <trondmy@kernel.org>,
Anna Schumaker <anna@kernel.org>,
Benjamin Coddington <bcodding@redhat.com>,
Trond Myklebust <trond.myklebust@hammerspace.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] NFS: sysfs: fix use-after-free on delayed kobject release
Date: Tue, 04 Aug 2026 08:58:39 -0400 [thread overview]
Message-ID: <4FA2A276-5C44-4D7E-8C33-1322A7BB8AB4@hammerspace.com> (raw)
In-Reply-To: <20260803-nfs-v1-1-034176dab4a3@gmail.com>
On 3 Aug 2026, at 5:18, Vasileios Almpanis wrote:
> struct nfs_netns_client embeds two kobjects and is freed by
> nfs_netns_object_release(), the release function of nfs_net_kobj.
> Despite that the first one, p->kobject lives in the same allocation.
> Nothing keeps the allocation from being freed before p->kobject
> has been released.
>
> When CONFIG_DEBUG_KOBJECT_RELEASE=y each release is instead deferred to
> a delayed_work embedded in the kobject, with an independent random
> delay, and nfs_net_kobj frees the allocation first in some of those
> cases. p->kobject's timer is then left armed inside freed memory, and
> the following splat appears:
>
> [ 139.805951][ T131] kobject: 'nfs_client' (ffff888027fdb800): kobject_release, parent 0000000000000000 (delayed 300)
> [ 139.808019][ T131] kobject: 'net' (ffff888027fdb898): kobject_release, parent 0000000000000000 (delayed 100)
>
> BUG: KASAN: slab-use-after-free in __run_timers+0x932/0x980
> Write of size 8 at addr ffff888027fdb868 by task swapper/0/0
>
> Reproduced on a KASAN kernel with CONFIG_NFS_FS=y and
> CONFIG_DEBUG_KOBJECT_RELEASE=y by:
>
> for i in $(seq 16); do unshare -n true; done; sleep 20
>
> Give p->kobject a reference on nfs_net_kobj for its whole lifetime and
> drop it from nfs_netns_client_release(), so the allocation is always
> freed after p->kobject has been released.
>
> Fixes: e96f9268eea6 ("NFS: Make all of /sys/fs/nfs network-namespace unique")
> Signed-off-by: Vasileios Almpanis <vasilisalmpanis@gmail.com>
Reviewed-by: Benjamin Coddington <bcodding@hammerspace.com>
Ben
next prev parent reply other threads:[~2026-08-04 12:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 9:18 Vasileios Almpanis
2026-08-04 12:58 ` Benjamin Coddington [this message]
2026-08-27 13:20 ` Vasileios Almpanis
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=4FA2A276-5C44-4D7E-8C33-1322A7BB8AB4@hammerspace.com \
--to=ben.coddington@hammerspace.com \
--cc=anna@kernel.org \
--cc=bcodding@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
--cc=trondmy@kernel.org \
--cc=vasilisalmpanis@gmail.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
all inboxes | Powered by JetHome®