From: Jiayuan Chen <jiayuan.chen@linux.dev>
To: Mahe Tardy <mahe.tardy@gmail.com>, bpf@vger.kernel.org
Cc: andrew+netdev@lunn.ch, andrii@kernel.org, ast@kernel.org,
daniel@iogearbox.net, davem@davemloft.net, eddyz87@gmail.com,
edumazet@google.com, john.fastabend@gmail.com, kuba@kernel.org,
liamwisehart@meta.com, martin.lau@linux.dev, pabeni@redhat.com,
song@kernel.org, netdev@vger.kernel.org, sdf.kernel@gmail.com,
ameryhung@gmail.com, kuniyu@google.com, memxor@gmail.com
Subject: Re: [PATCH bpf-next v4 1/5] net: Add connect_socket() helper
Date: Fri, 7 Aug 2026 09:53:51 +0800 [thread overview]
Message-ID: <05084a53-a1a4-4e60-bdd7-6fd16ef6a029@linux.dev> (raw)
In-Reply-To: <20260806182234.380833-2-mahe.tardy@gmail.com>
On 8/7/26 2:22 AM, Mahe Tardy wrote:
> Add a helper that connects an existing socket while invoking the LSM
> hook. Reuse it in __sys_connect_file() to avoid duplicating the connect
> logic. Other socket operations have equivalent helpers that trigger the
> appropriate LSM hooks that can be reused, this one was the only one
> missing.
>
> Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
> ---
> include/linux/socket.h | 2 ++
> net/socket.c | 32 ++++++++++++++++++--------------
> 2 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index 2a8d7b14f1d1..8964528e3823 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -461,6 +461,8 @@ 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 connect_socket(struct socket *sock, struct sockaddr_storage *addr,
> + int addrlen, int flags);
> 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,
> diff --git a/net/socket.c b/net/socket.c
> index 63c69a0fa74e..126a674f534d 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -2103,6 +2103,20 @@ SYSCALL_DEFINE3(accept, int, fd, struct sockaddr __user *, upeer_sockaddr,
> return __sys_accept4(fd, upeer_sockaddr, upeer_addrlen, 0);
> }
>
> +int connect_socket(struct socket *sock, struct sockaddr_storage *address,
> + int addrlen, int flags)
> +{
Please fix the checkpatch warning if revise
CHECK: extern prototypes should be avoided in .h files
#27: FILE: include/linux/socket.h:464:
+extern int connect_socket(struct socket *sock, struct sockaddr_storage
*addr,
CHECK: Alignment should match open parenthesis
#28: FILE: include/linux/socket.h:465:
+extern int connect_socket(struct socket *sock, struct sockaddr_storage
*addr,
+ int addrlen, int flags);
CHECK: Alignment should match open parenthesis
#41: FILE: net/socket.c:2107:
+int connect_socket(struct socket *sock, struct sockaddr_storage *address,
+ int addrlen, int flags)
next prev parent reply other threads:[~2026-08-07 1:54 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 18:22 [PATCH bpf-next v4 0/5] Introduce bpf_ksock Mahe Tardy
2026-08-06 18:22 ` [PATCH bpf-next v4 1/5] net: Add connect_socket() helper Mahe Tardy
2026-08-06 20:09 ` Song Liu
2026-08-07 1:53 ` Jiayuan Chen [this message]
2026-08-07 9:51 ` Mahe Tardy
2026-08-06 18:22 ` [PATCH bpf-next v4 2/5] bpf: Add ksock kfuncs Mahe Tardy
2026-08-07 3:08 ` Jiayuan Chen
2026-08-07 9:56 ` Mahe Tardy
2026-08-06 18:22 ` [PATCH bpf-next v4 3/5] selftests/bpf: Add ksock kfunc test Mahe Tardy
2026-08-07 9:12 ` Jiayuan Chen
2026-08-07 10:11 ` Mahe Tardy
2026-08-06 18:22 ` [PATCH bpf-next v4 4/5] selftests/bpf: Test forbidden bpf_ksock_send() LSM attach Mahe Tardy
2026-08-06 18:22 ` [PATCH bpf-next v4 5/5] selftests/bpf: Add ksock test for async callback guard Mahe Tardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05084a53-a1a4-4e60-bdd7-6fd16ef6a029@linux.dev \
--to=jiayuan.chen@linux.dev \
--cc=ameryhung@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=liamwisehart@meta.com \
--cc=mahe.tardy@gmail.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf.kernel@gmail.com \
--cc=song@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox