summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Mayhew <smayhew@redhat.com>2025-08-07 12:49:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-09-19 16:35:43 +0200
commit57c1bb02b4fc8eec6eb01736e7fad26dffacf18c (patch)
treef7fe68c08e3371286f9e1a20ae6706e58092f6f5
parenta707c9a8380f1f4da0ee907a7ff9eaa976df29b1 (diff)
nfs/localio: restore creds before releasing pageio data
[ Upstream commit 992203a1fba51b025c60ec0c8b0d9223343dea95 ] Otherwise if the nfsd filecache code releases the nfsd_file immediately, it can trigger the BUG_ON(cred == current->cred) in __put_cred() when it puts the nfsd_file->nf_file->f-cred. Fixes: b9f5dd57f4a5 ("nfs/localio: use dedicated workqueues for filesystem read and write") Signed-off-by: Scott Mayhew <smayhew@redhat.com> Reviewed-by: Mike Snitzer <snitzer@kernel.org> Link: https://lore.kernel.org/r/20250807164938.2395136-1-smayhew@redhat.com Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--fs/nfs/localio.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c
index 8fb145124e93..82a053304ad5 100644
--- a/fs/nfs/localio.c
+++ b/fs/nfs/localio.c
@@ -425,12 +425,13 @@ static void nfs_local_call_read(struct work_struct *work)
nfs_local_iter_init(&iter, iocb, READ);
status = filp->f_op->read_iter(&iocb->kiocb, &iter);
+
+ revert_creds(save_cred);
+
if (status != -EIOCBQUEUED) {
nfs_local_read_done(iocb, status);
nfs_local_pgio_release(iocb);
}
-
- revert_creds(save_cred);
}
static int
@@ -626,14 +627,15 @@ static void nfs_local_call_write(struct work_struct *work)
file_start_write(filp);
status = filp->f_op->write_iter(&iocb->kiocb, &iter);
file_end_write(filp);
+
+ revert_creds(save_cred);
+ current->flags = old_flags;
+
if (status != -EIOCBQUEUED) {
nfs_local_write_done(iocb, status);
nfs_local_vfs_getattr(iocb);
nfs_local_pgio_release(iocb);
}
-
- revert_creds(save_cred);
- current->flags = old_flags;
}
static int