Skip to contentSkip to conversation

net: Split a __sys_bind helper for io_uring

PATCH Applied Gabriel Krisman Bertazi 6 participants 17 messages Jun 14, 2024 – Jul 22, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 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.

---
 include/linux/socket.h |  2 ++
 net/socket.c           | 25 ++++++++++++++++---------
 2 files changed, 18 insertions(+), 9 deletions(-)
include/linux/socket.h +2 -0
index 89d16b90370b..b3000f49e9f5 100644
@@ -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,
net/socket.c +16 -9
index e416920e9399..fd0714e10ced 100644
@@ -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;
Signature · 1 line
2.45.2
#1 lore raw

PATCH v2 2/4 net: Split a __sys_listen 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_listen in preparation to support an io_uring listen command.

---
 include/linux/socket.h |  1 +
 net/socket.c           | 23 ++++++++++++++---------
 2 files changed, 15 insertions(+), 9 deletions(-)
include/linux/socket.h +1 -0
index b3000f49e9f5..c1f16cdab677 100644
@@ -449,6 +449,7 @@ extern int __sys_connect_file(struct file *file, struct sockaddr_storage *addr,
 extern int __sys_connect(int fd, struct sockaddr __user *uservaddr,
 			 int addrlen);
 extern int __sys_listen(int fd, int backlog);
+extern int __sys_listen_socket(struct socket *sock, int backlog);
 extern int __sys_getsockname(int fd, struct sockaddr __user *usockaddr,
 			     int __user *usockaddr_len);
 extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr,
net/socket.c +14 -9
index fd0714e10ced..fcbdd5bc47ac 100644
@@ -1870,23 +1870,28 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
  *	necessary for a listen, and if that works, we mark the socket as
  *	ready for listening.
  */
+int __sys_listen_socket(struct socket *sock, int backlog)
+{
+	int somaxconn, err;
+
+	somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
+	if ((unsigned int)backlog > somaxconn)
+		backlog = somaxconn;
+
+	err = security_socket_listen(sock, backlog);
+	if (!err)
+		err = READ_ONCE(sock->ops)->listen(sock, backlog);
+	return err;
+}
 
 int __sys_listen(int fd, int backlog)
 {
 	struct socket *sock;
 	int err, fput_needed;
-	int somaxconn;
 
 	sock = sockfd_lookup_light(fd, &err, &fput_needed);
 	if (sock) {
-		somaxconn = READ_ONCE(sock_net(sock->sk)->core.sysctl_somaxconn);
-		if ((unsigned int)backlog > somaxconn)
-			backlog = somaxconn;
-
-		err = security_socket_listen(sock, backlog);
-		if (!err)
-			err = READ_ONCE(sock->ops)->listen(sock, backlog);
-
+		err = __sys_listen_socket(sock, backlog);
 		fput_light(sock->file, fput_needed);
 	}
 	return err;
Signature · 1 line
2.45.2
Reviewed-by on v2 2/4
#2 lore raw

Re: [PATCH v2 2/4] net: Split a __sys_listen helper for io_uring

From: Gabriel Krisman Bertazi <[email protected]>
Date: Fri, 14 Jun 2024 12:30:45 -0400

Quoted 7 lines

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_listen in preparation to support an io_uring listen command.

maintainer Acked-by on v2 2/4
#3 lore raw

Re: [PATCH v2 2/4] net: Split a __sys_listen helper for io_uring

In reply to Gabriel Krisman Bertazi
Quoted 7 lines · On Fri, 14 Jun 2024 12:30:45 -0400 Gabriel Krisman Bertazi wrote:

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_listen in preparation to support an io_uring listen command.

#4 lore raw

PATCH v2 3/4 io_uring: Introduce IORING_OP_BIND

In reply to Gabriel Krisman Bertazi

IORING_OP_BIND provides the semantic of bind(2) via io_uring. While this is an essentially synchronous system call, the main point is to enable a network path to execute fully with io_uring registered and descriptorless files.

---
changes since v1:
- drop explocit error handling for move_addr_to_kernel (jens)
- Remove empty line ahead of return;

---
 include/uapi/linux/io_uring.h |  1 +
 io_uring/net.c                | 36 +++++++++++++++++++++++++++++++++++
 io_uring/net.h                |  3 +++
 io_uring/opdef.c              | 13 +++++++++++++
 4 files changed, 53 insertions(+)
include/uapi/linux/io_uring.h +1 -0
index 994bf7af0efe..4ef153d95c87 100644
@@ -257,6 +257,7 @@ enum io_uring_op {
 	IORING_OP_FUTEX_WAITV,
 	IORING_OP_FIXED_FD_INSTALL,
 	IORING_OP_FTRUNCATE,
+	IORING_OP_BIND,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
io_uring/net.c +36 -0
index 0a48596429d9..8cbc29aff15c 100644
@@ -51,6 +51,11 @@ struct io_connect {
 	bool				seen_econnaborted;
 };
 
+struct io_bind {
+	struct file			*file;
+	int				addr_len;
+};
+
 struct io_sr_msg {
 	struct file			*file;
 	union {
@@ -1715,6 +1720,37 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 	return IOU_OK;
 }
 
+int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+	struct io_bind *bind = io_kiocb_to_cmd(req, struct io_bind);
+	struct sockaddr __user *uaddr;
+	struct io_async_msghdr *io;
+
+	if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in)
+		return -EINVAL;
+
+	uaddr = u64_to_user_ptr(READ_ONCE(sqe->addr));
+	bind->addr_len =  READ_ONCE(sqe->addr2);
+
+	io = io_msg_alloc_async(req);
+	if (unlikely(!io))
+		return -ENOMEM;
+	return move_addr_to_kernel(uaddr, bind->addr_len, &io->addr);
+}
+
+int io_bind(struct io_kiocb *req, unsigned int issue_flags)
+{
+	struct io_bind *bind = io_kiocb_to_cmd(req, struct io_bind);
+	struct io_async_msghdr *io = req->async_data;
+	int ret;
+
+	ret = __sys_bind_socket(sock_from_file(req->file),  &io->addr, bind->addr_len);
+	if (ret < 0)
+		req_set_fail(req);
+	io_req_set_res(req, ret, 0);
+	return 0;
+}
+
 void io_netmsg_cache_free(const void *entry)
 {
 	struct io_async_msghdr *kmsg = (struct io_async_msghdr *) entry;
io_uring/net.h +3 -0
index 0eb1c1920fc9..49f9a7bc1113 100644
@@ -49,6 +49,9 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags);
 int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 void io_send_zc_cleanup(struct io_kiocb *req);
 
+int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+int io_bind(struct io_kiocb *req, unsigned int issue_flags);
+
 void io_netmsg_cache_free(const void *entry);
 #else
 static inline void io_netmsg_cache_free(const void *entry)
io_uring/opdef.c +13 -0
index 2de5cca9504e..19ee9445f024 100644
@@ -495,6 +495,16 @@ const struct io_issue_def io_issue_defs[] = {
 		.prep			= io_ftruncate_prep,
 		.issue			= io_ftruncate,
 	},
+	[IORING_OP_BIND] = {
+#if defined(CONFIG_NET)
+		.needs_file		= 1,
+		.prep			= io_bind_prep,
+		.issue			= io_bind,
+		.async_size		= sizeof(struct io_async_msghdr),
+#else
+		.prep			= io_eopnotsupp_prep,
+#endif
+	},
 };
 
 const struct io_cold_def io_cold_defs[] = {
@@ -711,6 +721,9 @@ const struct io_cold_def io_cold_defs[] = {
 	[IORING_OP_FTRUNCATE] = {
 		.name			= "FTRUNCATE",
 	},
+	[IORING_OP_BIND] = {
+		.name			= "BIND",
+	},
 };
 
 const char *io_uring_get_opcode(u8 opcode)
Signature · 1 line
2.45.2
#5 lore raw

Re: [PATCH v2 3/4] io_uring: Introduce IORING_OP_BIND

From: Gabriel Krisman Bertazi <[email protected]>
Date: Fri, 14 Jun 2024 12:30:46 -0400

Quoted 51 lines

IORING_OP_BIND provides the semantic of bind(2) via io_uring. While this is an essentially synchronous system call, the main point is to enable a network path to execute fully with io_uring registered and descriptorless files.

---
changes since v1:
- drop explocit error handling for move_addr_to_kernel (jens)
- Remove empty line ahead of return;

---
 include/uapi/linux/io_uring.h |  1 +
 io_uring/net.c                | 36 +++++++++++++++++++++++++++++++++++
 io_uring/net.h                |  3 +++
 io_uring/opdef.c              | 13 +++++++++++++
 4 files changed, 53 insertions(+)
include/uapi/linux/io_uring.h +1 -0
index 994bf7af0efe..4ef153d95c87 100644
@@ -257,6 +257,7 @@ enum io_uring_op {
 	IORING_OP_FUTEX_WAITV,
 	IORING_OP_FIXED_FD_INSTALL,
 	IORING_OP_FTRUNCATE,
+	IORING_OP_BIND,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
io_uring/net.c +6 -0
index 0a48596429d9..8cbc29aff15c 100644
@@ -51,6 +51,11 @@ struct io_connect {
 	bool				seen_econnaborted;
 };
 
+struct io_bind {
+	struct file			*file;
+	int				addr_len;
+};
+
 struct io_sr_msg {
 	struct file			*file;
 	union {
@@ -1715,6 +1720,37 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 	return IOU_OK;
 }
 
+int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)

io_uring/net.c int io_connect(struct io_kiocb *req, unsigned int issue_flags) · line 1733

Quoted 10 lines
io_uring/net.c +10 -0
+{
+	struct io_bind *bind = io_kiocb_to_cmd(req, struct io_bind);
+	struct sockaddr __user *uaddr;
+	struct io_async_msghdr *io;
+
+	if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in)
+		return -EINVAL;
+
+	uaddr = u64_to_user_ptr(READ_ONCE(sqe->addr));
+	bind->addr_len =  READ_ONCE(sqe->addr2);
                        ^^

nit: double space

Quoted 4 lines
io_uring/net.c +4 -0
+
+	io = io_msg_alloc_async(req);
+	if (unlikely(!io))
+		return -ENOMEM;

io_uring/net.c int io_connect(struct io_kiocb *req, unsigned int issue_flags) · line 1747

Quoted 10 lines
io_uring/net.c +10 -0
+	return move_addr_to_kernel(uaddr, bind->addr_len, &io->addr);
+}
+
+int io_bind(struct io_kiocb *req, unsigned int issue_flags)
+{
+	struct io_bind *bind = io_kiocb_to_cmd(req, struct io_bind);
+	struct io_async_msghdr *io = req->async_data;
+	int ret;
+
+	ret = __sys_bind_socket(sock_from_file(req->file),  &io->addr, bind->addr_len);
                                                          ^^

ditto

Quoted 56 lines
io_uring/net.c +6 -0
+	if (ret < 0)
+		req_set_fail(req);
+	io_req_set_res(req, ret, 0);
+	return 0;
+}
+
 void io_netmsg_cache_free(const void *entry)
 {
 	struct io_async_msghdr *kmsg = (struct io_async_msghdr *) entry;
io_uring/net.h +3 -0
index 0eb1c1920fc9..49f9a7bc1113 100644
@@ -49,6 +49,9 @@ int io_sendmsg_zc(struct io_kiocb *req, unsigned int issue_flags);
 int io_send_zc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 void io_send_zc_cleanup(struct io_kiocb *req);
 
+int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+int io_bind(struct io_kiocb *req, unsigned int issue_flags);
+
 void io_netmsg_cache_free(const void *entry);
 #else
 static inline void io_netmsg_cache_free(const void *entry)
io_uring/opdef.c +13 -0
index 2de5cca9504e..19ee9445f024 100644
@@ -495,6 +495,16 @@ const struct io_issue_def io_issue_defs[] = {
 		.prep			= io_ftruncate_prep,
 		.issue			= io_ftruncate,
 	},
+	[IORING_OP_BIND] = {
+#if defined(CONFIG_NET)
+		.needs_file		= 1,
+		.prep			= io_bind_prep,
+		.issue			= io_bind,
+		.async_size		= sizeof(struct io_async_msghdr),
+#else
+		.prep			= io_eopnotsupp_prep,
+#endif
+	},
 };
 
 const struct io_cold_def io_cold_defs[] = {
@@ -711,6 +721,9 @@ const struct io_cold_def io_cold_defs[] = {
 	[IORING_OP_FTRUNCATE] = {
 		.name			= "FTRUNCATE",
 	},
+	[IORING_OP_BIND] = {
+		.name			= "BIND",
+	},
 };
 
 const char *io_uring_get_opcode(u8 opcode)
Signature · 1 line
2.45.2
maintainer
#6 lore raw

Re: [PATCH v2 3/4] io_uring: Introduce IORING_OP_BIND

Quoted 64 lines · Kuniyuki Iwashima

From: Gabriel Krisman Bertazi <[email protected]>
Date: Fri, 14 Jun 2024 12:30:46 -0400

Quoted 51 lines

IORING_OP_BIND provides the semantic of bind(2) via io_uring. While this is an essentially synchronous system call, the main point is to enable a network path to execute fully with io_uring registered and descriptorless files.

---
changes since v1:
- drop explocit error handling for move_addr_to_kernel (jens)
- Remove empty line ahead of return;

---
 include/uapi/linux/io_uring.h |  1 +
 io_uring/net.c                | 36 +++++++++++++++++++++++++++++++++++
 io_uring/net.h                |  3 +++
 io_uring/opdef.c              | 13 +++++++++++++
 4 files changed, 53 insertions(+)
include/uapi/linux/io_uring.h +1 -0
index 994bf7af0efe..4ef153d95c87 100644
@@ -257,6 +257,7 @@ enum io_uring_op {
 	IORING_OP_FUTEX_WAITV,
 	IORING_OP_FIXED_FD_INSTALL,
 	IORING_OP_FTRUNCATE,
+	IORING_OP_BIND,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
io_uring/net.c +6 -0
index 0a48596429d9..8cbc29aff15c 100644
@@ -51,6 +51,11 @@ struct io_connect {
 	bool				seen_econnaborted;
 };
 
+struct io_bind {
+	struct file			*file;
+	int				addr_len;
+};
+
 struct io_sr_msg {
 	struct file			*file;
 	union {
@@ -1715,6 +1720,37 @@ int io_connect(struct io_kiocb *req, unsigned int issue_flags)
 	return IOU_OK;
 }
 
+int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)

io_uring/net.c int io_connect(struct io_kiocb *req, unsigned int issue_flags) · line 1733

Quoted 10 lines
io_uring/net.c +10 -0
+{
+	struct io_bind *bind = io_kiocb_to_cmd(req, struct io_bind);
+	struct sockaddr __user *uaddr;
+	struct io_async_msghdr *io;
+
+	if (sqe->len || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in)
+		return -EINVAL;
+
+	uaddr = u64_to_user_ptr(READ_ONCE(sqe->addr));
+	bind->addr_len =  READ_ONCE(sqe->addr2);
                        ^^
Quoted 1 line

nit: double space

Thanks for spotting those, I can just remove those two while applying. Mostly just a note to Grabriel, no need to re-post for that.

Signature · 1 line
Jens Axboe
#7 lore raw

PATCH v2 4/4 io_uring: Introduce IORING_OP_LISTEN

In reply to Gabriel Krisman Bertazi

IORING_OP_LISTEN provides the semantic of listen(2) via io_uring. While this is an essentially synchronous system call, the main point is to enable a network path to execute fully with io_uring registered and descriptorless files.

---
changes since v1:
- Drop empty lines ahead of return (Jens).

---
 include/uapi/linux/io_uring.h |  1 +
 io_uring/net.c                | 28 ++++++++++++++++++++++++++++
 io_uring/net.h                |  3 +++
 io_uring/opdef.c              | 13 +++++++++++++
 4 files changed, 45 insertions(+)
include/uapi/linux/io_uring.h +1 -0
index 4ef153d95c87..2aaf7ee256ac 100644
@@ -258,6 +258,7 @@ enum io_uring_op {
 	IORING_OP_FIXED_FD_INSTALL,
 	IORING_OP_FTRUNCATE,
 	IORING_OP_BIND,
+	IORING_OP_LISTEN,
 
 	/* this goes last, obviously */
 	IORING_OP_LAST,
io_uring/net.c +28 -0
index 8cbc29aff15c..028e126ab30c 100644
@@ -56,6 +56,11 @@ struct io_bind {
 	int				addr_len;
 };
 
+struct io_listen {
+	struct file			*file;
+	int				backlog;
+};
+
 struct io_sr_msg {
 	struct file			*file;
 	union {
@@ -1751,6 +1756,29 @@ int io_bind(struct io_kiocb *req, unsigned int issue_flags)
 	return 0;
 }
 
+int io_listen_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
+{
+	struct io_listen *listen = io_kiocb_to_cmd(req, struct io_listen);
+
+	if (sqe->addr || sqe->buf_index || sqe->rw_flags || sqe->splice_fd_in || sqe->addr2)
+		return -EINVAL;
+
+	listen->backlog = READ_ONCE(sqe->len);
+	return 0;
+}
+
+int io_listen(struct io_kiocb *req, unsigned int issue_flags)
+{
+	struct io_listen *listen = io_kiocb_to_cmd(req, struct io_listen);
+	int ret;
+
+	ret = __sys_listen_socket(sock_from_file(req->file), listen->backlog);
+	if (ret < 0)
+		req_set_fail(req);
+	io_req_set_res(req, ret, 0);
+	return 0;
+}
+
 void io_netmsg_cache_free(const void *entry)
 {
 	struct io_async_msghdr *kmsg = (struct io_async_msghdr *) entry;
io_uring/net.h +3 -0
index 49f9a7bc1113..52bfee05f06a 100644
@@ -52,6 +52,9 @@ void io_send_zc_cleanup(struct io_kiocb *req);
 int io_bind_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
 int io_bind(struct io_kiocb *req, unsigned int issue_flags);
 
+int io_listen_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe);
+int io_listen(struct io_kiocb *req, unsigned int issue_flags);
+
 void io_netmsg_cache_free(const void *entry);
 #else
 static inline void io_netmsg_cache_free(const void *entry)
io_uring/opdef.c +13 -0
index 19ee9445f024..7d5c51fb8e6e 100644
@@ -503,6 +503,16 @@ const struct io_issue_def io_issue_defs[] = {
 		.async_size		= sizeof(struct io_async_msghdr),
 #else
 		.prep			= io_eopnotsupp_prep,
+#endif
+	},
+	[IORING_OP_LISTEN] = {
+#if defined(CONFIG_NET)
+		.needs_file		= 1,
+		.prep			= io_listen_prep,
+		.issue			= io_listen,
+		.async_size		= sizeof(struct io_async_msghdr),
+#else
+		.prep			= io_eopnotsupp_prep,
 #endif
 	},
 };
@@ -724,6 +734,9 @@ const struct io_cold_def io_cold_defs[] = {
 	[IORING_OP_BIND] = {
 		.name			= "BIND",
 	},
+	[IORING_OP_LISTEN] = {
+		.name			= "LISTEN",
+	},
 };
 
 const char *io_uring_get_opcode(u8 opcode)
Signature · 1 line
2.45.2
Reviewed-by on v2 1/4
#8 lore raw
In reply to Gabriel Krisman Bertazi

From: Gabriel Krisman Bertazi <[email protected]>
Date: Fri, 14 Jun 2024 12:30:44 -0400

Quoted 7 lines

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.

maintainer Acked-by on v2 1/4
#9 lore raw
In reply to Gabriel Krisman Bertazi
Quoted 7 lines · On Fri, 14 Jun 2024 12:30:44 -0400 Gabriel Krisman Bertazi wrote:

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.

maintainer
#10 lore raw
Quoted 10 lines · Jakub Kicinski
Quoted 7 lines · On Fri, 14 Jun 2024 12:30:44 -0400 Gabriel Krisman Bertazi wrote:

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.

Are you fine with me queueing up 1-2 via the io_uring branch? I'm guessing the risk of conflict should be very low, so doesn't warrant a shared branch.

Signature · 1 line
Jens Axboe
maintainer
#11 lore raw
Quoted 7 lines · On Wed, 19 Jun 2024 07:40:40 -0600 Jens Axboe wrote:
Quoted 6 lines · Jakub Kicinski
Quoted 5 lines · On Fri, 14 Jun 2024 12:30:44 -0400 Gabriel Krisman Bertazi wrote:

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.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Are you fine with me queueing up 1-2 via the io_uring branch? I'm guessing the risk of conflict should be very low, so doesn't warrant a shared branch.

Yup, exactly, these can go via io_uring without branch juggling.

maintainer
#12 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Wed, 19 Jun 2024 07:40:40 -0600 Jens Axboe wrote:
Quoted 9 lines · Jakub Kicinski
Quoted 7 lines · On Fri, 14 Jun 2024 12:30:44 -0400 Gabriel Krisman Bertazi wrote:

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.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Are you fine with me queueing up 1-2 via the io_uring branch? I'm guessing the risk of conflict should be very low, so doesn't warrant a shared branch.

Yup, exactly, these can go via io_uring without branch juggling.

Great thanks!

Signature · 1 line
Jens Axboe
#13 lore raw
Quoted 14 lines · Jens Axboe
Quoted 13 lines · Jakub Kicinski
Quoted 12 lines · On Wed, 19 Jun 2024 07:40:40 -0600 Jens Axboe wrote:
Quoted 10 lines · Jakub Kicinski
Quoted 7 lines · On Fri, 14 Jun 2024 12:30:44 -0400 Gabriel Krisman Bertazi wrote:

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.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Are you fine with me queueing up 1-2 via the io_uring branch? I'm guessing the risk of conflict should be very low, so doesn't warrant a shared branch.

Yup, exactly, these can go via io_uring without branch juggling.

Great thanks!

Please fix io_bind and io_listen to not pass NULL ptr to related helpers __sys_bind_socket and __sys_listen_socket. The first helper's argument shouldn't be NULL, as related security hooks expect a valid socket object.

See the syzkaller's bug report:
https://lore.kernel.org/linux-security-module/[email protected]/

Thanks,
mY

#14 lore raw
Quoted 6 lines · Matus Jokay

Please fix io_bind and io_listen to not pass NULL ptr to related helpers __sys_bind_socket and __sys_listen_socket. The first helper's argument shouldn't be NULL, as related security hooks expect a valid socket object.

See the syzkaller's bug report:
https://lore.kernel.org/linux-security-module/[email protected]/

That was already fixed.

https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=ad00e629145b2b9f0d78aa46e204a9df7d628978

#15 lore raw
Quoted 5 lines · Tetsuo Handa
Quoted 4 lines · Matus Jokay

Please fix io_bind and io_listen to not pass NULL ptr to related helpers __sys_bind_socket and __sys_listen_socket. The first helper's argument shouldn't be NULL, as related security hooks expect a valid socket object.

Quoted 8 lines
Quoted 2 lines

See the syzkaller's bug report:
https://lore.kernel.org/linux-security-module/[email protected]/

That was already fixed.

https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git/commit/?h=for-next&id=ad00e629145b2b9f0d78aa46e204a9df7d628978

Tetsuo, you are very fast ;)
Thank you!
mY

maintainer Applied
#16 lore raw
In reply to Gabriel Krisman Bertazi
Quoted 6 lines · Gabriel Krisman Bertazi

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.

Applied, thanks!

[1/4] net: Split a __sys_bind helper for io_uring

      commit: dc2e77979412d289df9049d8c693761db8602867
[2/4] net: Split a __sys_listen helper for io_uring
      commit: bb6aaf736680f0f3c2e6281735c47c64e2042819
[3/4] io_uring: Introduce IORING_OP_BIND
      commit: 7481fd93fa0a851740e26026485f56a1305454ce
[4/4] io_uring: Introduce IORING_OP_LISTEN
      commit: ff140cc8628abfb1755691d16cfa8788d8820ef7

Best regards,

Signature · 1 line
Jens Axboe