mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
net: Split a __sys_bind helper for io_uring
io_uring holds a reference to the file and maintains a sockaddr_storage address. Similarly to what was done to __sys_connect_file, split an internal helper for __sys_bind in preparation to supporting an io_uring bind command. Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Gabriel Krisman Bertazi <krisman@suse.de> Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com> Acked-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/r/20240614163047.31581-1-krisman@suse.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
3b87184f7e
commit
dc2e779794
@ -442,6 +442,8 @@ extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
|
||||
extern int __sys_socket(int family, int type, int protocol);
|
||||
extern struct file *__sys_socket_file(int family, int type, int protocol);
|
||||
extern int __sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen);
|
||||
extern int __sys_bind_socket(struct socket *sock, struct sockaddr_storage *address,
|
||||
int addrlen);
|
||||
extern int __sys_connect_file(struct file *file, struct sockaddr_storage *addr,
|
||||
int addrlen, int file_flags);
|
||||
extern int __sys_connect(int fd, struct sockaddr __user *uservaddr,
|
||||
|
25
net/socket.c
25
net/socket.c
@ -1822,6 +1822,20 @@ SYSCALL_DEFINE4(socketpair, int, family, int, type, int, protocol,
|
||||
return __sys_socketpair(family, type, protocol, usockvec);
|
||||
}
|
||||
|
||||
int __sys_bind_socket(struct socket *sock, struct sockaddr_storage *address,
|
||||
int addrlen)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = security_socket_bind(sock, (struct sockaddr *)address,
|
||||
addrlen);
|
||||
if (!err)
|
||||
err = READ_ONCE(sock->ops)->bind(sock,
|
||||
(struct sockaddr *)address,
|
||||
addrlen);
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bind a name to a socket. Nothing much to do here since it's
|
||||
* the protocol's responsibility to handle the local address.
|
||||
@ -1839,15 +1853,8 @@ int __sys_bind(int fd, struct sockaddr __user *umyaddr, int addrlen)
|
||||
sock = sockfd_lookup_light(fd, &err, &fput_needed);
|
||||
if (sock) {
|
||||
err = move_addr_to_kernel(umyaddr, addrlen, &address);
|
||||
if (!err) {
|
||||
err = security_socket_bind(sock,
|
||||
(struct sockaddr *)&address,
|
||||
addrlen);
|
||||
if (!err)
|
||||
err = READ_ONCE(sock->ops)->bind(sock,
|
||||
(struct sockaddr *)
|
||||
&address, addrlen);
|
||||
}
|
||||
if (!err)
|
||||
err = __sys_bind_socket(sock, &address, addrlen);
|
||||
fput_light(sock->file, fput_needed);
|
||||
}
|
||||
return err;
|
||||
|
Loading…
Reference in New Issue
Block a user