file: stop exposing receive_fd_user()

Not every subsystem needs to have their own specialized helper.
Just us the __receive_fd() helper.

Link: https://lore.kernel.org/r/20231130-vfs-files-fixes-v1-4-e73ca6f4ea83@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2023-11-30 13:49:10 +01:00
parent 372a34e66f
commit eac9189c96
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
4 changed files with 11 additions and 9 deletions

View File

@ -101,13 +101,6 @@ extern int __receive_fd(struct file *file, int __user *ufd,
extern int receive_fd(struct file *file, unsigned int o_flags); extern int receive_fd(struct file *file, unsigned int o_flags);
static inline int receive_fd_user(struct file *file, int __user *ufd,
unsigned int o_flags)
{
if (ufd == NULL)
return -EFAULT;
return __receive_fd(file, ufd, o_flags);
}
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags); int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
extern void flush_delayed_fput(void); extern void flush_delayed_fput(void);

View File

@ -5,6 +5,7 @@
#include <linux/limits.h> #include <linux/limits.h>
#include <linux/net.h> #include <linux/net.h>
#include <linux/cred.h> #include <linux/cred.h>
#include <linux/file.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/pid.h> #include <linux/pid.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
@ -208,5 +209,13 @@ static inline void scm_recv_unix(struct socket *sock, struct msghdr *msg,
scm_destroy_cred(scm); scm_destroy_cred(scm);
} }
static inline int scm_recv_one_fd(struct file *f, int __user *ufd,
unsigned int flags)
{
if (!ufd)
return -EFAULT;
return __receive_fd(f, ufd, flags);
}
#endif /* __LINUX_NET_SCM_H */ #endif /* __LINUX_NET_SCM_H */

View File

@ -297,7 +297,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
int err = 0, i; int err = 0, i;
for (i = 0; i < fdmax; i++) { for (i = 0; i < fdmax; i++) {
err = receive_fd_user(scm->fp->fp[i], cmsg_data + i, o_flags); err = scm_recv_one_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
if (err < 0) if (err < 0)
break; break;
} }

View File

@ -319,7 +319,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
} }
for (i = 0; i < fdmax; i++) { for (i = 0; i < fdmax; i++) {
err = receive_fd_user(scm->fp->fp[i], cmsg_data + i, o_flags); err = scm_recv_one_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
if (err < 0) if (err < 0)
break; break;
} }