Skip to content

Commit b690668

Browse files
committed
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/[email protected] Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: Jens Axboe <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 62e5396 commit b690668

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

io_uring/io_uring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
17281728
return -EBADF;
17291729

17301730
if (unlikely((req->flags & REQ_F_CREDS) && req->creds != current_cred()))
1731-
creds = override_creds(get_new_cred(req->creds));
1731+
creds = override_creds(req->creds);
17321732

17331733
if (!def->audit_skip)
17341734
audit_uring_entry(req->opcode);
@@ -1739,7 +1739,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags)
17391739
audit_uring_exit(!ret, ret);
17401740

17411741
if (creds)
1742-
put_cred(revert_creds(creds));
1742+
revert_creds(creds);
17431743

17441744
if (ret == IOU_OK) {
17451745
if (issue_flags & IO_URING_F_COMPLETE_DEFER)

io_uring/sqpoll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
174174
const struct cred *creds = NULL;
175175

176176
if (ctx->sq_creds != current_cred())
177-
creds = override_creds(get_new_cred(ctx->sq_creds));
177+
creds = override_creds(ctx->sq_creds);
178178

179179
mutex_lock(&ctx->uring_lock);
180180
if (!wq_list_empty(&ctx->iopoll_list))
@@ -192,7 +192,7 @@ static int __io_sq_thread(struct io_ring_ctx *ctx, bool cap_entries)
192192
if (to_submit && wq_has_sleeper(&ctx->sqo_sq_wait))
193193
wake_up(&ctx->sqo_sq_wait);
194194
if (creds)
195-
put_cred(revert_creds(creds));
195+
revert_creds(creds);
196196
}
197197

198198
return ret;

0 commit comments

Comments
 (0)