All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: Stephen Smalley <stephen.smalley.work@gmail.com>,
	Paul Moore <paul@paul-moore.com>,
	Anna Schumaker <anna@kernel.org>
Cc: Achilles Gaikwad <achillesgaikwad@gmail.com>,
	Trond Myklebust <trondmy@kernel.org>,
	Casey Schaufler <casey@schaufler-ca.com>,
	Christian Brauner <brauner@kernel.org>,
	linux-nfs@vger.kernel.org, linux-security-module@vger.kernel.org,
	selinux@vger.kernel.org
Subject: Re: [PATCH v2] security,fs,nfs,net: update security_inode_listsecurity() interface
Date: Sat, 25 Jul 2026 16:14:48 -0400	[thread overview]
Message-ID: <20260725200958.4471-1-cel@kernel.org> (raw)
In-Reply-To: <20250428195022.24587-2-stephen.smalley.work@gmail.com>

On Mon, Apr 28, 2025 at 03:50:19PM -0400, Stephen Smalley wrote:
> Update the security_inode_listsecurity() interface to allow
> use of the xattr_list_one() helper and update the hook
> implementations.

This commit wedges an NFSv4.2 client running fstests.

A kdevops fstests run against nfsd-next hangs at generic/086.  The
client stops making progress and never recovers:

  watchdog: BUG: soft lockup - CPU#3 stuck for 250s! [086:60396]
  Comm: 086 Tainted: G  D  L  7.2.0-rc4
    __pv_queued_spin_lock_slowpath
    _raw_spin_lock
    nfs4_xattr_set_listcache [nfsv4]
    nfs4_xattr_discard_cache [nfsv4]
    nfs4_xattr_cache_scan [nfsv4]
    do_shrink_slab
    drop_caches_sysctl_handler

The D taint says something died earlier.  It did: by the time the
lockup fires, the client has already taken two dozen NULL pointer
dereferences, all of them in the same place:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: _copy_from_pages+0x44/0xd0 [sunrpc]
    nfs4_xattr_cache_list [nfsv4]
    nfs4_listxattr [nfsv4]
    vfs_listxattr
    __x64_sys_listxattr

The two stages are connected.  nfs4_listxattr() declares its
remaining-size accumulator as an unsigned size_t.  On a size query,
where listxattr(2) passes a NULL buffer and a length of zero,
xattr_list_one() decrements that accumulator for the SELinux label
without regard to the NULL buffer, so it wraps to a very large
value.  nfs4_xattr_cache_list() then sees a NULL buffer paired with
a buffer length large enough to pass its own bounds check, and
copies into it.  The fault happens while the xattr listcache
spinlock is held.  Task exit does not release spinlocks, so the
lock is orphaned, and the next shrinker pass spins on it until the
watchdog fires.

The reproducer is a plain getfattr on a file on an NFSv4.2 mount
with SELinux enforcing, which is what fstests generic/086 arrives
at by way of a drop_caches write.  No fstests machinery is needed
to see the oops.

An audit of the listxattr path pointed here, so I built nfsd-next
with this commit reverted and reran the full fstests nfs_v42
section on the same pair of guests.  745 tests, no soft lockup, no
oops, and generic/086 passes.  The two failures that remain,
generic/033 and generic/258, are unrelated to xattrs.

I am not proposing the revert as the fix.  Achilles Gaikwad has
already posted a targeted patch for the accounting itself:

  https://lore.kernel.org/linux-nfs/20260707152305.15324-1-achillesgaikwad@gmail.com/

Whether the right answer is that patch, a change to
xattr_list_one() so it leaves the remaining size alone when the
buffer is NULL, or hardening nfs4_xattr_cache_list() against a NULL
buffer, is for the three of you to settle.  I am reporting the
severity, because the accounting bug is not confined to a short
size query: on a filesystem that caches xattrs behind a lock, it
takes the whole machine down.

I can test whatever you settle on against the same setup.

--
Chuck Lever

      parent reply	other threads:[~2026-07-25 20:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 19:50 [PATCH v2] security,fs,nfs,net: update security_inode_listsecurity() interface Stephen Smalley
2025-04-29  7:46 ` Christian Brauner
2025-04-29 12:25   ` Stephen Smalley
2025-04-29 23:34 ` Paul Moore
2025-05-20 21:31   ` Paul Moore
2025-05-21  0:22     ` Casey Schaufler
2025-05-27 21:03     ` Anna Schumaker
2025-06-19 21:18       ` Paul Moore
2025-07-24  2:09         ` Paul Moore
2025-12-03 15:35           ` Stephen Smalley
2025-12-03 15:55             ` Paul Moore
2025-12-03 18:08               ` Stephen Smalley
2025-12-03 20:01                 ` Stephen Smalley
2025-06-05 18:09   ` Stephen Smalley
2025-06-05 18:24     ` Paul Moore
2025-05-21  0:31 ` Kuniyuki Iwashima
2025-06-19 21:04   ` Paul Moore
2025-06-06 13:39 ` Konstantin Andreev
2025-06-06 14:28   ` Stephen Smalley
2025-06-06 15:24     ` Konstantin Andreev
2026-04-28 19:21 ` [PATCH ported/repost " Paul Moore
2026-04-28 19:26   ` Paul Moore
2026-05-01 16:00     ` Paul Moore
2026-07-25 20:14 ` Chuck Lever [this message]

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=20260725200958.4471-1-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=achillesgaikwad@gmail.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=casey@schaufler-ca.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=selinux@vger.kernel.org \
    --cc=stephen.smalley.work@gmail.com \
    --cc=trondmy@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.