Skip to content

Commit eac9189

Browse files
committed
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>
1 parent 372a34e commit eac9189

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

include/linux/file.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,6 @@ extern int __receive_fd(struct file *file, int __user *ufd,
101101

102102
extern int receive_fd(struct file *file, unsigned int o_flags);
103103

104-
static inline int receive_fd_user(struct file *file, int __user *ufd,
105-
unsigned int o_flags)
106-
{
107-
if (ufd == NULL)
108-
return -EFAULT;
109-
return __receive_fd(file, ufd, o_flags);
110-
}
111104
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags);
112105

113106
extern void flush_delayed_fput(void);

include/net/scm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/limits.h>
66
#include <linux/net.h>
77
#include <linux/cred.h>
8+
#include <linux/file.h>
89
#include <linux/security.h>
910
#include <linux/pid.h>
1011
#include <linux/nsproxy.h>
@@ -208,5 +209,13 @@ static inline void scm_recv_unix(struct socket *sock, struct msghdr *msg,
208209
scm_destroy_cred(scm);
209210
}
210211

212+
static inline int scm_recv_one_fd(struct file *f, int __user *ufd,
213+
unsigned int flags)
214+
{
215+
if (!ufd)
216+
return -EFAULT;
217+
return __receive_fd(f, ufd, flags);
218+
}
219+
211220
#endif /* __LINUX_NET_SCM_H */
212221

net/compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
297297
int err = 0, i;
298298

299299
for (i = 0; i < fdmax; i++) {
300-
err = receive_fd_user(scm->fp->fp[i], cmsg_data + i, o_flags);
300+
err = scm_recv_one_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
301301
if (err < 0)
302302
break;
303303
}

net/core/scm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
319319
}
320320

321321
for (i = 0; i < fdmax; i++) {
322-
err = receive_fd_user(scm->fp->fp[i], cmsg_data + i, o_flags);
322+
err = scm_recv_one_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
323323
if (err < 0)
324324
break;
325325
}

0 commit comments

Comments
 (0)