From patchwork Sun Nov 24 13:43:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884113 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E3842040A7; Sun, 24 Nov 2024 13:44:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455858; cv=none; b=iegNmTXErE9ZV73k/70BhwnbxdK1LegIZs9D1qgjYggSZBjbTWhYGKOKtly3j4/yw4ZuHuVCYDiFgv+VdUXeYGSPCTzb/C6VT4W73Ry7MMewQe8wtXG1NAyvpGcL56HghYB4v3uP1Y3xvwpv9dn8IVcr9OXKowAgbCoK+UHhE1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455858; c=relaxed/simple; bh=vSV0hLsIUoJrtYtJtCa6k/8o6hPHqRU5dFHPUwMtLG4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ulq22C0z+b8W48PoPQjnFSScI9CCFSZWCYJwPicfAuoynVk7BrUPyxpfvqXVA7uJh0v9kIvPfYIhJRPI1BR4+FF3jGvGF0A0Esq9dzGbd39JEd4w7ihlj4OzmpswfkNdmcbU4gEPHCDNrijlTchOzFA1hqO+DsEgTECRWy//pNA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RX5iixpB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RX5iixpB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8523C4CED1; Sun, 24 Nov 2024 13:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455858; bh=vSV0hLsIUoJrtYtJtCa6k/8o6hPHqRU5dFHPUwMtLG4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX5iixpBRq9+IrpBtYOVuQgEKONo0YJHH50fIJBuR+faCpO+lbiTPkHjRb6jYFRsS 92gQPuA0d9KPoUyhmLhSxpmKODDHHJ8SD9CBs1begQb5qTlWDjS+iGOaWOWRXGVAGC 7joiDVLqjHwuuzkVu+xuCfEg+oSBrTULuZlVwLokd+JKTCyXsgKQrGdnpb8VvryCJ2 RaT1ACX/om7T5FuM7MPcvDg9x32KrTQOW8nib39cI7SqDQXr/whO1X01PkMRQaYI5h zwlWIVeDp3XYi0J/xcZ7gEH7gqh2HBUsJ+PgK4mQENS8r145lfhNcQs6rifdzVxoKi 1u89ftyFLRFiQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 01/26] tree-wide: s/override_creds()/override_creds_light(get_new_cred())/g Date: Sun, 24 Nov 2024 14:43:47 +0100 Message-ID: <20241124-work-cred-v1-1-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=14871; i=brauner@kernel.org; h=from:subject:message-id; bh=vSV0hLsIUoJrtYtJtCa6k/8o6hPHqRU5dFHPUwMtLG4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76864+7N32rv6TS+rplZuaPSYlmgpMcVP7cSc4nsrU j6wPGUK6yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZiI6CyG/8m/Z5euExBitpvc /PBTw/szE18nv73jZtj/atbm8K+MmvEM/32OLHdsD/7E6CsVI7b+Iw/HJZFFah1sHJ0rjz3lr+t YyQgA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Signed-off-by: Christian Brauner --- drivers/base/firmware_loader/main.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/target/target_core_configfs.c | 2 +- fs/aio.c | 2 +- fs/binfmt_misc.c | 2 +- fs/cachefiles/internal.h | 2 +- fs/coredump.c | 2 +- fs/nfs/localio.c | 4 ++-- fs/nfs/nfs4idmap.c | 2 +- fs/nfsd/auth.c | 2 +- fs/nfsd/nfs4recover.c | 2 +- fs/nfsd/nfsfh.c | 2 +- fs/open.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/smb/client/cifs_spnego.c | 2 +- fs/smb/client/cifsacl.c | 4 ++-- fs/smb/server/smb_common.c | 2 +- io_uring/io_uring.c | 2 +- io_uring/sqpoll.c | 2 +- kernel/acct.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/trace/trace_events_user.c | 2 +- net/dns_resolver/dns_query.c | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 324a9a3c087aa2e2c4e0b53b30a2f11f61195aa3..74039d6b2b71b91d0d1d57b71f74501abaf646e2 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -912,7 +912,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret = -ENOMEM; goto out; } - old_cred = override_creds(kern_cred); + old_cred = override_creds_light(get_new_cred(kern_cred)); ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL); diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index af018afd9cd7fc68c5f9004e2d0a2ee162d8c4b9..2ad6e41af085a400e88b3207c9b55345f57526e1 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -244,7 +244,7 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m if (!cred) return ERR_PTR(-ENOMEM); cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds(cred); + old_cred = override_creds_light(get_new_cred(cred)); fp = file_open_root(&root, filename, flags, mode); path_put(&root); diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index c40217f44b1bc53d149e8d5ea12c0e5297373800..be98d16b2c57c933ffe2c2477b881144f2283630 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -3756,7 +3756,7 @@ static int __init target_core_init_configfs(void) ret = -ENOMEM; goto out; } - old_cred = override_creds(kern_cred); + old_cred = override_creds_light(get_new_cred(kern_cred)); target_init_dbroot(); revert_creds(old_cred); put_cred(kern_cred); diff --git a/fs/aio.c b/fs/aio.c index 50671640b5883f5d20f652e23c4ea3fe04c989f2..a52fe2e999e73b00af9a19f1c01f0e384f667871 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1639,7 +1639,7 @@ 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); + const struct cred *old_cred = override_creds_light(get_new_cred(iocb->fsync.creds)); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); revert_creds(old_cred); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 31660d8cc2c610bd42f00f1de7ed6c39618cc5db..f8355eee3d19ef6d20565ec1938e8691ba084d83 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -826,7 +826,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, * didn't matter much as only a privileged process could open * the register file. */ - old_cred = override_creds(file->f_cred); + old_cred = override_creds_light(get_new_cred(file->f_cred)); f = open_exec(e->interpreter); revert_creds(old_cred); if (IS_ERR(f)) { diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 7b99bd98de75b8d95e09da1ca7cd1bb3378fcc62..b156cc2e0e63b28b521923b578cb3547dece5e66 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -393,7 +393,7 @@ extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache, static inline void cachefiles_begin_secure(struct cachefiles_cache *cache, const struct cred **_saved_cred) { - *_saved_cred = override_creds(cache->cache_cred); + *_saved_cred = override_creds_light(get_new_cred(cache->cache_cred)); } static inline void cachefiles_end_secure(struct cachefiles_cache *cache, diff --git a/fs/coredump.c b/fs/coredump.c index d48edb37bc35c0896d97a2f6a6cc259d8812f936..b6aae41b80d22bfed78eed6f3e45bdeb5d2daf06 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -576,7 +576,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) if (retval < 0) goto fail_creds; - old_cred = override_creds(cred); + old_cred = override_creds_light(get_new_cred(cred)); ispipe = format_corename(&cn, &cprm, &argv, &argc); diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 8f0ce82a677e1589092a30240d6e60a289d64a58..018e8159c5679757f9fbf257ad3ef60e89d3ee09 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -371,7 +371,7 @@ static void nfs_local_call_read(struct work_struct *work) struct iov_iter iter; ssize_t status; - save_cred = override_creds(filp->f_cred); + save_cred = override_creds_light(get_new_cred(filp->f_cred)); nfs_local_iter_init(&iter, iocb, READ); @@ -541,7 +541,7 @@ static void nfs_local_call_write(struct work_struct *work) ssize_t status; current->flags |= PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO; - save_cred = override_creds(filp->f_cred); + save_cred = override_creds_light(get_new_cred(filp->f_cred)); nfs_local_iter_init(&iter, iocb, WRITE); diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 25a7c771cfd89f3e6d494f26a78212d3d619c135..b9442f70271d8397fb36dcb62570f6d304fe5c71 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -311,7 +311,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, const struct user_key_payload *payload; ssize_t ret; - saved_cred = override_creds(id_resolver_cache); + saved_cred = override_creds_light(get_new_cred(id_resolver_cache)); rkey = nfs_idmap_request_key(name, namelen, type, idmap); revert_creds(saved_cred); diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index 93e33d1ee8917fc5d462f56b5c65380f7555e638..614a5ec4824b4ab9f6faa132c565688c94261704 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -79,7 +79,7 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp) else new->cap_effective = cap_raise_nfsd_set(new->cap_effective, new->cap_permitted); - put_cred(override_creds(new)); + put_cred(override_creds_light(get_new_cred(new))); put_cred(new); return 0; diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index b7d61eb8afe9e10d94b614ae50c2790fe6816732..f55ed06611aaaffa6dc8723b96b9876a3a3db0f7 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -81,7 +81,7 @@ nfs4_save_creds(const struct cred **original_creds) new->fsuid = GLOBAL_ROOT_UID; new->fsgid = GLOBAL_ROOT_GID; - *original_creds = override_creds(new); + *original_creds = override_creds_light(get_new_cred(new)); put_cred(new); return 0; } diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 40ad58a6a0361e48a48262a2c61abbcfd908a3bb..8e323cc8e2c5b26ec660ceedeb95be4ef0ac809e 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -221,7 +221,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, new->cap_effective = cap_raise_nfsd_set(new->cap_effective, new->cap_permitted); - put_cred(override_creds(new)); + put_cred(override_creds_light(get_new_cred(new))); put_cred(new); } else { error = nfsd_setuser_and_check_port(rqstp, cred, exp); diff --git a/fs/open.c b/fs/open.c index e6911101fe71d665d5f1a6346e5f82212bb8ed65..2459cd061f47f46756b7d0a7bf2f563b631ec1d5 100644 --- a/fs/open.c +++ b/fs/open.c @@ -448,7 +448,7 @@ static const struct cred *access_override_creds(void) */ override_cred->non_rcu = 1; - old_cred = override_creds(override_cred); + old_cred = override_creds_light(get_new_cred(override_cred)); /* override_cred() gets its own ref */ put_cred(override_cred); diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 3601ddfeddc2ec70764756905d528570ad1020e1..527b041213c8166d60d6a273675c2e2bc18dec36 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -741,7 +741,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc) return err; if (cc->new) - cc->old = override_creds(cc->new); + cc->old = override_creds_light(get_new_cred(cc->new)); return 0; } diff --git a/fs/smb/client/cifs_spnego.c b/fs/smb/client/cifs_spnego.c index 28f568b5fc2771b7a11d0e83d0ac1cb9baf20636..721d8b1254b6491f0b4cb5318fd60d81e13b1599 100644 --- a/fs/smb/client/cifs_spnego.c +++ b/fs/smb/client/cifs_spnego.c @@ -173,7 +173,7 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo, } cifs_dbg(FYI, "key description = %s\n", description); - saved_cred = override_creds(spnego_cred); + saved_cred = override_creds_light(get_new_cred(spnego_cred)); spnego_key = request_key(&cifs_spnego_key_type, description, ""); revert_creds(saved_cred); diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index ba79aa2107cc9f5b5fa628e9b9998d04e78c8bc1..b1ea4ea3de4b15013ac74cfce988515613543532 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -292,7 +292,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) return -EINVAL; rc = 0; - saved_cred = override_creds(root_cred); + saved_cred = override_creds_light(get_new_cred(root_cred)); sidkey = request_key(&cifs_idmap_key_type, desc, ""); if (IS_ERR(sidkey)) { rc = -EINVAL; @@ -398,7 +398,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, if (!sidstr) return -ENOMEM; - saved_cred = override_creds(root_cred); + saved_cred = override_creds_light(get_new_cred(root_cred)); sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); if (IS_ERR(sidkey)) { cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n", diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index 75b4eb856d32f7ddc856ad5cf04906638cede0b5..c2a59956e3a51b7727a7e358f3842d92d70f085d 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -780,7 +780,7 @@ int __ksmbd_override_fsids(struct ksmbd_work *work, cred->cap_effective = cap_drop_fs_set(cred->cap_effective); WARN_ON(work->saved_cred); - work->saved_cred = override_creds(cred); + work->saved_cred = override_creds_light(get_new_cred(cred)); if (!work->saved_cred) { abort_creds(cred); return -EINVAL; diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 8012933998837ddcef45c14f1dfe543947a9eaec..7ef3b67ebbde7b04d9428631ee72e7f45245feb4 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(req->creds); + creds = override_creds_light(get_new_cred(req->creds)); if (!def->audit_skip) audit_uring_entry(req->opcode); diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index 6df5e649c413e39e36db6cde2a8c6745e533bea9..58a76d5818959a9d7eeef52a8bacd29eba3f3d26 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(ctx->sq_creds); + creds = override_creds_light(get_new_cred(ctx->sq_creds)); mutex_lock(&ctx->uring_lock); if (!wq_list_empty(&ctx->iopoll_list)) diff --git a/kernel/acct.c b/kernel/acct.c index 179848ad33e978a557ce695a0d6020aa169177c6..8f18eb02dd416b884222b66f0f386379c46b30ea 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -501,7 +501,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) flim = rlimit(RLIMIT_FSIZE); current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; /* Perform file operations on behalf of whoever enabled accounting */ - orig_cred = override_creds(file->f_cred); + orig_cred = override_creds_light(get_new_cred(file->f_cred)); /* * First check to see if there is enough free_space to continue diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index d9061bd55436b502e065b477a903ed682d722c2e..97329b4fe5027dcc5d80f6b074f4c494c4794df7 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5216,7 +5216,7 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, * permissions using the credentials from file open to protect against * inherited fd attacks. */ - saved_cred = override_creds(of->file->f_cred); + saved_cred = override_creds_light(get_new_cred(of->file->f_cred)); ret = cgroup_attach_permissions(src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb, threadgroup, ctx->ns); diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 17bcad8f79de70a29fb58f84ce12ffb929515794..4dd7c45d227e9459e694535cee3f853c09826cff 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1469,7 +1469,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) */ cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds(cred); + old_cred = override_creds_light(get_new_cred(cred)); if (visible) ret = trace_add_event_call(&user->call); diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index 82b084cc1cc6349bb532d5ada555b0bcbb1cdbea..a54f5f841cea1edd7f449d4e3e79e37b8ed865f4 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -124,7 +124,7 @@ int dns_query(struct net *net, /* make the upcall, using special credentials to prevent the use of * add_key() to preinstall malicious redirections */ - saved_cred = override_creds(dns_resolver_cache); + saved_cred = override_creds_light(get_new_cred(dns_resolver_cache)); rkey = request_key_net(&key_type_dns_resolver, desc, net, options); revert_creds(saved_cred); kfree(desc); From patchwork Sun Nov 24 13:43:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884114 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CBA7204F89; Sun, 24 Nov 2024 13:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455860; cv=none; b=bXqKNWIo3kuc+LYMTETLkZ+rDIG8ryi0lIQmx3HBIGiGBEWj6RVqUFFz3Eu/k6TyPMXTFEZJ2Ywx0WYcgzHHB5wUQYFuG9B8Lc063Y6QnUnW5P5m9TmuliPqiI28iakrJ8zfSjBSynfKY0TvqnQaf4ULAltaWoxecuQmhh4EgbY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455860; c=relaxed/simple; bh=/k0C1GOH7oc08vW3tBXmzVQAQebTLcc7/aYdKqgOGO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FTyE9w0y3Or45YHXApsJN4UH5aa8vgr5wh9elIBLK+oRU7s1pk7hCFQhRI/+BENMLuS1ZnXwbMR/ErWFQ99wVGQ87wfFnsyTbMGHloE/nEwo9avHUmzZqC2ADRR7xlXmU0NX/CvLDtv9vFMV9Cuyhr8lM3grgMzCXSPb+SQt5lE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dhUge8+4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dhUge8+4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFCABC4CED7; Sun, 24 Nov 2024 13:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455860; bh=/k0C1GOH7oc08vW3tBXmzVQAQebTLcc7/aYdKqgOGO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dhUge8+41kAqTrJyxNLF81vwRM3YwQqvFXRUOAFIp296egp1G0UCjKlX7no1yo70s NHQF+XsjP6XZrOkURnksvufG3MY/AArKo7rmjK6ACd2arn97YICHYyL2WF8XmDL1+Y aMLv56a7qOOnKonafGRsaCterbAaz/Rub5rUc2gyHtxuHgV8bLpe52A5OfkSRCaYAz enf4VwemAdKS74WwDv2P/nINKraOLRR6az2CKH/NDFrcFbQKrrR102QjP4TkSgUz62 DYivV/3XAvRXlSnnLlR73kHdaJD1x9W7eAvkfeWE3WcXsbnTBBd9sgtmzalQYZj+8i r1Ga9FZ8lBbbA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 02/26] cred: return old creds from revert_creds_light() Date: Sun, 24 Nov 2024 14:43:48 +0100 Message-ID: <20241124-work-cred-v1-2-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=899; i=brauner@kernel.org; h=from:subject:message-id; bh=/k0C1GOH7oc08vW3tBXmzVQAQebTLcc7/aYdKqgOGO0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685Qd+fRyF5y+k74tKupb/8s1L9alN+hbP6SRycx4 PD/GxPOd5SyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzEhIfhv4OM2lEnSwH/D+yz UiZlzulM2Fy7iuf9pdNzZpzZe2ixvhAjw1S2khdHvlqu8t7KYfrJM6Qke6rQv6creLL6JtV4zOZ k5wUA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 So we can easily convert revert_creds() callers over to drop the reference count explicitly. Signed-off-by: Christian Brauner --- include/linux/cred.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/linux/cred.h b/include/linux/cred.h index e4a3155fe409d6b991fa6639005ebc233fc17dcc..382768a9707b5c3e6cbd3e8183769e1227a73107 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -185,9 +185,12 @@ static inline const struct cred *override_creds_light(const struct cred *overrid return old; } -static inline void revert_creds_light(const struct cred *revert_cred) +static inline const struct cred *revert_creds_light(const struct cred *revert_cred) { + const struct cred *override_cred = current->cred; + rcu_assign_pointer(current->cred, revert_cred); + return override_cred; } /** From patchwork Sun Nov 24 13:43:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884115 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68155205ACE; Sun, 24 Nov 2024 13:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455862; cv=none; b=XJZ0ViFf/AcGoAytqpW17nzNnM+ntvUB7tCHJWLwffgJXqcR+Wsaai4ewBOIwXx7cMY7VBxaAUCPQuSc+QE4hSEcsx7FVnS93xSDoiYz27Dqx5kJ4eBFEGOk6LikILC6UwWcRY/VZMs32nqj8Z2iv4t3ffyucBPJixTVwigz450= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455862; c=relaxed/simple; bh=6s05hOdmXUocToo4k+S7XAUaHBm1PVMvzZbMTSiUiZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Q8xtvO+0GjsypRMEjuGmGgA/LHqNMRxu0ZYme9VLIKSs1bjRDLFNBvPIoXp9oYrdo4jCKOYk9+NK8xzeUmgGKr0jEwqu6LwsHR/rO2qwew/Lz/6RA+xr6X3JouU1KvWgUcWfY6LHUlIiGdpWI15dK3HXMpBeWSqA60XKeEH9jRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RAec6/RH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RAec6/RH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5FCBC4CED3; Sun, 24 Nov 2024 13:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455862; bh=6s05hOdmXUocToo4k+S7XAUaHBm1PVMvzZbMTSiUiZ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RAec6/RHY0skf9EEq4pWynWBZDZG86BNOjL2Hp/VBg+946tdMYE0r5AW0CgT7ybG2 X/y6c/xkvwnCIDZko+kVYhl3OcdMbJgC0VtXKa7yQmZQV90UFNzE7t7LZqrhol9FTz w17/aMRZ5cvKDwZJoikpG3ndB9ReAdmjHQ9XVvh3fKGq3o/TTfWlAmHwelSkp1cI/N rv++2jUBH+taRzTpdkTJbT5zDD7XL7E889OHCqe7FE5W7p/V4krLYgh4Ob08P2eNgg biMOuVONMRg9bHq+YSDY82ZVrUgjvQ+NbC4xHgqR4H2/FImY/qrn4mOBDwLqwj189x 9vSkQNX9H/P9A== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 03/26] tree-wide: s/revert_creds()/put_cred(revert_creds_light())/g Date: Sun, 24 Nov 2024 14:43:49 +0100 Message-ID: <20241124-work-cred-v1-3-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=13577; i=brauner@kernel.org; h=from:subject:message-id; bh=6s05hOdmXUocToo4k+S7XAUaHBm1PVMvzZbMTSiUiZ4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685cu7ew3/lzn77FpIdzPgtx7im6eDLYgjN1tdjhn c8Y/m7p7ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI0n8M/8O4nRKjv3Q16YVE LFRQ58ng2H1mcfgLAyuxf5HPa3Xs3zP8s/S7arZ1yZ47Gbx8KuFfV5h2bgy1jvC7/ZVBiPfFneT TbAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Convert all calls to revert_creds() over to explicitly dropping reference counts in preparation for converting revert_creds() to revert_creds_light() semantics. Signed-off-by: Christian Brauner --- drivers/base/firmware_loader/main.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/target/target_core_configfs.c | 2 +- fs/aio.c | 2 +- fs/binfmt_misc.c | 2 +- fs/cachefiles/internal.h | 2 +- fs/coredump.c | 2 +- fs/nfs/localio.c | 4 ++-- fs/nfs/nfs4idmap.c | 2 +- fs/nfsd/auth.c | 2 +- fs/nfsd/filecache.c | 2 +- fs/nfsd/nfs4recover.c | 2 +- fs/open.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/smb/client/cifs_spnego.c | 2 +- fs/smb/client/cifsacl.c | 4 ++-- fs/smb/server/smb_common.c | 2 +- io_uring/io_uring.c | 2 +- io_uring/sqpoll.c | 2 +- kernel/acct.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/trace/trace_events_user.c | 2 +- net/dns_resolver/dns_query.c | 2 +- 23 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 74039d6b2b71b91d0d1d57b71f74501abaf646e2..8e3323a618e4436746258ce289a524f98c3ff60a 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -944,7 +944,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, } else ret = assign_fw(fw, device); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); put_cred(kern_cred); out: diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 2ad6e41af085a400e88b3207c9b55345f57526e1..9111a51d53e0e74e6d66bffe5b4e1bf1bf9157d0 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -249,7 +249,7 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m fp = file_open_root(&root, filename, flags, mode); path_put(&root); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); return fp; } diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index be98d16b2c57c933ffe2c2477b881144f2283630..564bc71d2d0923b9fdd575d520fd22206259b40a 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -3758,7 +3758,7 @@ static int __init target_core_init_configfs(void) } old_cred = override_creds_light(get_new_cred(kern_cred)); target_init_dbroot(); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); put_cred(kern_cred); return 0; diff --git a/fs/aio.c b/fs/aio.c index a52fe2e999e73b00af9a19f1c01f0e384f667871..6b987c48b6712abe2601b23f6aa9fac74c09161c 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1642,7 +1642,7 @@ static void aio_fsync_work(struct work_struct *work) const struct cred *old_cred = override_creds_light(get_new_cred(iocb->fsync.creds)); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); put_cred(iocb->fsync.creds); iocb_put(iocb); } diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index f8355eee3d19ef6d20565ec1938e8691ba084d83..84a96abfd090230334f935f666a145571c78b3a8 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -828,7 +828,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, */ old_cred = override_creds_light(get_new_cred(file->f_cred)); f = open_exec(e->interpreter); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); if (IS_ERR(f)) { pr_notice("register: failed to install interpreter file %s\n", e->interpreter); diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index b156cc2e0e63b28b521923b578cb3547dece5e66..809305dd531760d47e781064c1fc6e328849fc6b 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -399,7 +399,7 @@ static inline void cachefiles_begin_secure(struct cachefiles_cache *cache, static inline void cachefiles_end_secure(struct cachefiles_cache *cache, const struct cred *saved_cred) { - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); } /* diff --git a/fs/coredump.c b/fs/coredump.c index b6aae41b80d22bfed78eed6f3e45bdeb5d2daf06..ff119aaa5c313306b1183270a5d95904ed5951f4 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -781,7 +781,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) kfree(argv); kfree(cn.corename); coredump_finish(core_dumped); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); fail_creds: put_cred(cred); fail: diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 018e8159c5679757f9fbf257ad3ef60e89d3ee09..77ff066aa938158cd8fcf691ebfbda6385f70449 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -381,7 +381,7 @@ static void nfs_local_call_read(struct work_struct *work) nfs_local_read_done(iocb, status); nfs_local_pgio_release(iocb); - revert_creds(save_cred); + put_cred(revert_creds_light(save_cred)); } static int @@ -554,7 +554,7 @@ static void nfs_local_call_write(struct work_struct *work) nfs_local_vfs_getattr(iocb); nfs_local_pgio_release(iocb); - revert_creds(save_cred); + put_cred(revert_creds_light(save_cred)); current->flags = old_flags; } diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index b9442f70271d8397fb36dcb62570f6d304fe5c71..629979b20e98cbc37e148289570574d9ba2e7675 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -313,7 +313,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, saved_cred = override_creds_light(get_new_cred(id_resolver_cache)); rkey = nfs_idmap_request_key(name, namelen, type, idmap); - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey); diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index 614a5ec4824b4ab9f6faa132c565688c94261704..dda14811d092689e5aa44bdd29f25403e4e3a780 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -27,7 +27,7 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp) int flags = nfsexp_flags(cred, exp); /* discard any old override before preparing the new set */ - revert_creds(get_cred(current_real_cred())); + put_cred(revert_creds_light(get_cred(current_real_cred()))); new = prepare_creds(); if (!new) return -ENOMEM; diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 2e6783f63712454509c526969a622040985da577..fef2b8eb3a94736cbe8342a95f205f173f598447 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -1252,7 +1252,7 @@ nfsd_file_acquire_local(struct net *net, struct svc_cred *cred, beres = nfsd_file_do_acquire(NULL, net, cred, client, fhp, may_flags, NULL, pnf, true); - revert_creds(save_cred); + put_cred(revert_creds_light(save_cred)); return beres; } diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index f55ed06611aaaffa6dc8723b96b9876a3a3db0f7..61c8f4ab10777952088d1312f2e3d606dbc4f801 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -89,7 +89,7 @@ nfs4_save_creds(const struct cred **original_creds) static void nfs4_reset_creds(const struct cred *original) { - revert_creds(original); + put_cred(revert_creds_light(original)); } static void diff --git a/fs/open.c b/fs/open.c index 2459cd061f47f46756b7d0a7bf2f563b631ec1d5..23c414c10883927129a925a33680affc6f3a0a78 100644 --- a/fs/open.c +++ b/fs/open.c @@ -523,7 +523,7 @@ static long do_faccessat(int dfd, const char __user *filename, int mode, int fla } out: if (old_cred) - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); return res; } diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 527b041213c8166d60d6a273675c2e2bc18dec36..0f19bdbc78a45f35df2829ccc8cc65deef244ffd 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -749,7 +749,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc) static void ovl_revert_cu_creds(struct ovl_cu_creds *cc) { if (cc->new) { - revert_creds(cc->old); + put_cred(revert_creds_light(cc->old)); put_cred(cc->new); } } diff --git a/fs/smb/client/cifs_spnego.c b/fs/smb/client/cifs_spnego.c index 721d8b1254b6491f0b4cb5318fd60d81e13b1599..f2353bccc9f5e4637772a89dd0b0f42861fd21f3 100644 --- a/fs/smb/client/cifs_spnego.c +++ b/fs/smb/client/cifs_spnego.c @@ -175,7 +175,7 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo, cifs_dbg(FYI, "key description = %s\n", description); saved_cred = override_creds_light(get_new_cred(spnego_cred)); spnego_key = request_key(&cifs_spnego_key_type, description, ""); - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); #ifdef CONFIG_CIFS_DEBUG2 if (cifsFYI && !IS_ERR(spnego_key)) { diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index b1ea4ea3de4b15013ac74cfce988515613543532..81d8d9802a56d4bb5d3d0480396f0c78c4c3fb80 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -327,7 +327,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) out_key_put: key_put(sidkey); out_revert_creds: - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); return rc; invalidate_key: @@ -438,7 +438,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, out_key_put: key_put(sidkey); out_revert_creds: - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); kfree(sidstr); /* diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index c2a59956e3a51b7727a7e358f3842d92d70f085d..b13abbf67827fcad9c35606344cca055c09ba9c3 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -800,7 +800,7 @@ void ksmbd_revert_fsids(struct ksmbd_work *work) WARN_ON(!work->saved_cred); cred = current_cred(); - revert_creds(work->saved_cred); + put_cred(revert_creds_light(work->saved_cred)); put_cred(cred); work->saved_cred = NULL; } diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 7ef3b67ebbde7b04d9428631ee72e7f45245feb4..a6a50e86791e79745ace095af68c4b658e4a2cdc 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1715,7 +1715,7 @@ static int io_issue_sqe(struct io_kiocb *req, unsigned int issue_flags) audit_uring_exit(!ret, ret); if (creds) - revert_creds(creds); + put_cred(revert_creds_light(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 58a76d5818959a9d7eeef52a8bacd29eba3f3d26..42ca6e07e0f7b0fe54a9f09857f87fecb5aa7085 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -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) - revert_creds(creds); + put_cred(revert_creds_light(creds)); } return ret; diff --git a/kernel/acct.c b/kernel/acct.c index 8f18eb02dd416b884222b66f0f386379c46b30ea..4e28aa9e1ef278cd7fb3160a27b549155ceaffc3 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -541,7 +541,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) } out: current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; - revert_creds(orig_cred); + put_cred(revert_creds_light(orig_cred)); } /** diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 97329b4fe5027dcc5d80f6b074f4c494c4794df7..68b816955c9c7e0141a073f54b14949b4c37aae6 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5220,7 +5220,7 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, ret = cgroup_attach_permissions(src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb, threadgroup, ctx->ns); - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); if (ret) goto out_finish; diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 4dd7c45d227e9459e694535cee3f853c09826cff..2fdadb2e8547ec86f48d84c81c95434c811cb3cd 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1476,7 +1476,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) else ret = trace_remove_event_call(&user->call); - revert_creds(old_cred); + put_cred(revert_creds_light(old_cred)); put_cred(cred); return ret; diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index a54f5f841cea1edd7f449d4e3e79e37b8ed865f4..297059b7e2a367f5e745aac4557cda5996689a00 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -126,7 +126,7 @@ int dns_query(struct net *net, */ saved_cred = override_creds_light(get_new_cred(dns_resolver_cache)); rkey = request_key_net(&key_type_dns_resolver, desc, net, options); - revert_creds(saved_cred); + put_cred(revert_creds_light(saved_cred)); kfree(desc); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey); From patchwork Sun Nov 24 13:43:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884116 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 772B6206045; Sun, 24 Nov 2024 13:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455864; cv=none; b=ncVTPk8m2OdBGGMi9+xdZq2bcGKg/NnX44ae+nma3wfqOlGRw4nTD9Qpk5wbnPHNI2K3ilDSjZC22mKtCupv919waxQusguhly7v3z7gDl4mOrlRZhtDyY0wPjIhUTaM3Hn95etZasWsLtVOf6P1lt3zCB8LZnH/CC2wv8Vin7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455864; c=relaxed/simple; bh=SXsN7bKGTvPOcfeUJI9xF57hG44uKIH/DtpNG27lH2g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=j3ckXtCDxuejfzES7i0/hY1M2EbJlrdLl28BrSMq8Wqk0IKBSTbCgZkRfgzeScZuWJQK8Up0ei6ZinGg9ZtDqBMyKykO59JVyZQF7hNPEzcwgC/FSMtZoh/m33a8uhaAOZzHAm2m42Ke9l1JxufLYd/YedycmTMBEDXzT2+bHKo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KIyRePe5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KIyRePe5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9CA7C4CED1; Sun, 24 Nov 2024 13:44:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455864; bh=SXsN7bKGTvPOcfeUJI9xF57hG44uKIH/DtpNG27lH2g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KIyRePe51i3Xetqe60+y439UzXDYXiTtNtX02I8giK2eUHnzHzMQ0FXb7E1dkpOl7 bgDTPnSfUqn6wDULPU+71y/3aFzjYYS+A1KjMLlyskzu25zNqmcrblzutOtX9mMLvg Ax2GKEjL149Wlly9bJLfUb3c9BdY2SwD5jfBJJhyGW/m2m5V+DJ74gz1Z8uYTRXs3P 2QkoVfN9vh71p/58G9X7T8HcZV665MfdNhMShFb9wOqok6JkFslTzEXdzakXicEWPz dNlXdoH58ax43XZ058wfLrNhfdMaU0RaAbDhlAVh6izjm91T8YBkJwXaUkzl2nLcaW TmECBXE1R+3dA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 04/26] cred: remove old {override,revert}_creds() helpers Date: Sun, 24 Nov 2024 14:43:50 +0100 Message-ID: <20241124-work-cred-v1-4-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=3355; i=brauner@kernel.org; h=from:subject:message-id; bh=SXsN7bKGTvPOcfeUJI9xF57hG44uKIH/DtpNG27lH2g=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76858tm3x6hlM9+M8z7XkBnSoVxUtiXve8ZjhvovQ7 1NKjyytO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbin8jwT/l+97YoXqfkW3ft Z784+Ne+aNVZu02P3X/MLUrmcH731Jrhf8a7/aF3Dl3b/rvJ3m1TleYfdrlwh6DfOjETVaxnLTZ 0ZQMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 They are now unused. Signed-off-by: Christian Brauner --- include/linux/cred.h | 7 ------- kernel/cred.c | 50 -------------------------------------------------- 2 files changed, 57 deletions(-) diff --git a/include/linux/cred.h b/include/linux/cred.h index 382768a9707b5c3e6cbd3e8183769e1227a73107..439d7a1840e7ccbc94d814728698a4b383bc39b3 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -155,8 +155,6 @@ extern struct cred *prepare_creds(void); extern struct cred *prepare_exec_creds(void); extern int commit_creds(struct cred *); extern void abort_creds(struct cred *); -extern const struct cred *override_creds(const struct cred *); -extern void revert_creds(const struct cred *); extern struct cred *prepare_kernel_cred(struct task_struct *); extern int set_security_override(struct cred *, u32); extern int set_security_override_from_ctx(struct cred *, const char *); @@ -172,11 +170,6 @@ static inline bool cap_ambient_invariant_ok(const struct cred *cred) cred->cap_inheritable)); } -/* - * Override creds without bumping reference count. Caller must ensure - * reference remains valid or has taken reference. Almost always not the - * interface you want. Use override_creds()/revert_creds() instead. - */ static inline const struct cred *override_creds_light(const struct cred *override_cred) { const struct cred *old = current->cred; diff --git a/kernel/cred.c b/kernel/cred.c index da7da250f7c8b5ad91feb938f1e949c5ccb4914b..9676965c0981a01121757b2d904785c1a59e885f 100644 --- a/kernel/cred.c +++ b/kernel/cred.c @@ -476,56 +476,6 @@ void abort_creds(struct cred *new) } EXPORT_SYMBOL(abort_creds); -/** - * override_creds - Override the current process's subjective credentials - * @new: The credentials to be assigned - * - * Install a set of temporary override subjective credentials on the current - * process, returning the old set for later reversion. - */ -const struct cred *override_creds(const struct cred *new) -{ - const struct cred *old; - - kdebug("override_creds(%p{%ld})", new, - atomic_long_read(&new->usage)); - - /* - * NOTE! This uses 'get_new_cred()' rather than 'get_cred()'. - * - * That means that we do not clear the 'non_rcu' flag, since - * we are only installing the cred into the thread-synchronous - * '->cred' pointer, not the '->real_cred' pointer that is - * visible to other threads under RCU. - */ - get_new_cred((struct cred *)new); - old = override_creds_light(new); - - kdebug("override_creds() = %p{%ld}", old, - atomic_long_read(&old->usage)); - return old; -} -EXPORT_SYMBOL(override_creds); - -/** - * revert_creds - Revert a temporary subjective credentials override - * @old: The credentials to be restored - * - * Revert a temporary set of override subjective credentials to an old set, - * discarding the override set. - */ -void revert_creds(const struct cred *old) -{ - const struct cred *override = current->cred; - - kdebug("revert_creds(%p{%ld})", old, - atomic_long_read(&old->usage)); - - revert_creds_light(old); - put_cred(override); -} -EXPORT_SYMBOL(revert_creds); - /** * cred_fscmp - Compare two credentials with respect to filesystem access. * @a: The first credential From patchwork Sun Nov 24 13:43:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884117 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 66C5D207A04; Sun, 24 Nov 2024 13:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455866; cv=none; b=BE8Vyy5NX82bJ0dU3sWYkaG8ctYgVF1iBXPhNCj2kGdQVXQv1n5ixU0rpjeKkMWHpPKI9muUkk2I1ZsamkJdaDtuvwjibWSSD50+0sYOuD0PqLy6O2fBoxuSDdnfTlOERnWO2J4ndQGzgiglqAX0sarKBSm64vnJq30KGs7AJ4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455866; c=relaxed/simple; bh=WWfyP6fjtkWePcltxVWGntOdT2OeTGPjZ86iLbr6p1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=m0fSpfi106jFNRgflkWQTImkBC18HoAe1F73jcxmAAUXWlcMkk3lqbJ/CSuDawb65CRKu4BxgQK93zhO1p2QP6ECBe33IzBUGkK1Fo2VxWrUTsTJnx0+OOc9lMZwzOg6G+TK1juhykJZOhHdR1HoSLf5X6zzxjtztHMif67kqGU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gyDMGhK2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gyDMGhK2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02D3C4CECC; Sun, 24 Nov 2024 13:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455866; bh=WWfyP6fjtkWePcltxVWGntOdT2OeTGPjZ86iLbr6p1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gyDMGhK2FEnKOtVdf5P9aG++pwfuSRub1Wv6v7G1p1HnImJrLKUssUnxKcDgRjHni B6PzdPEe/7Kbljhd8+pruBfvWMjkql9vZwrp/qHIwTv/I1k3pWJ5OqZuMiOWBwzEgt oMp1d5vyAS0+0ZMHUv4Rxf0BohCR1pY8Zs1SHlvk1ulzgenEZfH3po/JE6DBz2/6Pu hdRQXwJwKzQ0KiGWFwPTy7eq5vdwa7T3bRqfXo+VstNTv9Q7Eu0I4eR0dQW/Za4A+O W8Yp8ys2u+3gvc6F9CUj06mjWKEtrNLNxw/befvP2vUTL50rvp352eiJGLaSNKDEmt 8L6EIB7wuEEfQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 05/26] tree-wide: s/override_creds_light()/override_creds()/g Date: Sun, 24 Nov 2024 14:43:51 +0100 Message-ID: <20241124-work-cred-v1-5-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=19026; i=brauner@kernel.org; h=from:subject:message-id; bh=WWfyP6fjtkWePcltxVWGntOdT2OeTGPjZ86iLbr6p1o=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7687s2VJuwrjAUTP4u3i1W+6h/IN/Oe4llQfb7H9W/ O07a7xTRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwES+MjP8jxTXdOWK/Hu7sPyL 0OY6WWXOiMirPMe7Vdyq6spffD/4lOGfedlUtfp+lb9LcnUuVR31YDALeaO/QEwpf/1Km/tvBE4 xAgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Rename all calls to override_creds_light() back to overrid_creds(). Signed-off-by: Christian Brauner --- drivers/base/firmware_loader/main.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/target/target_core_configfs.c | 2 +- fs/aio.c | 2 +- fs/backing-file.c | 10 +++++----- fs/binfmt_misc.c | 2 +- fs/cachefiles/internal.h | 2 +- fs/coredump.c | 2 +- fs/nfs/localio.c | 4 ++-- fs/nfs/nfs4idmap.c | 2 +- fs/nfsd/auth.c | 2 +- fs/nfsd/nfs4recover.c | 2 +- fs/nfsd/nfsfh.c | 2 +- fs/open.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/dir.c | 2 +- fs/overlayfs/util.c | 2 +- fs/smb/client/cifs_spnego.c | 2 +- fs/smb/client/cifsacl.c | 4 ++-- fs/smb/server/smb_common.c | 2 +- include/linux/cred.h | 2 +- io_uring/io_uring.c | 2 +- io_uring/sqpoll.c | 2 +- kernel/acct.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/trace/trace_events_user.c | 2 +- net/dns_resolver/dns_query.c | 2 +- 27 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 8e3323a618e4436746258ce289a524f98c3ff60a..729df15600efb743091d7e1b71a306cdfa9acbf0 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -912,7 +912,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret = -ENOMEM; goto out; } - old_cred = override_creds_light(get_new_cred(kern_cred)); + old_cred = override_creds(get_new_cred(kern_cred)); ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL); diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 9111a51d53e0e74e6d66bffe5b4e1bf1bf9157d0..ffae20fd52bc03e7123b116251c77a3ccd7c6cde 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -244,7 +244,7 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m if (!cred) return ERR_PTR(-ENOMEM); cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds_light(get_new_cred(cred)); + old_cred = override_creds(get_new_cred(cred)); fp = file_open_root(&root, filename, flags, mode); path_put(&root); diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 564bc71d2d0923b9fdd575d520fd22206259b40a..7788e1fe2633ded4f265ff874c62dc4a21fd1b6e 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -3756,7 +3756,7 @@ static int __init target_core_init_configfs(void) ret = -ENOMEM; goto out; } - old_cred = override_creds_light(get_new_cred(kern_cred)); + old_cred = override_creds(get_new_cred(kern_cred)); target_init_dbroot(); put_cred(revert_creds_light(old_cred)); put_cred(kern_cred); diff --git a/fs/aio.c b/fs/aio.c index 6b987c48b6712abe2601b23f6aa9fac74c09161c..7e0ec687f480c05358c6c40638a7e187aafd8124 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1639,7 +1639,7 @@ 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_light(get_new_cred(iocb->fsync.creds)); + const struct cred *old_cred = override_creds(get_new_cred(iocb->fsync.creds)); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); put_cred(revert_creds_light(old_cred)); diff --git a/fs/backing-file.c b/fs/backing-file.c index 526ddb4d6f764e8d3b0566ec51c5efa90faff0ee..bcf8c0b9ff42e2dd30dc239bb2580942fe6c40a7 100644 --- a/fs/backing-file.c +++ b/fs/backing-file.c @@ -176,7 +176,7 @@ ssize_t backing_file_read_iter(struct file *file, struct iov_iter *iter, !(file->f_mode & FMODE_CAN_ODIRECT)) return -EINVAL; - old_cred = override_creds_light(ctx->cred); + old_cred = override_creds(ctx->cred); if (is_sync_kiocb(iocb)) { rwf_t rwf = iocb_to_rw_flags(flags); @@ -233,7 +233,7 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter, */ flags &= ~IOCB_DIO_CALLER_COMP; - old_cred = override_creds_light(ctx->cred); + old_cred = override_creds(ctx->cred); if (is_sync_kiocb(iocb)) { rwf_t rwf = iocb_to_rw_flags(flags); @@ -281,7 +281,7 @@ ssize_t backing_file_splice_read(struct file *in, struct kiocb *iocb, if (WARN_ON_ONCE(!(in->f_mode & FMODE_BACKING))) return -EIO; - old_cred = override_creds_light(ctx->cred); + old_cred = override_creds(ctx->cred); ret = vfs_splice_read(in, &iocb->ki_pos, pipe, len, flags); revert_creds_light(old_cred); @@ -310,7 +310,7 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe, if (ret) return ret; - old_cred = override_creds_light(ctx->cred); + old_cred = override_creds(ctx->cred); file_start_write(out); ret = out->f_op->splice_write(pipe, out, &iocb->ki_pos, len, flags); file_end_write(out); @@ -337,7 +337,7 @@ int backing_file_mmap(struct file *file, struct vm_area_struct *vma, vma_set_file(vma, file); - old_cred = override_creds_light(ctx->cred); + old_cred = override_creds(ctx->cred); ret = call_mmap(vma->vm_file, vma); revert_creds_light(old_cred); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 84a96abfd090230334f935f666a145571c78b3a8..63544051404a9ff5ec8a74c754c3acfbc91f3279 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -826,7 +826,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, * didn't matter much as only a privileged process could open * the register file. */ - old_cred = override_creds_light(get_new_cred(file->f_cred)); + old_cred = override_creds(get_new_cred(file->f_cred)); f = open_exec(e->interpreter); put_cred(revert_creds_light(old_cred)); if (IS_ERR(f)) { diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 809305dd531760d47e781064c1fc6e328849fc6b..05b1d4cfb55afefd025c5f9c08afa81f67fdb9eb 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -393,7 +393,7 @@ extern int cachefiles_determine_cache_security(struct cachefiles_cache *cache, static inline void cachefiles_begin_secure(struct cachefiles_cache *cache, const struct cred **_saved_cred) { - *_saved_cred = override_creds_light(get_new_cred(cache->cache_cred)); + *_saved_cred = override_creds(get_new_cred(cache->cache_cred)); } static inline void cachefiles_end_secure(struct cachefiles_cache *cache, diff --git a/fs/coredump.c b/fs/coredump.c index ff119aaa5c313306b1183270a5d95904ed5951f4..4eae37892da58e982b53da4596952a1b3d2e1630 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -576,7 +576,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) if (retval < 0) goto fail_creds; - old_cred = override_creds_light(get_new_cred(cred)); + old_cred = override_creds(get_new_cred(cred)); ispipe = format_corename(&cn, &cprm, &argv, &argc); diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 77ff066aa938158cd8fcf691ebfbda6385f70449..374c6e35c7b4969ef193b71510ee9a34c45bb815 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -371,7 +371,7 @@ static void nfs_local_call_read(struct work_struct *work) struct iov_iter iter; ssize_t status; - save_cred = override_creds_light(get_new_cred(filp->f_cred)); + save_cred = override_creds(get_new_cred(filp->f_cred)); nfs_local_iter_init(&iter, iocb, READ); @@ -541,7 +541,7 @@ static void nfs_local_call_write(struct work_struct *work) ssize_t status; current->flags |= PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO; - save_cred = override_creds_light(get_new_cred(filp->f_cred)); + save_cred = override_creds(get_new_cred(filp->f_cred)); nfs_local_iter_init(&iter, iocb, WRITE); diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 629979b20e98cbc37e148289570574d9ba2e7675..3cae4057f8ba30914a91a3d368ace8f52175644d 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -311,7 +311,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, const struct user_key_payload *payload; ssize_t ret; - saved_cred = override_creds_light(get_new_cred(id_resolver_cache)); + saved_cred = override_creds(get_new_cred(id_resolver_cache)); rkey = nfs_idmap_request_key(name, namelen, type, idmap); put_cred(revert_creds_light(saved_cred)); diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index dda14811d092689e5aa44bdd29f25403e4e3a780..dafea9183b4e6413d61c0c83a1b8f26a9712d5c6 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -79,7 +79,7 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp) else new->cap_effective = cap_raise_nfsd_set(new->cap_effective, new->cap_permitted); - put_cred(override_creds_light(get_new_cred(new))); + put_cred(override_creds(get_new_cred(new))); put_cred(new); return 0; diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 61c8f4ab10777952088d1312f2e3d606dbc4f801..475c47f1c0afa2de56038bbb7cdd9fc5e583c8bd 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -81,7 +81,7 @@ nfs4_save_creds(const struct cred **original_creds) new->fsuid = GLOBAL_ROOT_UID; new->fsgid = GLOBAL_ROOT_GID; - *original_creds = override_creds_light(get_new_cred(new)); + *original_creds = override_creds(get_new_cred(new)); put_cred(new); return 0; } diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 8e323cc8e2c5b26ec660ceedeb95be4ef0ac809e..60b0275d5529d49ac87e8b89e4eb650ecd624f71 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -221,7 +221,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, new->cap_effective = cap_raise_nfsd_set(new->cap_effective, new->cap_permitted); - put_cred(override_creds_light(get_new_cred(new))); + put_cred(override_creds(get_new_cred(new))); put_cred(new); } else { error = nfsd_setuser_and_check_port(rqstp, cred, exp); diff --git a/fs/open.c b/fs/open.c index 23c414c10883927129a925a33680affc6f3a0a78..bd0a34653f0ebe210ddfeabf5ea3bc002bf2833d 100644 --- a/fs/open.c +++ b/fs/open.c @@ -448,7 +448,7 @@ static const struct cred *access_override_creds(void) */ override_cred->non_rcu = 1; - old_cred = override_creds_light(get_new_cred(override_cred)); + old_cred = override_creds(get_new_cred(override_cred)); /* override_cred() gets its own ref */ put_cred(override_cred); diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 0f19bdbc78a45f35df2829ccc8cc65deef244ffd..7805667b2e05264c011cd41ff6f77b9ae0fb30d9 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -741,7 +741,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc) return err; if (cc->new) - cc->old = override_creds_light(get_new_cred(cc->new)); + cc->old = override_creds(get_new_cred(cc->new)); return 0; } diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 08e683917d121b1fe8f0f0b4d4ba4f0f3c72f47d..151271f0586c7249cfa61cd45d249ec930adaf82 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -580,7 +580,7 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry, * We must be called with creator creds already, otherwise we risk * leaking creds. */ - old_cred = override_creds_light(override_cred); + old_cred = override_creds(override_cred); WARN_ON_ONCE(old_cred != ovl_creds(dentry->d_sb)); return override_cred; diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 9aa7493b1e10365cbcc97fceab26d614a319727f..2513a79a10b0bd69fa9d1c8a0f4726f3246ac39c 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -65,7 +65,7 @@ const struct cred *ovl_override_creds(struct super_block *sb) { struct ovl_fs *ofs = OVL_FS(sb); - return override_creds_light(ofs->creator_cred); + return override_creds(ofs->creator_cred); } void ovl_revert_creds(const struct cred *old_cred) diff --git a/fs/smb/client/cifs_spnego.c b/fs/smb/client/cifs_spnego.c index f2353bccc9f5e4637772a89dd0b0f42861fd21f3..f22dc0be357fa03cecc524976de5c69fddeef1ca 100644 --- a/fs/smb/client/cifs_spnego.c +++ b/fs/smb/client/cifs_spnego.c @@ -173,7 +173,7 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo, } cifs_dbg(FYI, "key description = %s\n", description); - saved_cred = override_creds_light(get_new_cred(spnego_cred)); + saved_cred = override_creds(get_new_cred(spnego_cred)); spnego_key = request_key(&cifs_spnego_key_type, description, ""); put_cred(revert_creds_light(saved_cred)); diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index 81d8d9802a56d4bb5d3d0480396f0c78c4c3fb80..d65e094b97cb2b1bd1c79d1959443fd8cae93f8f 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -292,7 +292,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) return -EINVAL; rc = 0; - saved_cred = override_creds_light(get_new_cred(root_cred)); + saved_cred = override_creds(get_new_cred(root_cred)); sidkey = request_key(&cifs_idmap_key_type, desc, ""); if (IS_ERR(sidkey)) { rc = -EINVAL; @@ -398,7 +398,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, if (!sidstr) return -ENOMEM; - saved_cred = override_creds_light(get_new_cred(root_cred)); + saved_cred = override_creds(get_new_cred(root_cred)); sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); if (IS_ERR(sidkey)) { cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n", diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index b13abbf67827fcad9c35606344cca055c09ba9c3..f09652bcca542464ed2f27fce9e912f797410612 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -780,7 +780,7 @@ int __ksmbd_override_fsids(struct ksmbd_work *work, cred->cap_effective = cap_drop_fs_set(cred->cap_effective); WARN_ON(work->saved_cred); - work->saved_cred = override_creds_light(get_new_cred(cred)); + work->saved_cred = override_creds(get_new_cred(cred)); if (!work->saved_cred) { abort_creds(cred); return -EINVAL; diff --git a/include/linux/cred.h b/include/linux/cred.h index 439d7a1840e7ccbc94d814728698a4b383bc39b3..a049993d22cca4e122091309f11fbc9e10d2e955 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -170,7 +170,7 @@ static inline bool cap_ambient_invariant_ok(const struct cred *cred) cred->cap_inheritable)); } -static inline const struct cred *override_creds_light(const struct cred *override_cred) +static inline const struct cred *override_creds(const struct cred *override_cred) { const struct cred *old = current->cred; diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index a6a50e86791e79745ace095af68c4b658e4a2cdc..946df208e7741a0e2e11eff2ee0b8978bcea7c3c 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_light(get_new_cred(req->creds)); + creds = override_creds(get_new_cred(req->creds)); if (!def->audit_skip) audit_uring_entry(req->opcode); diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index 42ca6e07e0f7b0fe54a9f09857f87fecb5aa7085..0fd424442118f38db0307fe10e0c6ee102c1f185 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_light(get_new_cred(ctx->sq_creds)); + creds = override_creds(get_new_cred(ctx->sq_creds)); mutex_lock(&ctx->uring_lock); if (!wq_list_empty(&ctx->iopoll_list)) diff --git a/kernel/acct.c b/kernel/acct.c index 4e28aa9e1ef278cd7fb3160a27b549155ceaffc3..a51a3b483fd9d94da916dc4e052ef4ab1042a39f 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -501,7 +501,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) flim = rlimit(RLIMIT_FSIZE); current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; /* Perform file operations on behalf of whoever enabled accounting */ - orig_cred = override_creds_light(get_new_cred(file->f_cred)); + orig_cred = override_creds(get_new_cred(file->f_cred)); /* * First check to see if there is enough free_space to continue diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 68b816955c9c7e0141a073f54b14949b4c37aae6..2d618b577e52e0117f77340dac79581882599578 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5216,7 +5216,7 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, * permissions using the credentials from file open to protect against * inherited fd attacks. */ - saved_cred = override_creds_light(get_new_cred(of->file->f_cred)); + saved_cred = override_creds(get_new_cred(of->file->f_cred)); ret = cgroup_attach_permissions(src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb, threadgroup, ctx->ns); diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 2fdadb2e8547ec86f48d84c81c95434c811cb3cd..857124d81f1255e7e6b4d18009b53191a71b57fc 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1469,7 +1469,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) */ cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds_light(get_new_cred(cred)); + old_cred = override_creds(get_new_cred(cred)); if (visible) ret = trace_add_event_call(&user->call); diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index 297059b7e2a367f5e745aac4557cda5996689a00..f8749d688d6676dd83d0c4b8e83ca893f1bd4248 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -124,7 +124,7 @@ int dns_query(struct net *net, /* make the upcall, using special credentials to prevent the use of * add_key() to preinstall malicious redirections */ - saved_cred = override_creds_light(get_new_cred(dns_resolver_cache)); + saved_cred = override_creds(get_new_cred(dns_resolver_cache)); rkey = request_key_net(&key_type_dns_resolver, desc, net, options); put_cred(revert_creds_light(saved_cred)); kfree(desc); From patchwork Sun Nov 24 13:43:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884118 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4226207A3B; Sun, 24 Nov 2024 13:44:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455869; cv=none; b=sfJ5Kd3o4xg6ob3DZZxQSweTVR6SVeYcw5Ufg94QC1ZxdrbhoGD0ajzhsH7lYgetqyHt55nR05WzvFReJ4KxE3/k7062EbVoZX5t94nm3hc+6CCVhA9aawLG2ICbUcCnH1vFuS4cMC6qJuCek32FrZa7fRsaW2MVVWeMD48bGZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455869; c=relaxed/simple; bh=eMs5v/Nm9a5GIOa2F0w8zTVJ777CLuzywV7nz78l/zk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qmhPGX5JAour5JRsPWHNq2Xh3p3yD3S+322PrIJ37+9cMUlPftQfxSZci2xKIw+D989PITP6K90iKMKEEjkKRWf+ycf0p5moESI0LBdMiV9t6DN1zJfdTQIlDD374Ub7x9o1/ylt9jG2Pm5psJBySX/cwPu+gQ6VwlQ729r20go= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jOyw+igD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jOyw+igD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D322BC4CECC; Sun, 24 Nov 2024 13:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455868; bh=eMs5v/Nm9a5GIOa2F0w8zTVJ777CLuzywV7nz78l/zk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jOyw+igDT4G+F4UY+8O6287DuHPZ4njyfSJPGSkTfGbx3Xo7FqHP6155RpXNa0JR3 GB+oki9UGuqXhtUaZD+gm6A+zdSzOXuuUrrNr+SUjSCCX8Vvqard83JM7mlxvkpEXI Cog4/c26wwP9KgK5wM4hyRN/XKTp4TfZWcy2L8H0RmGvs5mHrOqfbm/YqtwgfNJhp2 6ZAGgyJdQqItmPMFTIy3JRH5rANyDE6Tvks4C37jza+AdUEJVl0CdaySo3TEr4ct7x D7N9IlY+ZCqBdGzYtMUlMx89F54zSQ3uEAD4ZatxtzmglbDfT8tJYIHfGvyxcVhAik eLa3+rSY657KA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 06/26] tree-wide: s/revert_creds_light()/revert_creds()/g Date: Sun, 24 Nov 2024 14:43:52 +0100 Message-ID: <20241124-work-cred-v1-6-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=17093; i=brauner@kernel.org; h=from:subject:message-id; bh=eMs5v/Nm9a5GIOa2F0w8zTVJ777CLuzywV7nz78l/zk=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7687KyNN7r3ZxR7SE8kfPtSEtrf47Hhh/WZZzZ1ngl +ybJVPjOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbiHsbwz2RKlX/LOeZIbskT HacLOfZqzc0sc3o3c8pRVX+t9n0TmRgZVq/7enPZYekUM499YpNUNe75Rd92Z7Nfrb3WledNejc nEwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Rename all calls to revert_creds_light() back to revert_creds(). Signed-off-by: Christian Brauner --- drivers/base/firmware_loader/main.c | 2 +- drivers/crypto/ccp/sev-dev.c | 2 +- drivers/target/target_core_configfs.c | 2 +- fs/aio.c | 2 +- fs/backing-file.c | 10 +++++----- fs/binfmt_misc.c | 2 +- fs/cachefiles/internal.h | 2 +- fs/coredump.c | 2 +- fs/nfs/localio.c | 4 ++-- fs/nfs/nfs4idmap.c | 2 +- fs/nfsd/auth.c | 2 +- fs/nfsd/filecache.c | 2 +- fs/nfsd/nfs4recover.c | 2 +- fs/open.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/dir.c | 2 +- fs/overlayfs/util.c | 2 +- fs/smb/client/cifs_spnego.c | 2 +- fs/smb/client/cifsacl.c | 4 ++-- fs/smb/server/smb_common.c | 2 +- include/linux/cred.h | 2 +- io_uring/io_uring.c | 2 +- io_uring/sqpoll.c | 2 +- kernel/acct.c | 2 +- kernel/cgroup/cgroup.c | 2 +- kernel/trace/trace_events_user.c | 2 +- net/dns_resolver/dns_query.c | 2 +- 27 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 729df15600efb743091d7e1b71a306cdfa9acbf0..96a2c3011ca82148b4ba547764a1f92e252dbf5f 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -944,7 +944,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, } else ret = assign_fw(fw, device); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); put_cred(kern_cred); out: diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index ffae20fd52bc03e7123b116251c77a3ccd7c6cde..187c34b02442dd50640f88713bc5f6f88a1990f4 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -249,7 +249,7 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m fp = file_open_root(&root, filename, flags, mode); path_put(&root); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); return fp; } diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 7788e1fe2633ded4f265ff874c62dc4a21fd1b6e..ec7a5598719397da5cadfed12a05ca8eb81e46a9 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -3758,7 +3758,7 @@ static int __init target_core_init_configfs(void) } old_cred = override_creds(get_new_cred(kern_cred)); target_init_dbroot(); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); put_cred(kern_cred); return 0; diff --git a/fs/aio.c b/fs/aio.c index 7e0ec687f480c05358c6c40638a7e187aafd8124..5e57dcaed7f1ae1e4b38009b51a665954b31f5bd 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1642,7 +1642,7 @@ static void aio_fsync_work(struct work_struct *work) const struct cred *old_cred = override_creds(get_new_cred(iocb->fsync.creds)); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); put_cred(iocb->fsync.creds); iocb_put(iocb); } diff --git a/fs/backing-file.c b/fs/backing-file.c index bcf8c0b9ff42e2dd30dc239bb2580942fe6c40a7..a38737592ec77b50fa4d417a98ca272ca5f89399 100644 --- a/fs/backing-file.c +++ b/fs/backing-file.c @@ -197,7 +197,7 @@ ssize_t backing_file_read_iter(struct file *file, struct iov_iter *iter, backing_aio_cleanup(aio, ret); } out: - revert_creds_light(old_cred); + revert_creds(old_cred); if (ctx->accessed) ctx->accessed(iocb->ki_filp); @@ -264,7 +264,7 @@ ssize_t backing_file_write_iter(struct file *file, struct iov_iter *iter, backing_aio_cleanup(aio, ret); } out: - revert_creds_light(old_cred); + revert_creds(old_cred); return ret; } @@ -283,7 +283,7 @@ ssize_t backing_file_splice_read(struct file *in, struct kiocb *iocb, old_cred = override_creds(ctx->cred); ret = vfs_splice_read(in, &iocb->ki_pos, pipe, len, flags); - revert_creds_light(old_cred); + revert_creds(old_cred); if (ctx->accessed) ctx->accessed(iocb->ki_filp); @@ -314,7 +314,7 @@ ssize_t backing_file_splice_write(struct pipe_inode_info *pipe, file_start_write(out); ret = out->f_op->splice_write(pipe, out, &iocb->ki_pos, len, flags); file_end_write(out); - revert_creds_light(old_cred); + revert_creds(old_cred); if (ctx->end_write) ctx->end_write(iocb, ret); @@ -339,7 +339,7 @@ int backing_file_mmap(struct file *file, struct vm_area_struct *vma, old_cred = override_creds(ctx->cred); ret = call_mmap(vma->vm_file, vma); - revert_creds_light(old_cred); + revert_creds(old_cred); if (ctx->accessed) ctx->accessed(vma->vm_file); diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 63544051404a9ff5ec8a74c754c3acfbc91f3279..5692c512b740bb8f11d5da89a2e5f388aafebc13 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -828,7 +828,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, */ old_cred = override_creds(get_new_cred(file->f_cred)); f = open_exec(e->interpreter); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); if (IS_ERR(f)) { pr_notice("register: failed to install interpreter file %s\n", e->interpreter); diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 05b1d4cfb55afefd025c5f9c08afa81f67fdb9eb..1cfeb3b3831900b7c389c55c59fc7e3b84acfca6 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -399,7 +399,7 @@ static inline void cachefiles_begin_secure(struct cachefiles_cache *cache, static inline void cachefiles_end_secure(struct cachefiles_cache *cache, const struct cred *saved_cred) { - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); } /* diff --git a/fs/coredump.c b/fs/coredump.c index 4eae37892da58e982b53da4596952a1b3d2e1630..0d3a65cac546db6710eb1337b0a9c4ec0ffff679 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -781,7 +781,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) kfree(argv); kfree(cn.corename); coredump_finish(core_dumped); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); fail_creds: put_cred(cred); fail: diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index 374c6e35c7b4969ef193b71510ee9a34c45bb815..cb0ba4a810324cc9a4913767ce5a9b4f52c416ac 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -381,7 +381,7 @@ static void nfs_local_call_read(struct work_struct *work) nfs_local_read_done(iocb, status); nfs_local_pgio_release(iocb); - put_cred(revert_creds_light(save_cred)); + put_cred(revert_creds(save_cred)); } static int @@ -554,7 +554,7 @@ static void nfs_local_call_write(struct work_struct *work) nfs_local_vfs_getattr(iocb); nfs_local_pgio_release(iocb); - put_cred(revert_creds_light(save_cred)); + put_cred(revert_creds(save_cred)); current->flags = old_flags; } diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 3cae4057f8ba30914a91a3d368ace8f52175644d..25b6a8920a6545d43f437f2f0330ccc35380ccc3 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -313,7 +313,7 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, saved_cred = override_creds(get_new_cred(id_resolver_cache)); rkey = nfs_idmap_request_key(name, namelen, type, idmap); - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey); diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c index dafea9183b4e6413d61c0c83a1b8f26a9712d5c6..c399a5f030afbde6ad7bc9cf28f1e354d74db9a8 100644 --- a/fs/nfsd/auth.c +++ b/fs/nfsd/auth.c @@ -27,7 +27,7 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp) int flags = nfsexp_flags(cred, exp); /* discard any old override before preparing the new set */ - put_cred(revert_creds_light(get_cred(current_real_cred()))); + put_cred(revert_creds(get_cred(current_real_cred()))); new = prepare_creds(); if (!new) return -ENOMEM; diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index fef2b8eb3a94736cbe8342a95f205f173f598447..3ae9d8356d7de5190b4b038b1104b6d93d07eb65 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -1252,7 +1252,7 @@ nfsd_file_acquire_local(struct net *net, struct svc_cred *cred, beres = nfsd_file_do_acquire(NULL, net, cred, client, fhp, may_flags, NULL, pnf, true); - put_cred(revert_creds_light(save_cred)); + put_cred(revert_creds(save_cred)); return beres; } diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 475c47f1c0afa2de56038bbb7cdd9fc5e583c8bd..2834091cc988b1403aa2908f69e336f2fe4e0922 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -89,7 +89,7 @@ nfs4_save_creds(const struct cred **original_creds) static void nfs4_reset_creds(const struct cred *original) { - put_cred(revert_creds_light(original)); + put_cred(revert_creds(original)); } static void diff --git a/fs/open.c b/fs/open.c index bd0a34653f0ebe210ddfeabf5ea3bc002bf2833d..0a5cd8e74fb9bb4cc484d84096c6123b21acbf16 100644 --- a/fs/open.c +++ b/fs/open.c @@ -523,7 +523,7 @@ static long do_faccessat(int dfd, const char __user *filename, int mode, int fla } out: if (old_cred) - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); return res; } diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 7805667b2e05264c011cd41ff6f77b9ae0fb30d9..439bd9a5ceecc4d2f4dc5dfda7cea14c3d9411ba 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -749,7 +749,7 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc) static void ovl_revert_cu_creds(struct ovl_cu_creds *cc) { if (cc->new) { - put_cred(revert_creds_light(cc->old)); + put_cred(revert_creds(cc->old)); put_cred(cc->new); } } diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c index 151271f0586c7249cfa61cd45d249ec930adaf82..c9993ff66fc26ec45ab5a5b4679d1d2056a01df2 100644 --- a/fs/overlayfs/dir.c +++ b/fs/overlayfs/dir.c @@ -575,7 +575,7 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry, } /* - * Caller is going to match this with revert_creds_light() and drop + * Caller is going to match this with revert_creds() and drop * referenec on the returned creds. * We must be called with creator creds already, otherwise we risk * leaking creds. diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index 2513a79a10b0bd69fa9d1c8a0f4726f3246ac39c..0819c739cc2ffce0dfefa84d3ff8f9f103eec191 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -70,7 +70,7 @@ const struct cred *ovl_override_creds(struct super_block *sb) void ovl_revert_creds(const struct cred *old_cred) { - revert_creds_light(old_cred); + revert_creds(old_cred); } /* diff --git a/fs/smb/client/cifs_spnego.c b/fs/smb/client/cifs_spnego.c index f22dc0be357fa03cecc524976de5c69fddeef1ca..6284d924fdb1e25e07af7e10b6286df97c0942dd 100644 --- a/fs/smb/client/cifs_spnego.c +++ b/fs/smb/client/cifs_spnego.c @@ -175,7 +175,7 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo, cifs_dbg(FYI, "key description = %s\n", description); saved_cred = override_creds(get_new_cred(spnego_cred)); spnego_key = request_key(&cifs_spnego_key_type, description, ""); - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); #ifdef CONFIG_CIFS_DEBUG2 if (cifsFYI && !IS_ERR(spnego_key)) { diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index d65e094b97cb2b1bd1c79d1959443fd8cae93f8f..5718906369a96fc80bee6a472f93bac1159f1709 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -327,7 +327,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) out_key_put: key_put(sidkey); out_revert_creds: - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); return rc; invalidate_key: @@ -438,7 +438,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, out_key_put: key_put(sidkey); out_revert_creds: - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); kfree(sidstr); /* diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index f09652bcca542464ed2f27fce9e912f797410612..f1d770a214c8b2c7d7dd4083ef57c7130bbce52c 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -800,7 +800,7 @@ void ksmbd_revert_fsids(struct ksmbd_work *work) WARN_ON(!work->saved_cred); cred = current_cred(); - put_cred(revert_creds_light(work->saved_cred)); + put_cred(revert_creds(work->saved_cred)); put_cred(cred); work->saved_cred = NULL; } diff --git a/include/linux/cred.h b/include/linux/cred.h index a049993d22cca4e122091309f11fbc9e10d2e955..7ce1551c8aa7b7e000dffbd49ba6b27530ebc9ef 100644 --- a/include/linux/cred.h +++ b/include/linux/cred.h @@ -178,7 +178,7 @@ static inline const struct cred *override_creds(const struct cred *override_cred return old; } -static inline const struct cred *revert_creds_light(const struct cred *revert_cred) +static inline const struct cred *revert_creds(const struct cred *revert_cred) { const struct cred *override_cred = current->cred; diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 946df208e7741a0e2e11eff2ee0b8978bcea7c3c..ad4d8e94a8665cf5f3e9ea0fd9bc6c03a03cc48f 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -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_light(creds)); + put_cred(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 0fd424442118f38db0307fe10e0c6ee102c1f185..1ca96347433695de1eb0e3bec7c6da4299e9ceb0 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -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_light(creds)); + put_cred(revert_creds(creds)); } return ret; diff --git a/kernel/acct.c b/kernel/acct.c index a51a3b483fd9d94da916dc4e052ef4ab1042a39f..ea8c94887b5853b10e7a7e632f7b0bc4d52ab10b 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -541,7 +541,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) } out: current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; - put_cred(revert_creds_light(orig_cred)); + put_cred(revert_creds(orig_cred)); } /** diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 2d618b577e52e0117f77340dac79581882599578..1a94e8b154beeed45d69056917f3dd9fc6d950fa 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5220,7 +5220,7 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, ret = cgroup_attach_permissions(src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb, threadgroup, ctx->ns); - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); if (ret) goto out_finish; diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index 857124d81f1255e7e6b4d18009b53191a71b57fc..c54ae15f425c2c1dad3f8c776027beca2f00a0a5 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1476,7 +1476,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) else ret = trace_remove_event_call(&user->call); - put_cred(revert_creds_light(old_cred)); + put_cred(revert_creds(old_cred)); put_cred(cred); return ret; diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index f8749d688d6676dd83d0c4b8e83ca893f1bd4248..0b0789fe2194151102d5234aca3fc2dae9a1ed69 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -126,7 +126,7 @@ int dns_query(struct net *net, */ saved_cred = override_creds(get_new_cred(dns_resolver_cache)); rkey = request_key_net(&key_type_dns_resolver, desc, net, options); - put_cred(revert_creds_light(saved_cred)); + put_cred(revert_creds(saved_cred)); kfree(desc); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey); From patchwork Sun Nov 24 13:43:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884119 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05856208978; Sun, 24 Nov 2024 13:44:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455871; cv=none; b=HkeIM9SX0cXXjdgLC113WnaKwT6BQySFRfLK/KGPMuaN9J4zB30eJOI7PeeIGuknW3WM2J6i5MqGL9755mh9KNdkck6Df0yNcB81vlHwYunika3jQahmVsmiCwiZwBzerJuTPnGKXx6uIZ1Ia/wPg/AMg+ispcQU8/rnh4sSaDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455871; c=relaxed/simple; bh=UUdOyTarqKECdM6Rypy0inbWwzf+pM4wFf89gzXG8RQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GFZZyRwTTX+xGE4tjXjn9ND/v0HnoGYDnVR4N2oN64EBsRv6cicMM8GVsGK3hTu/WaKBGYIUDaou8lgeT5iKl2Jl+BNpXMmGdEyKqeIW06Jd29cFHOz44Gc0nKL4mCszq0BvY0jTwDcVPUQeABFXvrig9XrQzvinVONXjFL4JrQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UQ8KkMn3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UQ8KkMn3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA843C4CED3; Sun, 24 Nov 2024 13:44:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455870; bh=UUdOyTarqKECdM6Rypy0inbWwzf+pM4wFf89gzXG8RQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UQ8KkMn33IsQgvYN6dnMcwj/tJCyubObq0f9Gt3w7cd+mXiw39GRq8vZBOY4IRAY9 aOUubBDRWuJ7rC0SGie7kNppD6QznREwI3N1FcxzzWi5j1sLLT/2mmpWqZ16IY+QKG WsdCFw545wkH8IoJEpPcJhxMO20gyjNVkkSV4lAi7oXu1g9BatO8s3KcUFJOY/fVT3 fAnMykyxB3EdbO6WrBClLQQM06obKEbZRLNB+6Wp50SpqCOVujj6UhHhHoS7faj97m BiPc8XAwhxzld/h7dOXkZBzrtI6NfMVs+ZSsrJDoREmWmyHX6XHdiPgB/3nnlSjzeL y0YkIn5/942NA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 07/26] firmware: avoid pointless reference count bump Date: Sun, 24 Nov 2024 14:43:53 +0100 Message-ID: <20241124-work-cred-v1-7-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1050; i=brauner@kernel.org; h=from:subject:message-id; bh=UUdOyTarqKECdM6Rypy0inbWwzf+pM4wFf89gzXG8RQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685iinO9UnDfL+9KYvo5z6fXPj0xLtrFEOdQtkRB0 +PoIgPvjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIlYKDAyPFlhMHFz0kGuA++T Xr1VTs3K+ODQ9e3Lmj5jbuXzh0t5dzD8FTW6wvhc82jhzM7T8hnST/ZUxpZ9eOraYsbfWOhasvE UNwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The creds are allocated via prepare_kernel_cred() which has already taken a reference. Signed-off-by: Christian Brauner --- drivers/base/firmware_loader/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c index 96a2c3011ca82148b4ba547764a1f92e252dbf5f..740ef6223a62ca37e776d1558f840f09c7c46c95 100644 --- a/drivers/base/firmware_loader/main.c +++ b/drivers/base/firmware_loader/main.c @@ -912,7 +912,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret = -ENOMEM; goto out; } - old_cred = override_creds(get_new_cred(kern_cred)); + old_cred = override_creds(kern_cred); ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL); @@ -945,7 +945,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name, ret = assign_fw(fw, device); put_cred(revert_creds(old_cred)); - put_cred(kern_cred); out: if (ret < 0) { From patchwork Sun Nov 24 13:43:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884120 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D27F7209667; Sun, 24 Nov 2024 13:44:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455872; cv=none; b=o8tMUsperi+fOkgN6bGXNN+kIAUr+3wf5RyAbq2VdiBPC5zqOfL9wxnLTr0WboeRBA+QVYZn1QGYWTf91ldL+0PNbEmqP8mFEp+3t76s9AnIxMmg7TkoKkaBmygUh8vSG6xwbrRA6yuDAC6sJKnW92JKeyL7Z95Zvhiv872FrF4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455872; c=relaxed/simple; bh=JyuYZyB4OGl5WxMFcCkQWT6w+5cVFX8MiGQmbuR3Uto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=KUekGebyeWLkYmjxfHwaN4A1Kb4ciZi31jDwHr+71zGgL2gFciXI+IZ5RGK/tEtm4ZsIORgC9Az8T18BuzEJ1Bcmn/TMNx1fiUdyXXpb3YoifNnmv8DVliomzsvybL0hC3+uz6v1/eZJxy+N9py2shU6BwSZY0vsObx+NRo9Sd8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XTvnvEeY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XTvnvEeY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24B61C4CED1; Sun, 24 Nov 2024 13:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455872; bh=JyuYZyB4OGl5WxMFcCkQWT6w+5cVFX8MiGQmbuR3Uto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XTvnvEeYZD0vzhoR6ZADEwGB9P1N+jyf7ReEpFcLc0ak9YybywMzpe7J/y1hEbKaW CRqRurxZ1EpZ10THfXolog6ZjaQaLwNA6Ft6C1LKx49Aa9wl9dublc/8pctepTtUd7 mW89QbPuTtNc4yRXKcuI+oghcWXAEoVzrGQ0CwqfINGmtln9UVCiJTdSAlrUpVD3V1 rzXqMp9e2bu/OvfD4bH+nV6nWMiNOBQ6Nodb9FPJVCRgkAQmsGn2qpluSZeeQNlGCj zSG9X8X2gilrCbIg0jbi9UyDyEBRgzYwC7Lu0gzL1EjzOfsa4i8T7f7eDqlD4BwH2k SLY90QJfmtX+A== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 08/26] sev-dev: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:43:54 +0100 Message-ID: <20241124-work-cred-v1-8-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=980; i=brauner@kernel.org; h=from:subject:message-id; bh=JyuYZyB4OGl5WxMFcCkQWT6w+5cVFX8MiGQmbuR3Uto=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7686+EeKebvDqP9uid6reyQ9FGlez7nW5uzK0+93iu y8nCjGt7ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI0y0M/z1XXTnam5Mr8Ddh 9WqPeZvU36o89dUXXqTQuee3T4u7wSJGhv/lieqfHy/ukDYUXjh992Iri4edM9eGl/2fIsNtO6f lChcA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 and fix a memory leak while at it. The new creds are created via prepare_creds() and then reverted via put_cred(revert_creds()). The additional reference count bump from override_creds() wasn't even taken into account before. Signed-off-by: Christian Brauner --- drivers/crypto/ccp/sev-dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c index 187c34b02442dd50640f88713bc5f6f88a1990f4..2e87ca0e292a1c1706a8e878285159b481b68a6f 100644 --- a/drivers/crypto/ccp/sev-dev.c +++ b/drivers/crypto/ccp/sev-dev.c @@ -244,7 +244,7 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m if (!cred) return ERR_PTR(-ENOMEM); cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds(get_new_cred(cred)); + old_cred = override_creds(cred); fp = file_open_root(&root, filename, flags, mode); path_put(&root); From patchwork Sun Nov 24 13:43:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884121 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D93A4209695; Sun, 24 Nov 2024 13:44:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455874; cv=none; b=uQMldah1ui+UsKnmzncx+wwU2wXFZ4P9Tbdt9iesHz1QYk4y+ANdaSeSlqSFnkfpNkHlk2bjCUWfkHw1k+H88DXdQnXnNrZE+U3h9Wr+hiWUMaJrQfD/ZHExPFDfyGUuJOANx6DdCTdyxW0nrG8o8GHuPTLHSq1TCO65gb+dVkw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455874; c=relaxed/simple; bh=C/wR2ku2PTKFCMQ8eQB1+MnF9WOeryw7aC1vMHma/eU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ecy7HUEYWNLQjkf+quQ3Fo3esuUBTBS5uZroj80DaDI0JI36ms4UzJkIdw8ix3j5Hc9HkULmgWovVNxhIiHwhLM14KBJUwLfVl/5Cj5yL2v2K/JsHxZhNKEs4l3LPHc6NK0viaTYi5DEDdCUDGX7uWtohBtBrJNGFzopUn1OJJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FEadPYHz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FEadPYHz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E0AEC4CECC; Sun, 24 Nov 2024 13:44:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455874; bh=C/wR2ku2PTKFCMQ8eQB1+MnF9WOeryw7aC1vMHma/eU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FEadPYHzer9PRgNVdigPvPMS0fTvjyx8CK7vhZ5lAJ7k/yzIQ6tzvVpj9MACtNsOB YGHlgR8c1lTLSFK1HKKHy7fO6oXUE95eNdHPvHokNDM1PfcuS4wBYNAw5mB6tRyhAo zs6hg4moTnhh+FOgBr+BfwqCHNInJWAEOsXTirdyK9aXoWHPhHdwo7J52EdTPNOIhx Jx46YoYYsKF8qO3qbado55lbFyQ7yg93ytDORD4vDF2fgFI5n2SggyCm00FTbI+7XM 9UxqHQ52psuhXJcuravjF9Mp0Xo5VhKRqhAxcxnfUYuyyb3FvaSNV4GWfPLWLvmgV7 pVdrOVrYnd5cA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 09/26] target_core_configfs: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:43:55 +0100 Message-ID: <20241124-work-cred-v1-9-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=857; i=brauner@kernel.org; h=from:subject:message-id; bh=C/wR2ku2PTKFCMQ8eQB1+MnF9WOeryw7aC1vMHma/eU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685eacK0T/CCq6aZQvQFkZfO/j8PnZZ7N32PYMNDO 8H/pv/zO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbSsZjhn3XHx/sfGC+JL3oZ e3HT2v08lQulRfZfvs/7/V7vv6vOPfcYGS40PhIsXM3xdvdjg3d1u83PuG/LWX5krvUT/hvfZx1 kYeIBAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The creds are allocated via prepare_kernel_cred() which has already taken a reference. Signed-off-by: Christian Brauner --- drivers/target/target_core_configfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index ec7a5598719397da5cadfed12a05ca8eb81e46a9..d102ab79c56dd7977465f7455749e6e7a2c9fba1 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -3756,10 +3756,9 @@ static int __init target_core_init_configfs(void) ret = -ENOMEM; goto out; } - old_cred = override_creds(get_new_cred(kern_cred)); + old_cred = override_creds(kern_cred); target_init_dbroot(); put_cred(revert_creds(old_cred)); - put_cred(kern_cred); return 0; From patchwork Sun Nov 24 13:43:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884122 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB3111D63CF; Sun, 24 Nov 2024 13:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455877; cv=none; b=kZuxoUw3nr/+NGwG6q244xOF9NC5CsamErNFER9NSNDo7SjVuQ5+lehy1nV1plmlMq/8KrpJYvBpz76A6CncSRPAb4wDm2ps9ocrUq/ignau9i2tHZkcF1NBzecOE9NrdGM/x2CywL3lwKyx7T9A04OCeIXpgu0nAAJi5db0pac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455877; c=relaxed/simple; bh=5BZqSEtfHEZtuwJx5SewGy8hXt5AEF8UkUzuAtgQ7MI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Qu4AtX5ykOvkywi5VqcY8hBwTGaUpBkIRLZgTSgM4MMR2BAATfRq1ewe3BIrHBweFeFZE5x6xOvhUuWuCmCkMTUqtsMIE3pCZ1Xks+P2JBPkoDqZ2LfEhMe+HhEvYhpNvzA2tR7TC8IBn1YGYlbldwVOWpkCn54CFI+JtmBra2g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rG/xtGVD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rG/xtGVD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FD84C4CED1; Sun, 24 Nov 2024 13:44:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455876; bh=5BZqSEtfHEZtuwJx5SewGy8hXt5AEF8UkUzuAtgQ7MI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rG/xtGVDH06HE1ilf2qXSYqvCpFWpW5SeYMgB6BX71IMv+lteG8dNKkBtgDQ+grBI /H3QIIsUMoYyJxSzK2CkinyoPK1qQ69scnWptLeHeQuFulFnro9/h28JnBLxHMs004 HNl4Ket5BNxo3MzJv2EbldS+fHcXMT3aGqofO2YEVgP51EfPI1pnwziqQGjQJYRet9 +5fPaxqT7xsxweWB7p0L1JqsqIbzUjlQLCsUlCGtDu0aU4F4xpQTc/KmT20WkZ3qNe WoiAx79A8Rn6mVFCUtFYXnJhO+dwDtbfvfWCea8pneSmAf8vZ0GHw4KlZmcxD7EPfY sHS2is55pAXjg== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 10/26] aio: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:43:56 +0100 Message-ID: <20241124-work-cred-v1-10-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=903; i=brauner@kernel.org; h=from:subject:message-id; bh=5BZqSEtfHEZtuwJx5SewGy8hXt5AEF8UkUzuAtgQ7MI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7686ZcOrmgZ7jxp4tdyqafdv8vxxkVTrwPa5RfM4k2 7qEWbuSO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACaS0c7wVzR+u/vGH29PnL9i +DWi4Fy60Xl5Y8c2S+NfV9Ka7hYf3sHwh/+b7qkPJdcDnkiFs3qc+WbO/lViZ6C74S1JVZtUnj+ vuQE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/aio.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 5e57dcaed7f1ae1e4b38009b51a665954b31f5bd..98eb0f5d0ee49c564d87f9050d304c5a99130445 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1639,11 +1639,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(get_new_cred(iocb->fsync.creds)); + const struct cred *old_cred = override_creds(iocb->fsync.creds); iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); put_cred(revert_creds(old_cred)); - put_cred(iocb->fsync.creds); iocb_put(iocb); } From patchwork Sun Nov 24 13:43:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884123 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62AA5209F56; Sun, 24 Nov 2024 13:44:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455879; cv=none; b=QBNG3w5en7MLbfE/jyFzpxG8QiTrFDrxCPTH5a/9S06Ry4tBECcdGk5dVeEHB1YkIQWyl/rD+0nE4gs3DhKN9PTl7GJaWr+KTW98cqWp9WlGRJTDr0tW0TartRgTcQQq0sfMBBchzZNtT9FeM/4wXSyS3OQ+LTix9BAid/fahFs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455879; c=relaxed/simple; bh=kuDO6c0Xi1i8u6b8BmRNFBm4DAnCEEtoeHcGrcaxLc8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lQijvDCioZSIJNti47Yo1s7VrHs7masyGyohrNjSRaySr3HZd4eBRGSSBPYb+4tF+FYFr3WVWJeStAFTkt+Hv1vk3pbWblZ8wyF/qm7XlqGNrEB0RP2DtDh0ZoWOD4BYsgBxNa/V3ib3IHyEP/qUvD+MHZP5iJBWhUqHXsaMPl4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l2ZbJEC0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l2ZbJEC0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 648CBC4CECC; Sun, 24 Nov 2024 13:44:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455879; bh=kuDO6c0Xi1i8u6b8BmRNFBm4DAnCEEtoeHcGrcaxLc8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l2ZbJEC0hx+o5NKocINkLGcrMqeNjFa3SGg1WemZUOUuyVXBtk8X6wLK1TeCh77WG PlJ8NaTDu98kUH5/8/riCuACP6GDZrzGn8ksOznbrDTWeDbZlIzdgbf/t2Tb1v3TeX xnnUS7fAYJXyppLcu5+vARKK4rkLU5y+do4hh+4K451MN+E8DY91PXcCTkLXH7/rcP TIz/J5eaIQ98hyHbPJyGfOSgQX7nIKWzKQPsrQ3sJVpFRCIw1Cqvq5gXZ9kHr2SkJr OQZUrGRzuAV/K0BH4bA3DVh6nevZPgM3d+V2CE0XXKsTXwno41pS0SBvrUc3OIZbz6 H3fplp5DD5KlA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 11/26] binfmt_misc: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:43:57 +0100 Message-ID: <20241124-work-cred-v1-11-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=915; i=brauner@kernel.org; h=from:subject:message-id; bh=kuDO6c0Xi1i8u6b8BmRNFBm4DAnCEEtoeHcGrcaxLc8=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ768758Trlwrsrn20uTEk/Pi971rHzc+buVQx7ULdu9 Vr1GyeSd3eUsjCIcTHIiimyOLSbhMst56nYbJSpATOHlQlkCAMXpwBM5OphRobpizfu6ra4dS3t eG5uFfMy9Tv7n3gJd/pzx+dY79n4UHYNI8PqJOFlVvPuanlZtvzav7G6v+6YSmJPxnGBFeslwnh TG3gA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/binfmt_misc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 5692c512b740bb8f11d5da89a2e5f388aafebc13..31660d8cc2c610bd42f00f1de7ed6c39618cc5db 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c @@ -826,9 +826,9 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, * didn't matter much as only a privileged process could open * the register file. */ - old_cred = override_creds(get_new_cred(file->f_cred)); + old_cred = override_creds(file->f_cred); f = open_exec(e->interpreter); - put_cred(revert_creds(old_cred)); + revert_creds(old_cred); if (IS_ERR(f)) { pr_notice("register: failed to install interpreter file %s\n", e->interpreter); From patchwork Sun Nov 24 13:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884124 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58B3920A5DA; Sun, 24 Nov 2024 13:44:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455881; cv=none; b=kcQ65Da1dwSiCjjmLnsekMCV79+gDDeCmucXYH2C8+lsfR4sNs0OHBLmWKQF+asUubeXgvOY8GifNldNLVMe+kbBNNxrGP850qBVlpId1olM06m7qhoEcmPNVDUWvCezQ3WedNMvdaeyuflArRSGroLkRlkD4FiTQZeGNIVg87Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455881; c=relaxed/simple; bh=IFLM84NiqCXkwMMafq8E9pIDiDKUxCWKPeY0cpJ2rUw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=mhHqXMImRJtBSUrONszImcFkF9xu5k3JTBcz2mra46DIHAGaCMztgBcUO1CSmgW/RveYAB7cspVpgdikPuKq5UYnpkp8VrbCEDUS/KZBjOtnUQgZo3iqE+lqa7/35Fgqrd0Oh9T9FbWQpS/XKDX07IvaGNim7s08v6NupgTchPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sI2opDzO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sI2opDzO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7223EC4CED6; Sun, 24 Nov 2024 13:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455880; bh=IFLM84NiqCXkwMMafq8E9pIDiDKUxCWKPeY0cpJ2rUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sI2opDzOgQEi7xC9vj+5EmjCS3qDtfQxzTdESzu6itZdR+vbXESIvYinSUHqjX2hu I1XE4JpgQpPixcSLQSXDo7rvpmiWnc9Loc6JgbsJKT4SvIZPEdpYx6qYqHKOBqxqUA Te7zOO4BbCxzVykNtgpePCKuEQ6CrtWsbElOabMAYTtZHpXlACxuLTrpOq4lAdispV xhKxnXFFXbXeAwg6j06IaJ3xXAvHIdVTdZuK+T3pDkb5dkkUIT2ecHH1PL/OXZtGs0 nxT4sgAbe3lhr6RGsj+K7iR9oXpA4rborSqls0wX3rZmFqncfl/JGNxF6z9qn9ncik l7bxMC370jAEA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 12/26] coredump: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:43:58 +0100 Message-ID: <20241124-work-cred-v1-12-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=929; i=brauner@kernel.org; h=from:subject:message-id; bh=IFLM84NiqCXkwMMafq8E9pIDiDKUxCWKPeY0cpJ2rUw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7687lfLHW+9fNWQ8rBDqaV2iuiTVczhpRyfFHouKNr r33S8tbHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABN5IMTI8Ob/e/FgDa6ZLE+7 7Lu+KT3ylpXTub4o19E8cv8KoUdvDzAy/PB4duRBpCrP6b3WG3h03V7JtpdZCv/du6XsTkkVo9E SPgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The creds are allocated via prepare_creds() which has already taken a reference. Signed-off-by: Christian Brauner --- fs/coredump.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/coredump.c b/fs/coredump.c index 0d3a65cac546db6710eb1337b0a9c4ec0ffff679..d48edb37bc35c0896d97a2f6a6cc259d8812f936 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -576,7 +576,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) if (retval < 0) goto fail_creds; - old_cred = override_creds(get_new_cred(cred)); + old_cred = override_creds(cred); ispipe = format_corename(&cn, &cprm, &argv, &argc); @@ -781,7 +781,7 @@ void do_coredump(const kernel_siginfo_t *siginfo) kfree(argv); kfree(cn.corename); coredump_finish(core_dumped); - put_cred(revert_creds(old_cred)); + revert_creds(old_cred); fail_creds: put_cred(cred); fail: From patchwork Sun Nov 24 13:43:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884125 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28E0820A5C4; Sun, 24 Nov 2024 13:44:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455883; cv=none; b=RLiTbVr+vcU7ptT3To08fWmfObu2DD0xj6sYeZdKtpQ+VdYUotK7QDfgNNHAQlmwRH+/rVVKoodxcYZX0iyGl9Ga3kP3xx3gHD4yllAPYEMy/DN/kS1l9cKjy4obcOp5UuIpu0TRX3cLhJCU5dAwXnguHmo93DauG6N3uPNHFik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455883; c=relaxed/simple; bh=QzKXOaGTqarytwObmAB0KM5UViuc2HdStxVkwRWPnLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MhxrV5Qztum/dXFgDGS8wwWJ/yV+vQs7HZFNdRQI96B5UrVqHRaWD8LyeSk6orFwcGEhK0pGrLS/ZmUhYNmR5eAcB0acc8Gj3Tkk07A9OG3LVuTLblNiHVLr77gEi7+lQsDV8FNi+p5X73UCotR4FIMcQewYQc0G4BJIAVv0qvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sJqmTmSW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sJqmTmSW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64E6BC4CECC; Sun, 24 Nov 2024 13:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455883; bh=QzKXOaGTqarytwObmAB0KM5UViuc2HdStxVkwRWPnLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sJqmTmSW7/AOqaKttw23UXMUZBmV281OmhEwoB7uLb/zPDrpNs0xqpsC1owkQoaBi 8ks/k/27Sp/xy9RLZBbN3Q2B3tA4QCTrLXqru4kmGuyIe/2zISFpDMHeOC6sAKu8x9 GIq+lCmDtcnqIOsDfQ1xLtkOYoEYb588yvobvhlirsPl8Lq/d3wfNzpdUGRTzEVkXK SYRBDMbQ5oAv/iVUR5vRLlCh3zrlmplxU+ft9KWUK0WtinVQ/bfTIbyynZBpilawtQ aKpF7nRLUzfpOyHd9MXLbuxRvd8348H2MFf+NkAxcdPeRSfpdk20M67h69K9udISxT kMOYdgUK4GEGQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 13/26] nfs/localio: avoid pointless cred reference count bumps Date: Sun, 24 Nov 2024 14:43:59 +0100 Message-ID: <20241124-work-cred-v1-13-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1486; i=brauner@kernel.org; h=from:subject:message-id; bh=QzKXOaGTqarytwObmAB0KM5UViuc2HdStxVkwRWPnLw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685lUryd1ttdt4Xv/NHztdu2HDnP4DDzn9LyN6u+R JQmWN3s6ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI/o8M/ytfhm+3FlSZmKQz MUd95aqGE0vK/zFe+Pi5TuvxQTP7+sMM/3OVUoLnxKr9s45azGHnaBzXJZIXX3ZENDbqDtfqC0G 3uQE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/nfs/localio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/nfs/localio.c b/fs/nfs/localio.c index cb0ba4a810324cc9a4913767ce5a9b4f52c416ac..8f0ce82a677e1589092a30240d6e60a289d64a58 100644 --- a/fs/nfs/localio.c +++ b/fs/nfs/localio.c @@ -371,7 +371,7 @@ static void nfs_local_call_read(struct work_struct *work) struct iov_iter iter; ssize_t status; - save_cred = override_creds(get_new_cred(filp->f_cred)); + save_cred = override_creds(filp->f_cred); nfs_local_iter_init(&iter, iocb, READ); @@ -381,7 +381,7 @@ static void nfs_local_call_read(struct work_struct *work) nfs_local_read_done(iocb, status); nfs_local_pgio_release(iocb); - put_cred(revert_creds(save_cred)); + revert_creds(save_cred); } static int @@ -541,7 +541,7 @@ static void nfs_local_call_write(struct work_struct *work) ssize_t status; current->flags |= PF_LOCAL_THROTTLE | PF_MEMALLOC_NOIO; - save_cred = override_creds(get_new_cred(filp->f_cred)); + save_cred = override_creds(filp->f_cred); nfs_local_iter_init(&iter, iocb, WRITE); @@ -554,7 +554,7 @@ static void nfs_local_call_write(struct work_struct *work) nfs_local_vfs_getattr(iocb); nfs_local_pgio_release(iocb); - put_cred(revert_creds(save_cred)); + revert_creds(save_cred); current->flags = old_flags; } From patchwork Sun Nov 24 13:44:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884126 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51E4020ADEA; Sun, 24 Nov 2024 13:44:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455885; cv=none; b=I1ThPzTGL0jlKjDlrk4TDsLqhSotc2cRxD1rm0/fyIGZbhbXsY16FeAmUytfRLMPeQ48ki09KQeFMvqC9v7Gkce3XmFfDyWdEGBnub/f7e+u4YAVmNyvGmIJa+gX2T4HASutxRHEV20OxKGlYLymziScVZf9hAdgNG19RG/6eoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455885; c=relaxed/simple; bh=jZb6EkV6JzPYeldarSe+SomjASuUO2RJ9OILfv+gDsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EWpp344so9Wnxd5SN8sdI3xgslz3sn+Jf9uuM8rb6FfRBcfUSMxhoq0VyTwcYuOmW+lsd7HfC4W47Z+P9SBucNqpZ48WVUWyU/UqTLoMmt83nJCbswygEVffHUL3izdGyNEXTr6V5zoDjJM8axPlIWhLPhMVbFY/GFO+I42lhVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLHf9Ae8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PLHf9Ae8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 724F8C4CED7; Sun, 24 Nov 2024 13:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455885; bh=jZb6EkV6JzPYeldarSe+SomjASuUO2RJ9OILfv+gDsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLHf9Ae8ir64GAIiy6SV/w3+6Bg7JVc69rU4bX7pjYc6c0Oby3miLFkgvR+81mgNj XDyi453KUksGztHc+DzYy+6vtp3cwLa3nxTpaL8UaK7BSYGu0XoeOC0uK4PozqYtDo 8SmP3eazdAd7ETB+grOqqSt5trpJS3xMVH00gjGJC28d/lcy+xHsCz6oATvqDTwquQ LS3gCbgNGY+rs4FD9EyB+VGauNgs2Ve9z4roG0XB9jiDXR/hu3uU+SHOw2ntaeopTP lGE4/KZAASJaIEezGDHLgI1RlhKCqw0QXBS3Zaxq7XYaPxbxAnaFgXsVAgOnHl0DfX P+sGKQQsrq0Jg== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 14/26] nfs/nfs4idmap: avoid pointless reference count bump Date: Sun, 24 Nov 2024 14:44:00 +0100 Message-ID: <20241124-work-cred-v1-14-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=853; i=brauner@kernel.org; h=from:subject:message-id; bh=jZb6EkV6JzPYeldarSe+SomjASuUO2RJ9OILfv+gDsc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685rrFGTe/F3pU7M4eUbM34X1DoJTrLZvXRC7krlB YHvHqr1dJSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAExknTIjw2kZr4ebb8hP2M1V 75hzVeTfhpzC+0tW+eVfVMhaXLWU7SUjwzLB9ufT/r7ZlsG8M5C32Gxr674svwmslZZvt3A/rNl 6mgUA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/nfs/nfs4idmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c index 25b6a8920a6545d43f437f2f0330ccc35380ccc3..25a7c771cfd89f3e6d494f26a78212d3d619c135 100644 --- a/fs/nfs/nfs4idmap.c +++ b/fs/nfs/nfs4idmap.c @@ -311,9 +311,9 @@ static ssize_t nfs_idmap_get_key(const char *name, size_t namelen, const struct user_key_payload *payload; ssize_t ret; - saved_cred = override_creds(get_new_cred(id_resolver_cache)); + saved_cred = override_creds(id_resolver_cache); rkey = nfs_idmap_request_key(name, namelen, type, idmap); - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey); From patchwork Sun Nov 24 13:44:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884127 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E66420B201; Sun, 24 Nov 2024 13:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455887; cv=none; b=k9RBYK002pIN+3dsNkrMtYS8ZHgnO3+5/Oy311LriguRDK+SUMlSH6ji12ElPWYGMLmXmQSHXvNozTnC9Jm0dk5VYsVTntd5FZDPJirq6lbDZffGJOKplw5zWZ0qj8nc683JTnIVg1mbWdGe5IeBsHdf89VgejgywC3CAQX4qZo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455887; c=relaxed/simple; bh=lB66TPcFOcydsf/s9WmTXYzL0+fjEt3pLA7eh38aVwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=gylhprgWm/o7hwAlLlqsI13QvsYiWeaDRVMjJ+mOr8ri2OskaZn4CWmji07RsYKd13u8o3cqBvD7Vx1D4/a86swK238XFW4aT9C+sXoLVJFODBx+4u7OksQNJ1KXa7RM+lN/E6xBIMh5OXMN8QbZ79LHfTe+qjnYgggq7k2Hv1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dHW14Kci; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dHW14Kci" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DC17C4CED9; Sun, 24 Nov 2024 13:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455887; bh=lB66TPcFOcydsf/s9WmTXYzL0+fjEt3pLA7eh38aVwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dHW14KciLv/z7pM2IMFSaT0uLfQVVVS9jFRay4AEmMECA+sLMT0xyM4bS8fildSHK scNUdhpvvx5qAwoc1Cgc/X3woxG14kX0LyQ83PC65NRZTmuvSa/m/2jPG/TgttljRY uHC/dMjCznhWqjmQ+hw5zaYu4PeWXCZe0TtPPZrH9mmR3vHqzX+deVGp/McqNh0YgS jiW2U70IV5nOmzDGlll1sLL+Kme/mkubqbjyU2lv+y6y8rjMWsQ24G07DwPD0ROfiT 9/YFBZ1jCEIEtjVl8nMDPUIvRxsSceDtKB0XvmTss06GU6F+vqOl51ZhJZSdWS/ecb d/6V7vFQQVXEA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 15/26] nfs/nfs4recover: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:01 +0100 Message-ID: <20241124-work-cred-v1-15-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=696; i=brauner@kernel.org; h=from:subject:message-id; bh=lB66TPcFOcydsf/s9WmTXYzL0+fjEt3pLA7eh38aVwY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7684rbXSM3X+/88rlEpaM9znaGZIdCZZbOT5c+m2nK x3w8+vajlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIn48TIyrDh0nc1fZcG1XW0R dz4oeh4oe1JXpXZWoaFL1zhU3dwmkJHhi/P1X2vdHiafWv5oLaPXimvOG0uLLfT+dKzkMFoWL7i EEQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/nfsd/nfs4recover.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 2834091cc988b1403aa2908f69e336f2fe4e0922..5b1d36b26f93450bb14d1d922feeeb6c35399fd5 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -81,8 +81,7 @@ nfs4_save_creds(const struct cred **original_creds) new->fsuid = GLOBAL_ROOT_UID; new->fsgid = GLOBAL_ROOT_GID; - *original_creds = override_creds(get_new_cred(new)); - put_cred(new); + *original_creds = override_creds(new); return 0; } From patchwork Sun Nov 24 13:44:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884128 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E2A320B80D; Sun, 24 Nov 2024 13:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455889; cv=none; b=Gaq0aXTxoKf/OOXmGPeh2raQZgiufK40Q8cILRrpYgwdQODi+T07s1xlNbR9GlrN1uXFGECL1ljgbKtK+UO9mX0tiE9KVWdxO8HjsX0LSvP9rquLPRiREOqLO69AKBeuZgbGZgP3C4k0ucioGqBkafEiopxW2qm1YtmeO3XlQ6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455889; c=relaxed/simple; bh=cGAtL0IdSL5OIXyZPY4NHjrBposxrRNGFqPn12ctCts=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Nr5vRb94h5RdpCIDtEoglhx1dOFNnImxJqYDKYCO28/FeJ2TabavKLgqOChWjLMvShzbp5xs8Z4TrkIUzFucIgBoSMDTiFwF/9l8sIp96PcCw+sGJ4IM5a1XRLX/67ZmUQO6IAQfRH/9b8A2h7JHtN+t8/QYyGwUBmD4LapRx8w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hVdTktDF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hVdTktDF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A46C4CECC; Sun, 24 Nov 2024 13:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455889; bh=cGAtL0IdSL5OIXyZPY4NHjrBposxrRNGFqPn12ctCts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVdTktDF9OqnxXZHPQYIyy17fiN3Ey2QZVHkTtBZWX8bOjiVkjJEdPOuE0VUrdQAJ bvaiGs0dVP6PI9ONX9+Y1NbRT3gSPLPd2G3U2n2UJUx55QNSh16TeFZUN5P2OnGwHQ dtWA4PpzxtINxuSpwHzbDYdg+TqF0KnYwYTVW5qk3qYNhpBuxOXSrDfmzVZMe0/CDd dpsoJOul4Ozs2aQG03Prc8Qo1mjXxHKo5SEXFKg4VixgZiHODJm7t+zwU0So+Dl1fe 9kKDKqrU8BXsa037EH45jJKt+iA4N3MLiiixHoetXooSZxcdB0XiDjKZgucemcA+S8 Vz8rso9SHXZLw== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 16/26] nfsfh: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:02 +0100 Message-ID: <20241124-work-cred-v1-16-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=774; i=brauner@kernel.org; h=from:subject:message-id; bh=cGAtL0IdSL5OIXyZPY4NHjrBposxrRNGFqPn12ctCts=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7687TVVTdMmcbg8luu3aZotjva9559jxiXDltdWzaA T71z/rbOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACayaz/Dbxbd0jctr3fz2Xgt kXPwEM9ssyvisPe6mLyFIdw86dlkFkaGL28WKUp4LVvSX1A/vVJoY89LrSwhcZEYpwPJNxZdvLG KFwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/nfsd/nfsfh.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 60b0275d5529d49ac87e8b89e4eb650ecd624f71..ef925d96078397a5bc0d0842dbafa44a5a49f358 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -221,8 +221,7 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net, new->cap_effective = cap_raise_nfsd_set(new->cap_effective, new->cap_permitted); - put_cred(override_creds(get_new_cred(new))); - put_cred(new); + put_cred(override_creds(new)); } else { error = nfsd_setuser_and_check_port(rqstp, cred, exp); if (error) From patchwork Sun Nov 24 13:44:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884129 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF22620C017; Sun, 24 Nov 2024 13:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455891; cv=none; b=K7r3kQ+HFK35fwPTk8D82Oa1ln3At7lON7BArjiMUOmaZIN5u9XfyjfBw6TixikyGA6UOYaDNH9BupoGB7xv2N9N+v/6KHU/MhGcH+5B/v5unkp+DqDDhmAhdkU8NaY3TYL/6PUnPTV8sQ1P0y2ABAJzEI2nJ6r78DF05zocXMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455891; c=relaxed/simple; bh=nXqY7H+FrDdF1GL8dP3Sq3a9av6/N4Dvi59BVLXNltw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=A4+3FO/6ac2bUwMm7w1bIznJBEkSITj3fSdYN5Ig4H4a1mXKQOOwqK9a1eQCTb2K3/RycLGER/n5cXcr+JWuyHt4bKkeagTSBWPZ+NVOFhucvcJgTwm2Hlz5gvaU9TqWHm/bzwkY/9dxwV0O5Im4BTbh11EhqQR2DiJwjA0Em50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YipDC/g/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YipDC/g/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4D9BC4CED7; Sun, 24 Nov 2024 13:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455891; bh=nXqY7H+FrDdF1GL8dP3Sq3a9av6/N4Dvi59BVLXNltw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YipDC/g/bm/CiuXf0ojbRX3epnqq99kdT/SPd/EhKM6b2KSne8Cv8Lt0ohfQoKEDp EMIr4fSKOnkwcEwv2olG03rChXkkPhsABRM2D0b/sSbQT7OxzsE4zAju4hHvX/1sgZ t55dKS2M1zPaNs0gq1hyCN8u0173pBnPkmtGR8G/x05+rMQc2+8nyRHJu3niWvqYHO LpmzVeAAjq4aQSMUPZfEMBM9D047hNIs4Cgdwuk73+S0l+t4IsFnNkdnoor2oiuiJz qrgpsqcxXwGcD3MG13JmxKOOLrSbYM6ziWiZ+nByPmipybca1MrhFYR3vPwbfZTxIu kXuNz700N2hTQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 17/26] open: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:03 +0100 Message-ID: <20241124-work-cred-v1-17-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=786; i=brauner@kernel.org; h=from:subject:message-id; bh=nXqY7H+FrDdF1GL8dP3Sq3a9av6/N4Dvi59BVLXNltw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685/e8y+4PX2VynyE/dwpxwMet3cuO5A1yLZL8mP/ 3RqsCl7d5SyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzEcg4jw8P31SdkKn44TosX 53Zi5Wbd8nQqY0D5LQNdiUmuunuT0hgZZv9cfShip8bVs9ctrzfZr7F3ftuir7xQ3Uxj1+2rs0Q sGQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/open.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/open.c b/fs/open.c index 0a5cd8e74fb9bb4cc484d84096c6123b21acbf16..74ee5e02d68c590475f18f099b188f052f17f555 100644 --- a/fs/open.c +++ b/fs/open.c @@ -447,13 +447,7 @@ static const struct cred *access_override_creds(void) * freeing. */ override_cred->non_rcu = 1; - - old_cred = override_creds(get_new_cred(override_cred)); - - /* override_cred() gets its own ref */ - put_cred(override_cred); - - return old_cred; + return override_creds(override_cred); } static long do_faccessat(int dfd, const char __user *filename, int mode, int flags) From patchwork Sun Nov 24 13:44:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884130 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9346520C037; Sun, 24 Nov 2024 13:44:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455893; cv=none; b=JsSf4a3gPiIn8ASgKV5KyV5Q9UK7XTNZxWr5obw3YNNrn+WoY0mVvpaQKqLnq9kwCGbMvpTMOl0iKGt1/YZdZYbBMX4R6H6MXinsAB+Jwagkt2vH66VgTNvET18D1JEMXz1I49kvtrTLSa2R8z7Z1FHevhdFdSGIAl/21JrsSak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455893; c=relaxed/simple; bh=s1Ei5CtoYtfc2mSSk/8oqFVlzTKUdNU5RjswLDXHRtM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=No7nxydZ8mMtvxhMQFMRy7OQUV7eQ/z/zypzm/oxn4/Ql9uBeGHAaVcZiBK3P1nzpPn1JdMw6UHP4JVMTEeVMkmWPvLrGJNZMdK3EoVv4XQRoAtgqlLIFI9+W+iag/jjlQCECd5prbl9day/2/oKJkpoCUiSR1IDqFLMa1s0WII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pkHhzrKU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pkHhzrKU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3B40C4CED1; Sun, 24 Nov 2024 13:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455893; bh=s1Ei5CtoYtfc2mSSk/8oqFVlzTKUdNU5RjswLDXHRtM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pkHhzrKUWYq14MedTZ0n7UJz4nVWhzqwnZQklrhRA786NEaDv9eI+ykKGfzaH7cN7 Wc2cZ5VaU1R64rLuuRwRngYHTHIYJr43k7C8/IjqwyEh+0Ncs+KCqmmebHfpZzXPkk KazyV4gBAAQQau9tCx9TW/5iwdOU+Fa6tZa5e/hovenvKL8gqtjolrFsjIBXtiSfar GOmvMD4TnU3qlYD07KWiZX3prhiyugzQR88pAsBVdr/y/eXgRdRQX40vzowY/UdRxy tn1slnidBKZwce5WQM1WcYWud9zeYG02oYTzVypUkPirLcOHFeFEaS5vURKSTaRhUM TES1MEz4a0g2A== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 18/26] ovl: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:04 +0100 Message-ID: <20241124-work-cred-v1-18-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=853; i=brauner@kernel.org; h=from:subject:message-id; bh=s1Ei5CtoYtfc2mSSk/8oqFVlzTKUdNU5RjswLDXHRtM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ7685/t6Z98vydF9Zdn6lyMWNK+Iwbx390VORkB22r7 Jd5Oi+6v6OUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAiC1kZ/hl6Rfc2GK3dV/F8 +YVna/5cMrn30tVVifXyCgczOa3T79Yw/LOxC9lzp007ZNnvvX6yUsxf0rZ2nWyN73niF/p/9jo JXk4A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/overlayfs/copy_up.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 439bd9a5ceecc4d2f4dc5dfda7cea14c3d9411ba..39f08531abc7e99c32e709a46988939f072a9abe 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -741,17 +741,15 @@ static int ovl_prep_cu_creds(struct dentry *dentry, struct ovl_cu_creds *cc) return err; if (cc->new) - cc->old = override_creds(get_new_cred(cc->new)); + cc->old = override_creds(cc->new); return 0; } static void ovl_revert_cu_creds(struct ovl_cu_creds *cc) { - if (cc->new) { + if (cc->new) put_cred(revert_creds(cc->old)); - put_cred(cc->new); - } } /* From patchwork Sun Nov 24 13:44:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884131 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95C0720C482; Sun, 24 Nov 2024 13:44:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455895; cv=none; b=IqM2oIdDHxVUoRZaAxdu6AaG99ALRJIUcsOD4t4X8D10gujF2aXoQEfV4tOmFA/qomts53i+7nCbGc2mw5eLK/2S4/9CAAG6F1uQMUvR9WyuHCAz/gfHsh/iJTWohrO8graeUnjWPKQ6TygB1zTqXh/oPszSbbjZreVc6kyFYS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455895; c=relaxed/simple; bh=q23Mrxa8m3O45VqVv+7XtSnKSkr//0A5jKfdwR6XXQI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=AM7sbbDEODualNP9WlzUqtxjIJeINTiu6NDtRtyH/IArGCGI2tw30Mt9syFK/AVvkcSPddoi5Lj2UQoMN794p5Wl4rt8Yj9KjW6h0j7ThMw42ONZeU/UDFMH8+dNIfPgqEBj+eux0qGPNBKV1xgLPxSWLMTgB/qCGirpC0b8XO4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pggTkNIg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pggTkNIg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE8CBC4CED1; Sun, 24 Nov 2024 13:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455895; bh=q23Mrxa8m3O45VqVv+7XtSnKSkr//0A5jKfdwR6XXQI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pggTkNIgRmmG2siJUXe+qD0PphLSMN/h7alejbf7XSCY5OV0qpQRbRogEDlTiUpc5 BfXb/6BD1LNX5zGy1bCjeuwP43azKn1dXxIXD1M74OjbGMfufzO95ercXVRApd9oJR YFcDOJtb7IAaZrj5lM0KVtOEXV/BLibIeJKRY6P+LPqC6C6LEWZbg6C9GvktdHluIN /wIf7w3ejo0ECamFFAahVAWIIDATPxMo+ros16sB8EWSWpd6VzPKh01Fsgfw/kJfgt f/jq+4x0BjZylyWFwjVsJ6WMjgGfDkHuOe+jRMeYvDsXcOyXcRCtO+uqyMtdJQ9gGw zd31N8itcvlgg== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 19/26] cifs: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:05 +0100 Message-ID: <20241124-work-cred-v1-19-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=897; i=brauner@kernel.org; h=from:subject:message-id; bh=q23Mrxa8m3O45VqVv+7XtSnKSkr//0A5jKfdwR6XXQI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y7wNW3L546rf3Dja/ZMZ/W4RI5T7NLCGn1GzwX3/ DJ+f0+no5SFQYyLQVZMkcWh3SRcbjlPxWajTA2YOaxMIEMYuDgFYCJ2mxgZjn4znVFt+fCa4uVv y3c+qeSe6PxYW/iXWYsWX+6++kXnJzIybFR6lXu0Ju75Y6s97efVj01U2S/K3FTdKNG80IlvSes dBgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/smb/client/cifs_spnego.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/cifs_spnego.c b/fs/smb/client/cifs_spnego.c index 6284d924fdb1e25e07af7e10b6286df97c0942dd..28f568b5fc2771b7a11d0e83d0ac1cb9baf20636 100644 --- a/fs/smb/client/cifs_spnego.c +++ b/fs/smb/client/cifs_spnego.c @@ -173,9 +173,9 @@ cifs_get_spnego_key(struct cifs_ses *sesInfo, } cifs_dbg(FYI, "key description = %s\n", description); - saved_cred = override_creds(get_new_cred(spnego_cred)); + saved_cred = override_creds(spnego_cred); spnego_key = request_key(&cifs_spnego_key_type, description, ""); - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); #ifdef CONFIG_CIFS_DEBUG2 if (cifsFYI && !IS_ERR(spnego_key)) { From patchwork Sun Nov 24 13:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884132 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDCEF20CCD3; Sun, 24 Nov 2024 13:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455898; cv=none; b=NeaUNTr6DLav9TSfZWhsDvE+nyUoU4v88KHWCYahSJTgk24PckCeB6Z0EpTUmdIw3YphnGVujC+ioAQ9Y9jKZuIvyIqQ2aD6pMLYNPkFIfSfD1M4jYJ7hlJoErRy8pyJBkDS4fn8cxb1G4Lzwitxw4R6r2m92+MRg4YuUvPqC+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455898; c=relaxed/simple; bh=5+SMh6j/iqEcYwZZXZLq5UqmpwtfuZKJ9FPoeFDoAT0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TQEkr62074sQ7i7Fr8Wku4RDYqVB4jz89GoRdvCTWFHc/O2EGRae8rlXoHyVNzR6E8Ebk27RImf2P5ePXKLIapLtYSsABtOv6x13tbxD2LnEqJc3Ac57yzt5sy/ujBzbsT93FQU3xQWypnCoLXp7OjPB3h+AMRKpKUHFDNmznLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t7n8WfcE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t7n8WfcE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA5D7C4CED3; Sun, 24 Nov 2024 13:44:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455897; bh=5+SMh6j/iqEcYwZZXZLq5UqmpwtfuZKJ9FPoeFDoAT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t7n8WfcEVsSUbyrlwM4NYZORIuUjkGwc0ZnYmIUiHWsnziAYlo35J0eVcWMgK+Fss 0qEenrhkbZSFxK9czauGfdsd9z47MPtHkOk3EMfhZtpA/9Xi2vpUbErNNU7PQgm2e8 Q16ddLemVGUXfNDpoilvm3CLho05RsAd1eofyLZKw7KmxNaecliqwn4QvcXydErGMc aobq9qKT1FfMz4hecUWIKN+dmNT0ruH1DWyRBjUg8wyu02IWboh3TLOJrsGQFgA/jR /+QgKW5vixym3F59JCsC3PUjssYmE3MNqUzMHyJonoEi/K7ZHLXFzBkPTbWy2Px3tG 9zH+uVfJ5N7KQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 20/26] cifs: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:06 +0100 Message-ID: <20241124-work-cred-v1-20-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1591; i=brauner@kernel.org; h=from:subject:message-id; bh=5+SMh6j/iqEcYwZZXZLq5UqmpwtfuZKJ9FPoeFDoAT0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y44+7Dkj6a9QKSFSqt049LYzaIixzmKNktc70pRm LF6F0NQRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwEQEUhkZFtddZVgjaN3CpqHY 9mix8cbLzvlTFlrLzFE0qV50y1yzmeF/9MT9TgsSs4/0qZ9f9CSary+v2fhk1OMLIcx8B2PvWr7 kAQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/smb/client/cifsacl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c index 5718906369a96fc80bee6a472f93bac1159f1709..ba79aa2107cc9f5b5fa628e9b9998d04e78c8bc1 100644 --- a/fs/smb/client/cifsacl.c +++ b/fs/smb/client/cifsacl.c @@ -292,7 +292,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) return -EINVAL; rc = 0; - saved_cred = override_creds(get_new_cred(root_cred)); + saved_cred = override_creds(root_cred); sidkey = request_key(&cifs_idmap_key_type, desc, ""); if (IS_ERR(sidkey)) { rc = -EINVAL; @@ -327,7 +327,7 @@ id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid) out_key_put: key_put(sidkey); out_revert_creds: - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); return rc; invalidate_key: @@ -398,7 +398,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, if (!sidstr) return -ENOMEM; - saved_cred = override_creds(get_new_cred(root_cred)); + saved_cred = override_creds(root_cred); sidkey = request_key(&cifs_idmap_key_type, sidstr, ""); if (IS_ERR(sidkey)) { cifs_dbg(FYI, "%s: Can't map SID %s to a %cid\n", @@ -438,7 +438,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, out_key_put: key_put(sidkey); out_revert_creds: - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); kfree(sidstr); /* From patchwork Sun Nov 24 13:44:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884133 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C7D1920D4E8; Sun, 24 Nov 2024 13:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455899; cv=none; b=ns3qkF9OAdMPgoOX9Lwx9TnMF840sL+8Cag0DI8GjXflT5h2/UNE90a5z4z3ZZNt9ALagG2TbOLcfHvnLc1XSYJJfqQ0tdr8wp1PWPcEX0f2qLLpINopOlmt1BeMk1b0PfAj8fmElsxo3k3v+WMuBmD2TPfXjN4MMK559Qq311E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455899; c=relaxed/simple; bh=7+BonKFNZvP5fMRV20M9AzuaXHt6M1zBtDLiQy7THD4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Z+314C0aaVYfMMlfsoSUNL1UpuU6L9HMVhjVAXrHulet6ujOqq+xW5tWpdiCbNB5QdiK6i7mmhxwv2mmCVJxTeFdh1NMwej5dN62OYclebCwoJ5f3RQCD86T453734ReqjYXee63jnufkWnAgc3yYsoyoKCcz/kDjCYQyBBWWLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PiwsEVwl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PiwsEVwl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17DBDC4CED7; Sun, 24 Nov 2024 13:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455899; bh=7+BonKFNZvP5fMRV20M9AzuaXHt6M1zBtDLiQy7THD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PiwsEVwlXO8IWaBuPVVj9VVJOHRq878Y25IGeV+HF5r4OlqZfQwIlv/55lEsl/c2R C+XcgL5j0X5657+IjRObCYfYy7fAK0LpO00wwbg3xHXVJztV2TIhKT1L7PSk28fnxM w0NhkA7HA083N7ZeSsk+/i8u3k50lECzDb+HcahHCl8w+TE9ZJh8Rn3XkGT1QDS0kA dPpDCP8QOjlohO5Npxu8gR5ekVmGtvaxIrzsrbc52wHjvVJI8b11jDeSHsjaWhDHqx Cmt4hGcIuMNmmU4Nj3wFKQk4IfettGXYoxtzrKrsSSDvbdiM/6fx0k3OiuWxiGekHh zvxA4TGEWjFLw== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 21/26] smb: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:07 +0100 Message-ID: <20241124-work-cred-v1-21-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1021; i=brauner@kernel.org; h=from:subject:message-id; bh=7+BonKFNZvP5fMRV20M9AzuaXHt6M1zBtDLiQy7THD4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y7U9P7zZElXvKkin52Iy9w2/+9ZZubeRvc4zwjMe OrPsfdMRykLgxgXg6yYIotDu0m43HKeis1GmRowc1iZQIYwcHEKwETeTmRkaNrkxjw1cU4uc8jC m7k8gp8KLArX3l546XJV/fuEgBbhCIb/USuF90pnNxWe9LOqv8dze0U4l/DTnCsf/boU5aI8Q77 zAwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- fs/smb/server/smb_common.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c index f1d770a214c8b2c7d7dd4083ef57c7130bbce52c..a3f96804f84f03c22376769dffdf60cd66f5e3d2 100644 --- a/fs/smb/server/smb_common.c +++ b/fs/smb/server/smb_common.c @@ -780,7 +780,7 @@ int __ksmbd_override_fsids(struct ksmbd_work *work, cred->cap_effective = cap_drop_fs_set(cred->cap_effective); WARN_ON(work->saved_cred); - work->saved_cred = override_creds(get_new_cred(cred)); + work->saved_cred = override_creds(cred); if (!work->saved_cred) { abort_creds(cred); return -EINVAL; @@ -799,9 +799,7 @@ void ksmbd_revert_fsids(struct ksmbd_work *work) WARN_ON(!work->saved_cred); - cred = current_cred(); put_cred(revert_creds(work->saved_cred)); - put_cred(cred); work->saved_cred = NULL; } From patchwork Sun Nov 24 13:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884134 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27CC520DD5B; Sun, 24 Nov 2024 13:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455902; cv=none; b=Tg4HmqaPF/BNURHSz9opeZPbFR30SJg7dvFsN0Ic93ihn3f+R6sO9y3peOUpuZ+BhElsAbyhPZdpfIZfPw1xRHNAD8SWlXj0wlnA0RSz3RGGxPNgV2ZwpALjEEI9TjTJA/3UIwqSJslYabNItKjK9vBcD4f/DfHcMj971hFAd3U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455902; c=relaxed/simple; bh=zrNjxsAjCHPuNaCLSpJvKnvN3m8hTYHZar8IMmrrZ2o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GyriOHyR5frz6PUvfAGB0r0XEeKGevVl47K8kLAzXB6WJMMOELlZZjnIxi0A0kRuH33TCWPbovU4QmnWm9uA3WH6aEhYVDryM2fTVdxbML3bXi0FiR+siS2sO1YWIYl92qG1pOPXIT3YfZ5uFv7Z3NxzSIWE0G7ubXu5jtMy20o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fS2JeZSH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fS2JeZSH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26EA7C4CED1; Sun, 24 Nov 2024 13:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455901; bh=zrNjxsAjCHPuNaCLSpJvKnvN3m8hTYHZar8IMmrrZ2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fS2JeZSHY1mgMlhvxOAZvcwdSZlhVxyVXXQBH48ROlGFbdKVTKnER3kTqjuIoQwMp yCyVt9JCKUFoQcOVAsIlM9gkvGZ14bBerCjWH1Iwswu5WluB5aw3dE+cMdxoJnprTI c8R9M9CT5QPAW3Gm0qfmth18wcrbC93bve4wo6r6Z/spG6xlNB9K4tr179wdRhwIB/ e0RyQj5cX2xc8rYyrrfMZ+RaWtsBgGmiU5yropv4+2+v8VSkxneKp++dkKc55Qi6aM Z8dlalq83fDsQNoc3lRfJSF4VzCSZYRZWcgTAeGkdEnNmeLhISz4ZQ3dMK2JRA+QVT VAdoxtZ5Ly6gA== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 22/26] io_uring: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:08 +0100 Message-ID: <20241124-work-cred-v1-22-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1908; i=brauner@kernel.org; h=from:subject:message-id; bh=zrNjxsAjCHPuNaCLSpJvKnvN3m8hTYHZar8IMmrrZ2o=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y5cJX/+QvW8vq7f3e8T1L787PCUtTpjevvw69mRK XILG9/d6yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhITRgjw2Wzm9OZrFK737K3 2TlOiArnPnm06foRXpu/8hsOeoYrfmH4p8q1bk83i8SBBa9WXr374PNGUdYkz0dP2J10DatX/+X rZwIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- 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; From patchwork Sun Nov 24 13:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884135 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 319BB20E01C; Sun, 24 Nov 2024 13:45:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455904; cv=none; b=Wd48R3mOJQ7Ph8d662/58/TcRaEQ3kDQb9X60lt5zWsxHK2fMnT9hhM63tN9TitKMYRYND0Jtnh6C5fF7JI7tiE1PngNL4PD6IwTqH4lOpJCgqiLEk+rBngcXi4hwdimvplVjeqQr/N5lSVMYrgSjeQvBViqefTUfWio+BppABY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455904; c=relaxed/simple; bh=vWgSEUDddBjtaq3jwhrWDE1y09L23Hj1M4WCy2387LM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MaNwjMFx+temJPhY2vjXCUh7djWg7Zma/WCeJ9bxpeUXoEw0wZgiVE4qAx8/r851ersFQ377NHVmU1sQOe9t5BQyHa1JNQQbu7Da9Q1hu80qqzJJw6Cx1MHGRdyYquYbHkbM65N1K0nUj7zgW7OmsH2JZgnbk2v5tY6xGlO7pyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jhsPSwNR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jhsPSwNR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32D34C4CED6; Sun, 24 Nov 2024 13:45:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455903; bh=vWgSEUDddBjtaq3jwhrWDE1y09L23Hj1M4WCy2387LM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhsPSwNRHi8+Vperw9tTAM/dDLrwyqlBL0HfmF9JefXguZ4M+7/8O97jaMtwqhY51 xmgDoUE+HochG1lF8mIdoxTHJ3HGhs/36uhzID13QFg8K/yx9zZ5Xyk7VehMIAQyns z5/GHufgJdd//pUM2JmCV/T/tOhbvuIKsYC2jDg3K6Glhc2grcbFi5+CJA541C7SqY G8S7AvQWT6Wbxq/0dbDEtPQvAr1o2jENC/gZCODpDJsXCCJaxfUWfFu+qxOT0/P5cC aG3gJ/xfKNGFwCU/1oaLsVz3sa3cgrzCUp1xdeYCdl11Cp2YQBTGJryjy4FKTICl3J 1aILNjTAtQIhQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 23/26] acct: avoid pointless reference count bump Date: Sun, 24 Nov 2024 14:44:09 +0100 Message-ID: <20241124-work-cred-v1-23-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1037; i=brauner@kernel.org; h=from:subject:message-id; bh=vWgSEUDddBjtaq3jwhrWDE1y09L23Hj1M4WCy2387LM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y5advda3e820UdcTW/Ox2Yef9zUdHPOHOtD688s6 j67r2tiV0cpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBEarQY/unLhBbPeRrHuSpP 7dff1ZN+b9R96qx7aMLZ0/Y2Hztd60oZGZ7t3/6iW3jTk+NmSks+m/+M73Jd8O28wDzmoujEsyI cc3gA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- kernel/acct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/acct.c b/kernel/acct.c index ea8c94887b5853b10e7a7e632f7b0bc4d52ab10b..179848ad33e978a557ce695a0d6020aa169177c6 100644 --- a/kernel/acct.c +++ b/kernel/acct.c @@ -501,7 +501,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) flim = rlimit(RLIMIT_FSIZE); current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; /* Perform file operations on behalf of whoever enabled accounting */ - orig_cred = override_creds(get_new_cred(file->f_cred)); + orig_cred = override_creds(file->f_cred); /* * First check to see if there is enough free_space to continue @@ -541,7 +541,7 @@ static void do_acct_process(struct bsd_acct_struct *acct) } out: current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; - put_cred(revert_creds(orig_cred)); + revert_creds(orig_cred); } /** From patchwork Sun Nov 24 13:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884136 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2738920D514; Sun, 24 Nov 2024 13:45:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455906; cv=none; b=NHopUElRCp9kjNlvbbN4aHH+oXxzqIyisvIwN6EpBfpbUuJMsUXNy8TEKPFM7iv5iKVClZ/YsK8wx45UJdU5kAMPMjEgq0x/S3JDfI9S5+5ult1WFewuZZ8zhHsgEs8Qs+OD/7u83iKMb+rIbk36oWu4H4UkXrTrEX+5Tbp518g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455906; c=relaxed/simple; bh=wcnUSwtChL+VJdcCKPWSyAxsaM/o7Qx5RaqxsWjwVKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sq/UF5FCWkfXU8TeX8911D2YGvwe+msFdxilGUysLE9f6L0inoXsFbFx9wAou7CLidLdOBUuAIXAzngzWcmToupr6Rb8QDHgixtfxC5DCyOjFjohPwU5VROzUVRjrYe0v3cXN9WMUtyIwZ/dps0C41vxZNBh+Wae03iQBkjXnak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bm6QdHNo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bm6QdHNo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FCB1C4CED1; Sun, 24 Nov 2024 13:45:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455905; bh=wcnUSwtChL+VJdcCKPWSyAxsaM/o7Qx5RaqxsWjwVKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bm6QdHNoI4FGfmvNhn7WOM2k7vrZ0svCm+G+lPxSsLj4MlWSCaNZYSit4mL0mPriQ 4/2QVRzJxGjpML2qPcUx7c18zBAWd0V+uWEV2whaVIjWmk6tRqhH7UOMUbynRzIbqI lIqzge8/YjwoWxo3IPLSKly0DHTAYfAbB0N/cTh/nHV2cu3MXizwqFl+O7GCTCOA1G uDOMwWZPdL6rWINZiUAfHXbuJrteiHRhNtbq9hmDdYQCj/UjI5csA9CRYnycjjRTFo RodCDZAIHiTpwIa1aw9Ryi/hyI6/oRY6EDRkLoqQZ9hYfQt2u6U25A8HjITqDVA8FZ yiY1sn6coRDkw== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 24/26] cgroup: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:10 +0100 Message-ID: <20241124-work-cred-v1-24-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=978; i=brauner@kernel.org; h=from:subject:message-id; bh=wcnUSwtChL+VJdcCKPWSyAxsaM/o7Qx5RaqxsWjwVKA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y560DbfetrpF/c2OH7pahcpa1H7lNdQJ/3zRti+J k7rZ5oMHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPRsGBkaL3EY/NB0OztZ6EX rRlWvh3f/VdLPXTlXPfhRMWmStvkyYwMDa9O6rkLauVp2QtXLK8QZY2aoLfowdkF89rWPWKxrEx lBQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- kernel/cgroup/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 1a94e8b154beeed45d69056917f3dd9fc6d950fa..d9061bd55436b502e065b477a903ed682d722c2e 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -5216,11 +5216,11 @@ static ssize_t __cgroup_procs_write(struct kernfs_open_file *of, char *buf, * permissions using the credentials from file open to protect against * inherited fd attacks. */ - saved_cred = override_creds(get_new_cred(of->file->f_cred)); + saved_cred = override_creds(of->file->f_cred); ret = cgroup_attach_permissions(src_cgrp, dst_cgrp, of->file->f_path.dentry->d_sb, threadgroup, ctx->ns); - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); if (ret) goto out_finish; From patchwork Sun Nov 24 13:44:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884137 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBB8520FAA9; Sun, 24 Nov 2024 13:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455908; cv=none; b=JZiR1QCGJauHexkxBun2mxRPdAsmpmw7TzMhV/lJYTPVTa0Ci+P88P9eq8R+XYjW/WetrFSY0AggGDEJ7Yab0SEYxM0uffAeUcWgCcpznr0oROXIdPSTyQqeBI0piZWqZPWHjfKGPl4OjcLgoeJHI8LFjVy+jal9LaFrKpPsj1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455908; c=relaxed/simple; bh=C8K04Vp01127KZpkH0Pi2MRdy+GUfirK+wsgK6Ynj00=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qk02lL5dtjlpg33bS6iN+Mxsn1NdPpvUpsHnnUhKIgjpOMIehZDuRIUJFx+thciEdC1fBxAmYIvtTsFKMzZFKPv2iTIZycK6ZA7hE7WG19e28a38MGH2+Y/fn8nEBK68wr5SWO3uvQp2k5Y+lmsO71GCt1qi0SnYpxAcq2MeZDw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mWLv1vUL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mWLv1vUL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 318D7C4CECC; Sun, 24 Nov 2024 13:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455907; bh=C8K04Vp01127KZpkH0Pi2MRdy+GUfirK+wsgK6Ynj00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mWLv1vULgLXAeqWSKpTTGxkWezME6v58q/yB9NBbGKQw+BaFNWJa00R04hJI8hOo4 +8bqXEQJ66iyflKznMpvOFiu7t3BWKmz8rzdBEr8lh4cF7rD3XnCyhqgkkKlwRYWTT /8Xn2HH0C8KE8f5RAmFxUgVKsk1Nt9WiS1TmhAlsUQGJCMLmBX+NOe/sFSZgGX9u0m oDnx1fD6sj0tGsNSqZeys3RUUTSP7jdDUGsTSahaz2VcwuFixixCfpgX+TtO6iO4xj zx4cvk2T9kwnzGRvfiVl8Z4PxF8astMfcXK/UwRzEMkcRQnqbtR0ZWOiU84/TzXkQf 8vZI/EDmyZe4w== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 25/26] trace: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:11 +0100 Message-ID: <20241124-work-cred-v1-25-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1000; i=brauner@kernel.org; h=from:subject:message-id; bh=C8K04Vp01127KZpkH0Pi2MRdy+GUfirK+wsgK6Ynj00=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y5mWP3QvUdMRPtSwzOjfSbWUxf/Ozw5TfHap+sFd yr2xnOe6ChlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE9gQLk4BmMgrVUaGVdxlb2O/LBVfbujk dJ3Bbu5Fntk3E/7ZVb2JZI6seLrSiOE3m1MvwyXO0Iiezu6Gtsn5M3p+n20O25rpdn7J1x9W1tu YAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- kernel/trace/trace_events_user.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_user.c b/kernel/trace/trace_events_user.c index c54ae15f425c2c1dad3f8c776027beca2f00a0a5..1ec83a4f19ac038a8580391c291653ab822ce664 100644 --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -1469,7 +1469,7 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) */ cred->fsuid = GLOBAL_ROOT_UID; - old_cred = override_creds(get_new_cred(cred)); + old_cred = override_creds(cred); if (visible) ret = trace_add_event_call(&user->call); @@ -1477,7 +1477,6 @@ static int user_event_set_call_visible(struct user_event *user, bool visible) ret = trace_remove_event_call(&user->call); put_cred(revert_creds(old_cred)); - put_cred(cred); return ret; } From patchwork Sun Nov 24 13:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13884138 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C29A2101A4; Sun, 24 Nov 2024 13:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455910; cv=none; b=CTPeVtez4iK7nJ3Aiu5bHn1YvvHGXcOROn42J7XH+YW+b+kcDp0PPtufeu80+3Iaz19O6PsBULwG1KEHkixS+YqwILC5MwPYH7rqOsdSQ7N6WqjLf8uiI4f1jBAMZsQfp2PvlshUCQruRgeR2RAcpFR5FFi9kwxjY4xQ+PtCpV4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732455910; c=relaxed/simple; bh=Cxwbe8QlWEJJCmaXE8xmYnN+TJILRMFJ54WvDGDeDgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h60lLVF5dW3VUU1chpeVNfKBugPosygoPTn5jVRLAHx98aH0SKYReov/1xfoQ8Q2KCrtiT/dbgRcG6KxXP0C+M+HPXAnnSeWf1F/ux8rIDsQxMcj4oU3iO6v5qPePl2E3e9GI7mkDttMhgLGbzjmWXS5wkYK55aY1tJlGWOpR6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iKIJhUru; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iKIJhUru" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D452C4CECC; Sun, 24 Nov 2024 13:45:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732455909; bh=Cxwbe8QlWEJJCmaXE8xmYnN+TJILRMFJ54WvDGDeDgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKIJhUruV9FeRFuGmVYkwumvyPUoLtWv3jgJYbB3e+J11oJiJU/NH3j6HndXFyElN gggNjGqrODywtdKxENqvzPTK5SYCKjggqaxDVVLtAK9nn0wcEZc7Lc/87TQt08IZBB SXhSYB9ZSH0WG0HddoUWcSRIqg02DVuVGq/av1EcGCD07GYw7EuGzZJ0XU/JQWIkFA thOBUYbLTACjB4qsh3IrvZmTHJT2rMiMulA9BTSykNKuYZuhfsKYsKgz/AaQFsIITK eFC500+kLaUDZjJzJLmPaczZwnBJLGNnw/h2ArEz6oGtO+65QNgD0GkldqzDwsnoI5 B3BUaYR8qtlOQ== From: Christian Brauner To: Linus Torvalds Cc: Christian Brauner , Amir Goldstein , Miklos Szeredi , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 26/26] dns_resolver: avoid pointless cred reference count bump Date: Sun, 24 Nov 2024 14:44:12 +0100 Message-ID: <20241124-work-cred-v1-26-f352241c3970@kernel.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241124-work-cred-v1-0-f352241c3970@kernel.org> References: <20241124-work-cred-v1-0-f352241c3970@kernel.org> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mailer: b4 0.15-dev-355e8 X-Developer-Signature: v=1; a=openpgp-sha256; l=961; i=brauner@kernel.org; h=from:subject:message-id; bh=Cxwbe8QlWEJJCmaXE8xmYnN+TJILRMFJ54WvDGDeDgs=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaQ76y6uD0w3PaB1pfvlnc1fYutrr73SVQszd1pi4PT09 OEvRyYt7ihlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI6iiGP5xdam/3P0x4yZ3u kuNRXKslsrFcQnvazZPnuSwFRX4GmzH8zzmhtUhI5f5rtWLb96FdexnO/Dotl5nDkmky8ciyyTy cnAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 No need for the extra reference count bump. Signed-off-by: Christian Brauner --- net/dns_resolver/dns_query.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index 0b0789fe2194151102d5234aca3fc2dae9a1ed69..82b084cc1cc6349bb532d5ada555b0bcbb1cdbea 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c @@ -124,9 +124,9 @@ int dns_query(struct net *net, /* make the upcall, using special credentials to prevent the use of * add_key() to preinstall malicious redirections */ - saved_cred = override_creds(get_new_cred(dns_resolver_cache)); + saved_cred = override_creds(dns_resolver_cache); rkey = request_key_net(&key_type_dns_resolver, desc, net, options); - put_cred(revert_creds(saved_cred)); + revert_creds(saved_cred); kfree(desc); if (IS_ERR(rkey)) { ret = PTR_ERR(rkey);