aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2024-11-25 15:10:18 +0100
committerChristian Brauner <brauner@kernel.org>2024-12-02 11:25:13 +0100
commitb690668b65e504d3e9344aa038bdaa7b2354304f (patch)
treeca4d87a643a7d4b4bc856bcbf6d151e33ffd38c2
parentsmb: avoid pointless cred reference count bump (diff)
downloadlinux-rng-b690668b65e504d3e9344aa038bdaa7b2354304f.tar.xz
linux-rng-b690668b65e504d3e9344aa038bdaa7b2354304f.zip
io_uring: avoid pointless cred reference count bump
req->creds and ctx->sq_creds already hold reference counts that are stable during the operations. Link: https://lore.kernel.org/r/20241125-work-cred-v2-22-68b9d38bb5b2@kernel.org Reviewed-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
-rw-r--r--io_uring/io_uring.c4
-rw-r--r--io_uring/sqpoll.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 3e408c8442d4..06ff41484e29 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1728,7 +1728,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
return -EBADF;
if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred()))
- creds = override_creds(get_new_cred(req->creds));
+ creds = override_creds(req->creds);
if (!def->audit_skip)
audit_uring_entry(req->opcode);
@@ -1739,7 +1739,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
audit_uring_exit(!ret, ret);
if (creds)
- put_cred(revert_creds(creds));
+ revert_creds(creds);
if (ret == IOU_OK) {
if (issue_flags & IO_URING_F_COMPLETE_DEFER)
diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c
index 1ca963474336..6df5e649c413 100644
--- a/io_uring/sqpoll.c
+++ b/io_uring/sqpoll.c
@@ -174,7 +174,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
const struct cred *creds = NULL;
if (ctx->sq_creds != current_cred())
- creds = override_creds(get_new_cred(ctx->sq_creds));
+ creds = override_creds(ctx->sq_creds);
mutex_lock(&ctx->uring_lock);
if (!wq_list_empty(&ctx->iopoll_list))
@@ -192,7 +192,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))
wake_up(&ctx->sqo_sq_wait);
if (creds)
- put_cred(revert_creds(creds));
+ revert_creds(creds);
}
return ret;