From: Al Viro <viro@zeniv.linux.org.uk>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 1/8] convert setns(2) to fdget()/fdput()
Date: Fri, 10 Mar 2023 21:27:41 +0000 [thread overview]
Message-ID: <20230310212748.3679076-1-viro@zeniv.linux.org.uk> (raw)
In-Reply-To: <20230310212536.GX3390869@ZenIV>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
kernel/nsproxy.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c
index a487ff24129b..80d9c6d77a45 100644
--- a/kernel/nsproxy.c
+++ b/kernel/nsproxy.c
@@ -545,21 +545,20 @@ static void commit_nsset(struct nsset *nsset)
SYSCALL_DEFINE2(setns, int, fd, int, flags)
{
- struct file *file;
+ struct fd f = fdget(fd);
struct ns_common *ns = NULL;
struct nsset nsset = {};
int err = 0;
- file = fget(fd);
- if (!file)
+ if (!f.file)
return -EBADF;
- if (proc_ns_file(file)) {
- ns = get_proc_ns(file_inode(file));
+ if (proc_ns_file(f.file)) {
+ ns = get_proc_ns(file_inode(f.file));
if (flags && (ns->ops->type != flags))
err = -EINVAL;
flags = ns->ops->type;
- } else if (!IS_ERR(pidfd_pid(file))) {
+ } else if (!IS_ERR(pidfd_pid(f.file))) {
err = check_setns_flags(flags);
} else {
err = -EINVAL;
@@ -571,17 +570,17 @@ SYSCALL_DEFINE2(setns, int, fd, int, flags)
if (err)
goto out;
- if (proc_ns_file(file))
+ if (proc_ns_file(f.file))
err = validate_ns(&nsset, ns);
else
- err = validate_nsset(&nsset, file->private_data);
+ err = validate_nsset(&nsset, f.file->private_data);
if (!err) {
commit_nsset(&nsset);
perf_event_namespaces(current);
}
put_nsset(&nsset);
out:
- fput(file);
+ fdput(f);
return err;
}
--
2.30.2
next prev parent reply other threads:[~2023-03-10 21:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-10 21:25 [PATCHES] fget()-to-fdget() whack-a-mole Al Viro
2023-03-10 21:27 ` Al Viro [this message]
2023-03-10 21:27 ` [PATCH 2/8] convert sgx_set_attribute() to fdget()/fdput() Al Viro
2023-03-10 21:27 ` [PATCH 3/8] SVM-SEV: convert the rest of fget() uses to fdget() in there Al Viro
2023-03-10 21:27 ` [PATCH 4/8] kill the last remaining user of proc_ns_fget() Al Viro
2023-03-10 21:27 ` [PATCH 5/8] build_mount_idmapped(): switch to fdget() Al Viro
2023-03-10 21:27 ` [PATCH 6/8] bpf: switch to fdget_raw() Al Viro
2023-03-10 21:27 ` [PATCH 7/8] cgroup_get_from_fd(): " Al Viro
2023-03-10 21:27 ` [PATCH 8/8] fuse_dev_ioctl(): switch to fdget() Al Viro
2023-03-13 11:52 ` [PATCHES] fget()-to-fdget() whack-a-mole Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230310212748.3679076-1-viro@zeniv.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).