From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Amir Goldstein <amir73il@gmail.com>,
Miklos Szeredi <miklos@szeredi.hu>,
Al Viro <viro@zeniv.linux.org.uk>, Jens Axboe <axboe@kernel.dk>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Christian Brauner <brauner@kernel.org>
Subject: [PATCH v2 22/29] io_uring: avoid pointless cred reference count bump
Date: Mon, 25 Nov 2024 15:10:18 +0100 [thread overview]
Message-ID: <20241125-work-cred-v2-22-68b9d38bb5b2@kernel.org> (raw)
In-Reply-To: <20241125-work-cred-v2-0-68b9d38bb5b2@kernel.org>
req->creds and ctx->sq_creds already hold reference counts that are
stable during the operations.
Signed-off-by: Christian Brauner <brauner@kernel.org>
---
io_uring/io_uring.c | 4 ++--
io_uring/sqpoll.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index ad4d8e94a8665cf5f3e9ea0fd9bc6c03a03cc48f..8012933998837ddcef45c14f1dfe543947a9eaec 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -1704,7 +1704,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);
@@ -1715,7 +1715,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 1ca96347433695de1eb0e3bec7c6da4299e9ceb0..6df5e649c413e39e36db6cde2a8c6745e533bea9 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;
--
2.45.2
next prev parent reply other threads:[~2024-11-25 14:11 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-25 14:09 [PATCH v2 00/29] cred: rework {override,revert}_creds() Christian Brauner
2024-11-25 14:09 ` [PATCH v2 01/29] tree-wide: s/override_creds()/override_creds_light(get_new_cred())/g Christian Brauner
2024-11-25 14:09 ` [PATCH v2 02/29] cred: return old creds from revert_creds_light() Christian Brauner
2024-11-25 14:09 ` [PATCH v2 03/29] tree-wide: s/revert_creds()/put_cred(revert_creds_light())/g Christian Brauner
2024-11-25 14:10 ` [PATCH v2 04/29] cred: remove old {override,revert}_creds() helpers Christian Brauner
2024-11-25 14:10 ` [PATCH v2 05/29] tree-wide: s/override_creds_light()/override_creds()/g Christian Brauner
2024-11-25 14:10 ` [PATCH v2 06/29] tree-wide: s/revert_creds_light()/revert_creds()/g Christian Brauner
2024-11-25 14:10 ` [PATCH v2 07/29] firmware: avoid pointless reference count bump Christian Brauner
2024-11-25 14:10 ` [PATCH v2 08/29] sev-dev: avoid pointless cred " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 09/29] target_core_configfs: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 10/29] aio: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 11/29] binfmt_misc: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 12/29] coredump: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 13/29] nfs/localio: avoid pointless cred reference count bumps Christian Brauner
2024-11-25 14:10 ` [PATCH v2 14/29] nfs/nfs4idmap: avoid pointless reference count bump Christian Brauner
2024-11-25 14:10 ` [PATCH v2 15/29] nfs/nfs4recover: avoid pointless cred " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 16/29] nfsfh: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 17/29] open: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 18/29] ovl: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 19/29] cifs: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 20/29] " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 21/29] smb: " Christian Brauner
2024-11-25 14:10 ` Christian Brauner [this message]
2024-11-25 14:10 ` [PATCH v2 23/29] acct: avoid pointless " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 24/29] cgroup: avoid pointless cred " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 25/29] trace: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 26/29] dns_resolver: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 27/29] cachefiles: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 28/29] nfsd: " Christian Brauner
2024-11-25 14:10 ` [PATCH v2 29/29] cred: remove unused get_new_cred() Christian Brauner
2024-11-25 15:37 ` [PATCH v2 00/29] cred: rework {override,revert}_creds() Chuck Lever
2024-11-25 16:53 ` Linus Torvalds
2024-11-26 9:57 ` Christian Brauner
2024-11-27 2:03 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241125-work-cred-v2-22-68b9d38bb5b2@kernel.org \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox