Skip to content

Commit 992203a

Browse files
scottmayhewTrond Myklebust
authored andcommitted
nfs/localio: restore creds before releasing pageio data
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: b9f5dd5 ("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>
1 parent 4fb2b67 commit 992203a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

fs/nfs/localio.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,13 @@ static void nfs_local_call_read(struct work_struct *work)
453453
nfs_local_iter_init(&iter, iocb, READ);
454454

455455
status = filp->f_op->read_iter(&iocb->kiocb, &iter);
456+
457+
revert_creds(save_cred);
458+
456459
if (status != -EIOCBQUEUED) {
457460
nfs_local_read_done(iocb, status);
458461
nfs_local_pgio_release(iocb);
459462
}
460-
461-
revert_creds(save_cred);
462463
}
463464

464465
static int
@@ -648,14 +649,15 @@ static void nfs_local_call_write(struct work_struct *work)
648649
file_start_write(filp);
649650
status = filp->f_op->write_iter(&iocb->kiocb, &iter);
650651
file_end_write(filp);
652+
653+
revert_creds(save_cred);
654+
current->flags = old_flags;
655+
651656
if (status != -EIOCBQUEUED) {
652657
nfs_local_write_done(iocb, status);
653658
nfs_local_vfs_getattr(iocb);
654659
nfs_local_pgio_release(iocb);
655660
}
656-
657-
revert_creds(save_cred);
658-
current->flags = old_flags;
659661
}
660662

661663
static int

0 commit comments

Comments
 (0)