diff options
| author | Mahe Tardy <mahe.tardy@gmail.com> | 2026-08-13 11:05:36 +0000 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2026-08-15 23:36:18 +0200 |
| commit | 5bd369c05576ec12f62f02c65b576bf0bf074131 (patch) | |
| tree | 1f1bffdb9f5b87cb8b111eeb191156bd67ce6e77 /include/linux | |
| parent | ce7c9f6c599b640c1be288fd1af3289d1406d559 (diff) | |
net: Add connect_socket() helper
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. This will be used in the next commit for a new BPF kfunc that
needs to connect a socket and trigger the LSM hook.
Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Acked-by: Song Liu <song@kernel.org>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://lore.kernel.org/bpf/20260813110540.103550-2-mahe.tardy@gmail.com
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/socket.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h index 2a8d7b14f1d1..5a5eb1250103 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); +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, |
