]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
aio: use credential guards
authorChristian Brauner <brauner@kernel.org>
Mon, 3 Nov 2025 11:26:50 +0000 (12:26 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 4 Nov 2025 11:36:33 +0000 (12:36 +0100)
Use credential guards for scoped credential override with automatic
restoration on scope exit.

Link: https://patch.msgid.link/20251103-work-creds-guards-simple-v1-2-a3e156839e7f@kernel.org
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/aio.c

index 5bc1333864078e15e3daa41a45aaf220d09d60de..0a23a8c0717ff9ce71a413baf174569ae52f345f 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1640,10 +1640,10 @@ static int aio_write(struct kiocb *req, const struct iocb *iocb,
 static void aio_fsync_work(struct work_struct *work)
 {
        struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work);
-       const struct cred *old_cred = override_creds(iocb->fsync.creds);
 
-       iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync);
-       revert_creds(old_cred);
+       scoped_with_creds(iocb->fsync.creds)
+               iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync);
+
        put_cred(iocb->fsync.creds);
        iocb_put(iocb);
 }