]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nfs/localio: fix regression due to out-of-order __put_cred
authorMike Snitzer <snitzer@kernel.org>
Wed, 26 Nov 2025 06:01:25 +0000 (01:01 -0500)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Dec 2025 01:53:56 +0000 (17:53 -0800)
commit3af870aedbff10bfed220e280b57a405e972229f
tree438e107e00c0ac368bfa2b34a15a8c97c53339f5
parent11efc1cb7016e300047822fd60e0f4b4158bd56d
nfs/localio: fix regression due to out-of-order __put_cred

Commit f2060bdc21d7 ("nfs/localio: add refcounting for each iocb IO
associated with NFS pgio header") inadvertantly reintroduced the same
potential for __put_cred() triggering BUG_ON(cred == current->cred) that
commit 992203a1fba5 ("nfs/localio: restore creds before releasing pageio
data") fixed.

Fix this by saving and restoring the cred around each {read,write}_iter
call within the respective for loop of nfs_local_call_{read,write} using
scoped_with_creds().

NOTE: this fix started by first reverting the following commits:

 94afb627dfc2 ("nfs: use credential guards in nfs_local_call_read()")
 bff3c841f7bd ("nfs: use credential guards in nfs_local_call_write()")
 1d18101a644e ("Merge tag 'kernel-6.19-rc1.cred' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs")

followed by narrowly fixing the cred lifetime issue by using
scoped_with_creds().  In doing so, this commit's changes appear more
extensive than they really are (as evidenced by comparing to v6.18's
fs/nfs/localio.c).

Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Acked-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/linux-next/20251205111942.4150b06f@canb.auug.org.au/
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/nfs/localio.c