linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHES] fget()-to-fdget() whack-a-mole
@ 2023-03-10 21:25 Al Viro
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
  2023-03-13 11:52 ` [PATCHES] fget()-to-fdget() whack-a-mole Christian Brauner
  0 siblings, 2 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:25 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

	fget()/fget_raw() should be used when we are going to keep
struct file reference; for temporary references fdget()/fdget_raw()
ought to be used.  That kind of stuff keeps cropping up on a regular
basis, and it needs periodic pruning.

	The current pile is in vfs.git #work.fd; individual patches
in followups.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/8] convert setns(2) to fdget()/fdput()
  2023-03-10 21:25 [PATCHES] fget()-to-fdget() whack-a-mole Al Viro
@ 2023-03-10 21:27 ` Al Viro
  2023-03-10 21:27   ` [PATCH 2/8] convert sgx_set_attribute() " Al Viro
                     ` (6 more replies)
  2023-03-13 11:52 ` [PATCHES] fget()-to-fdget() whack-a-mole Christian Brauner
  1 sibling, 7 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/8] convert sgx_set_attribute() to fdget()/fdput()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
@ 2023-03-10 21:27   ` Al Viro
  2023-03-10 21:27   ` [PATCH 3/8] SVM-SEV: convert the rest of fget() uses to fdget() in there Al Viro
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 arch/x86/kernel/cpu/sgx/main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/cpu/sgx/main.c b/arch/x86/kernel/cpu/sgx/main.c
index e5a37b6e9aa5..166692f2d501 100644
--- a/arch/x86/kernel/cpu/sgx/main.c
+++ b/arch/x86/kernel/cpu/sgx/main.c
@@ -892,20 +892,19 @@ static struct miscdevice sgx_dev_provision = {
 int sgx_set_attribute(unsigned long *allowed_attributes,
 		      unsigned int attribute_fd)
 {
-	struct file *file;
+	struct fd f = fdget(attribute_fd);
 
-	file = fget(attribute_fd);
-	if (!file)
+	if (!f.file)
 		return -EINVAL;
 
-	if (file->f_op != &sgx_provision_fops) {
-		fput(file);
+	if (f.file->f_op != &sgx_provision_fops) {
+		fdput(f);
 		return -EINVAL;
 	}
 
 	*allowed_attributes |= SGX_ATTR_PROVISIONKEY;
 
-	fput(file);
+	fdput(f);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sgx_set_attribute);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/8] SVM-SEV: convert the rest of fget() uses to fdget() in there
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
  2023-03-10 21:27   ` [PATCH 2/8] convert sgx_set_attribute() " Al Viro
@ 2023-03-10 21:27   ` Al Viro
  2023-03-10 21:27   ` [PATCH 4/8] kill the last remaining user of proc_ns_fget() Al Viro
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 arch/x86/kvm/svm/sev.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index c25aeb550cd9..52398d49bc2f 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -1767,18 +1767,20 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
 {
 	struct kvm_sev_info *dst_sev = &to_kvm_svm(kvm)->sev_info;
 	struct kvm_sev_info *src_sev, *cg_cleanup_sev;
-	struct file *source_kvm_file;
+	struct fd f = fdget(source_fd);
 	struct kvm *source_kvm;
 	bool charged = false;
 	int ret;
 
-	source_kvm_file = fget(source_fd);
-	if (!file_is_kvm(source_kvm_file)) {
+	if (!f.file)
+		return -EBADF;
+
+	if (!file_is_kvm(f.file)) {
 		ret = -EBADF;
 		goto out_fput;
 	}
 
-	source_kvm = source_kvm_file->private_data;
+	source_kvm = f.file->private_data;
 	ret = sev_lock_two_vms(kvm, source_kvm);
 	if (ret)
 		goto out_fput;
@@ -1828,8 +1830,7 @@ int sev_vm_move_enc_context_from(struct kvm *kvm, unsigned int source_fd)
 out_unlock:
 	sev_unlock_two_vms(kvm, source_kvm);
 out_fput:
-	if (source_kvm_file)
-		fput(source_kvm_file);
+	fdput(f);
 	return ret;
 }
 
@@ -2046,18 +2047,20 @@ int sev_mem_enc_unregister_region(struct kvm *kvm,
 
 int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd)
 {
-	struct file *source_kvm_file;
+	struct fd f = fdget(source_fd);
 	struct kvm *source_kvm;
 	struct kvm_sev_info *source_sev, *mirror_sev;
 	int ret;
 
-	source_kvm_file = fget(source_fd);
-	if (!file_is_kvm(source_kvm_file)) {
+	if (!f.file)
+		return -EBADF;
+
+	if (!file_is_kvm(f.file)) {
 		ret = -EBADF;
 		goto e_source_fput;
 	}
 
-	source_kvm = source_kvm_file->private_data;
+	source_kvm = f.file->private_data;
 	ret = sev_lock_two_vms(kvm, source_kvm);
 	if (ret)
 		goto e_source_fput;
@@ -2103,8 +2106,7 @@ int sev_vm_copy_enc_context_from(struct kvm *kvm, unsigned int source_fd)
 e_unlock:
 	sev_unlock_two_vms(kvm, source_kvm);
 e_source_fput:
-	if (source_kvm_file)
-		fput(source_kvm_file);
+	fdput(f);
 	return ret;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 4/8] kill the last remaining user of proc_ns_fget()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
  2023-03-10 21:27   ` [PATCH 2/8] convert sgx_set_attribute() " 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   ` Al Viro
  2023-03-10 21:27   ` [PATCH 5/8] build_mount_idmapped(): switch to fdget() Al Viro
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

lookups by descriptor are better off closer to syscall surface...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/nsfs.c                | 18 ------------------
 include/linux/proc_ns.h  |  1 -
 net/core/net_namespace.c | 23 +++++++++++------------
 3 files changed, 11 insertions(+), 31 deletions(-)

diff --git a/fs/nsfs.c b/fs/nsfs.c
index f8df60b3b901..f602a96a1afe 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -235,24 +235,6 @@ bool proc_ns_file(const struct file *file)
 	return file->f_op == &ns_file_operations;
 }
 
-struct file *proc_ns_fget(int fd)
-{
-	struct file *file;
-
-	file = fget(fd);
-	if (!file)
-		return ERR_PTR(-EBADF);
-
-	if (file->f_op != &ns_file_operations)
-		goto out_invalid;
-
-	return file;
-
-out_invalid:
-	fput(file);
-	return ERR_PTR(-EINVAL);
-}
-
 /**
  * ns_match() - Returns true if current namespace matches dev/ino provided.
  * @ns: current namespace
diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
index 75807ecef880..49539bc416ce 100644
--- a/include/linux/proc_ns.h
+++ b/include/linux/proc_ns.h
@@ -72,7 +72,6 @@ static inline int ns_alloc_inum(struct ns_common *ns)
 
 #define ns_free_inum(ns) proc_free_inum((ns)->inum)
 
-extern struct file *proc_ns_fget(int fd);
 #define get_proc_ns(inode) ((struct ns_common *)(inode)->i_private)
 extern int ns_get_path(struct path *path, struct task_struct *task,
 			const struct proc_ns_operations *ns_ops);
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 7b69cf882b8e..3e3598cd49f2 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -20,6 +20,7 @@
 #include <linux/sched/task.h>
 #include <linux/uidgid.h>
 #include <linux/cookie.h>
+#include <linux/proc_fs.h>
 
 #include <net/sock.h>
 #include <net/netlink.h>
@@ -676,21 +677,19 @@ EXPORT_SYMBOL_GPL(get_net_ns);
 
 struct net *get_net_ns_by_fd(int fd)
 {
-	struct file *file;
-	struct ns_common *ns;
-	struct net *net;
+	struct fd f = fdget(fd);
+	struct net *net = ERR_PTR(-EINVAL);
 
-	file = proc_ns_fget(fd);
-	if (IS_ERR(file))
-		return ERR_CAST(file);
+	if (!f.file)
+		return ERR_PTR(-EBADF);
 
-	ns = get_proc_ns(file_inode(file));
-	if (ns->ops == &netns_operations)
-		net = get_net(container_of(ns, struct net, ns));
-	else
-		net = ERR_PTR(-EINVAL);
+	if (proc_ns_file(f.file)) {
+		struct ns_common *ns = get_proc_ns(file_inode(f.file));
+		if (ns->ops == &netns_operations)
+			net = get_net(container_of(ns, struct net, ns));
+	}
+	fdput(f);
 
-	fput(file);
 	return net;
 }
 EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 5/8] build_mount_idmapped(): switch to fdget()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
                     ` (2 preceding siblings ...)
  2023-03-10 21:27   ` [PATCH 4/8] kill the last remaining user of proc_ns_fget() Al Viro
@ 2023-03-10 21:27   ` Al Viro
  2023-03-10 21:27   ` [PATCH 6/8] bpf: switch to fdget_raw() Al Viro
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/namespace.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index bc0f15257b49..d26ea0d9041f 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -4197,7 +4197,7 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
 	int err = 0;
 	struct ns_common *ns;
 	struct user_namespace *mnt_userns;
-	struct file *file;
+	struct fd f;
 
 	if (!((attr->attr_set | attr->attr_clr) & MOUNT_ATTR_IDMAP))
 		return 0;
@@ -4213,16 +4213,16 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
 	if (attr->userns_fd > INT_MAX)
 		return -EINVAL;
 
-	file = fget(attr->userns_fd);
-	if (!file)
+	f = fdget(attr->userns_fd);
+	if (!f.file)
 		return -EBADF;
 
-	if (!proc_ns_file(file)) {
+	if (!proc_ns_file(f.file)) {
 		err = -EINVAL;
 		goto out_fput;
 	}
 
-	ns = get_proc_ns(file_inode(file));
+	ns = get_proc_ns(file_inode(f.file));
 	if (ns->ops->type != CLONE_NEWUSER) {
 		err = -EINVAL;
 		goto out_fput;
@@ -4251,7 +4251,7 @@ static int build_mount_idmapped(const struct mount_attr *attr, size_t usize,
 	kattr->mnt_userns = get_user_ns(mnt_userns);
 
 out_fput:
-	fput(file);
+	fdput(f);
 	return err;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 6/8] bpf: switch to fdget_raw()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
                     ` (3 preceding siblings ...)
  2023-03-10 21:27   ` [PATCH 5/8] build_mount_idmapped(): switch to fdget() Al Viro
@ 2023-03-10 21:27   ` 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
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 kernel/bpf/bpf_inode_storage.c | 38 ++++++++++++++--------------------
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/kernel/bpf/bpf_inode_storage.c b/kernel/bpf/bpf_inode_storage.c
index 05f4c66c9089..85720311cc67 100644
--- a/kernel/bpf/bpf_inode_storage.c
+++ b/kernel/bpf/bpf_inode_storage.c
@@ -84,16 +84,13 @@ void bpf_inode_storage_free(struct inode *inode)
 static void *bpf_fd_inode_storage_lookup_elem(struct bpf_map *map, void *key)
 {
 	struct bpf_local_storage_data *sdata;
-	struct file *f;
-	int fd;
+	struct fd f = fdget_raw(*(int *)key);
 
-	fd = *(int *)key;
-	f = fget_raw(fd);
-	if (!f)
+	if (!f.file)
 		return ERR_PTR(-EBADF);
 
-	sdata = inode_storage_lookup(f->f_inode, map, true);
-	fput(f);
+	sdata = inode_storage_lookup(file_inode(f.file), map, true);
+	fdput(f);
 	return sdata ? sdata->data : NULL;
 }
 
@@ -101,22 +98,19 @@ static int bpf_fd_inode_storage_update_elem(struct bpf_map *map, void *key,
 					 void *value, u64 map_flags)
 {
 	struct bpf_local_storage_data *sdata;
-	struct file *f;
-	int fd;
+	struct fd f = fdget_raw(*(int *)key);
 
-	fd = *(int *)key;
-	f = fget_raw(fd);
-	if (!f)
+	if (!f.file)
 		return -EBADF;
-	if (!inode_storage_ptr(f->f_inode)) {
-		fput(f);
+	if (!inode_storage_ptr(file_inode(f.file))) {
+		fdput(f);
 		return -EBADF;
 	}
 
-	sdata = bpf_local_storage_update(f->f_inode,
+	sdata = bpf_local_storage_update(file_inode(f.file),
 					 (struct bpf_local_storage_map *)map,
 					 value, map_flags, GFP_ATOMIC);
-	fput(f);
+	fdput(f);
 	return PTR_ERR_OR_ZERO(sdata);
 }
 
@@ -135,16 +129,14 @@ static int inode_storage_delete(struct inode *inode, struct bpf_map *map)
 
 static int bpf_fd_inode_storage_delete_elem(struct bpf_map *map, void *key)
 {
-	struct file *f;
-	int fd, err;
+	struct fd f = fdget_raw(*(int *)key);
+	int err;
 
-	fd = *(int *)key;
-	f = fget_raw(fd);
-	if (!f)
+	if (!f.file)
 		return -EBADF;
 
-	err = inode_storage_delete(f->f_inode, map);
-	fput(f);
+	err = inode_storage_delete(file_inode(f.file), map);
+	fdput(f);
 	return err;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 7/8] cgroup_get_from_fd(): switch to fdget_raw()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
                     ` (4 preceding siblings ...)
  2023-03-10 21:27   ` [PATCH 6/8] bpf: switch to fdget_raw() Al Viro
@ 2023-03-10 21:27   ` Al Viro
  2023-03-10 21:27   ` [PATCH 8/8] fuse_dev_ioctl(): switch to fdget() Al Viro
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 kernel/cgroup/cgroup.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 935e8121b21e..4b249f81c693 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -6856,14 +6856,12 @@ EXPORT_SYMBOL_GPL(cgroup_get_from_path);
 struct cgroup *cgroup_v1v2_get_from_fd(int fd)
 {
 	struct cgroup *cgrp;
-	struct file *f;
-
-	f = fget_raw(fd);
-	if (!f)
+	struct fd f = fdget_raw(fd);
+	if (!f.file)
 		return ERR_PTR(-EBADF);
 
-	cgrp = cgroup_v1v2_get_from_file(f);
-	fput(f);
+	cgrp = cgroup_v1v2_get_from_file(f.file);
+	fdput(f);
 	return cgrp;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 8/8] fuse_dev_ioctl(): switch to fdget()
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
                     ` (5 preceding siblings ...)
  2023-03-10 21:27   ` [PATCH 7/8] cgroup_get_from_fd(): " Al Viro
@ 2023-03-10 21:27   ` Al Viro
  6 siblings, 0 replies; 10+ messages in thread
From: Al Viro @ 2023-03-10 21:27 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
 fs/fuse/dev.c | 41 +++++++++++++++++++++--------------------
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index eb4f88e3dc97..1a8f82f478cb 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2257,30 +2257,31 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
 	int res;
 	int oldfd;
 	struct fuse_dev *fud = NULL;
+	struct fd f;
 
 	switch (cmd) {
 	case FUSE_DEV_IOC_CLONE:
-		res = -EFAULT;
-		if (!get_user(oldfd, (__u32 __user *)arg)) {
-			struct file *old = fget(oldfd);
-
-			res = -EINVAL;
-			if (old) {
-				/*
-				 * Check against file->f_op because CUSE
-				 * uses the same ioctl handler.
-				 */
-				if (old->f_op == file->f_op)
-					fud = fuse_get_dev(old);
-
-				if (fud) {
-					mutex_lock(&fuse_mutex);
-					res = fuse_device_clone(fud->fc, file);
-					mutex_unlock(&fuse_mutex);
-				}
-				fput(old);
-			}
+		if (get_user(oldfd, (__u32 __user *)arg))
+			return -EFAULT;
+
+		f = fdget(oldfd);
+		if (!f.file)
+			return -EINVAL;
+
+		/*
+		 * Check against file->f_op because CUSE
+		 * uses the same ioctl handler.
+		 */
+		if (f.file->f_op == file->f_op)
+			fud = fuse_get_dev(f.file);
+
+		res = -EINVAL;
+		if (fud) {
+			mutex_lock(&fuse_mutex);
+			res = fuse_device_clone(fud->fc, file);
+			mutex_unlock(&fuse_mutex);
 		}
+		fdput(f);
 		break;
 	default:
 		res = -ENOTTY;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCHES] fget()-to-fdget() whack-a-mole
  2023-03-10 21:25 [PATCHES] fget()-to-fdget() whack-a-mole Al Viro
  2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
@ 2023-03-13 11:52 ` Christian Brauner
  1 sibling, 0 replies; 10+ messages in thread
From: Christian Brauner @ 2023-03-13 11:52 UTC (permalink / raw)
  To: Al Viro; +Cc: linux-fsdevel, linux-kernel

On Fri, Mar 10, 2023 at 09:25:36PM +0000, Al Viro wrote:
> 	fget()/fget_raw() should be used when we are going to keep
> struct file reference; for temporary references fdget()/fdget_raw()
> ought to be used.  That kind of stuff keeps cropping up on a regular

Fwiw, might be worth to mention/document that explicitly anywhere.
I didn't see anything but might've missed it.

> basis, and it needs periodic pruning.
> 
> 	The current pile is in vfs.git #work.fd; individual patches
> in followups.

Reviewed-by: Christian Brauner <brauner@kernel.org>

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-13 11:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-10 21:25 [PATCHES] fget()-to-fdget() whack-a-mole Al Viro
2023-03-10 21:27 ` [PATCH 1/8] convert setns(2) to fdget()/fdput() Al Viro
2023-03-10 21:27   ` [PATCH 2/8] convert sgx_set_attribute() " 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

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).