Skip to content

Commit

Permalink
file: stop exposing receive_fd_user()
Browse files Browse the repository at this point in the history
Not every subsystem needs to have their own specialized helper.
Just us the __receive_fd() helper.

Link: https://lore.kernel.org/r/[email protected]
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Jens Axboe <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
  • Loading branch information
brauner committed Dec 12, 2023
1 parent 372a34e commit eac9189
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 0 additions & 7 deletions include/linux/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

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

extern void flush_delayed_fput(void);
Expand Down
9 changes: 9 additions & 0 deletions include/net/scm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <linux/limits.h>
#include <linux/net.h>
#include <linux/cred.h>
#include <linux/file.h>
#include <linux/security.h>
#include <linux/pid.h>
#include <linux/nsproxy.h>
Expand Down Expand Up @@ -208,5 +209,13 @@ static inline void scm_recv_unix(struct socket *sock, struct msghdr *msg,
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 */

2 changes: 1 addition & 1 deletion net/compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
int err = 0, 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)
break;
}
Expand Down
2 changes: 1 addition & 1 deletion net/core/scm.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
}

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)
break;
}
Expand Down

0 comments on commit eac9189

Please sign in to comment.