From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <daan.j.demeyer@gmail.com>
Cc: <bpf@vger.kernel.org>, <kernel-team@meta.com>,
<martin.lau@linux.dev>, <netdev@vger.kernel.org>,
<kuniyu@amazon.com>
Subject: Re: [PATCH bpf-next v9 4/9] bpf: Implement cgroup sockaddr hooks for unix sockets
Date: Tue, 10 Oct 2023 10:17:52 -0700 [thread overview]
Message-ID: <20231010171752.7580-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20231006074530.892825-5-daan.j.demeyer@gmail.com>
From: Daan De Meyer <daan.j.demeyer@gmail.com>
Date: Fri, 6 Oct 2023 09:44:58 +0200
> These hooks allows intercepting connect(), getsockname(),
> getpeername(), sendmsg() and recvmsg() for unix sockets. The unix
> socket hooks get write access to the address length because the
> address length is not fixed when dealing with unix sockets and
> needs to be modified when a unix socket address is modified by
> the hook. Because abstract socket unix addresses start with a
> NUL byte, we cannot recalculate the socket address in kernelspace
> after running the hook by calculating the length of the unix socket
> path using strlen().
>
> These hooks can be used when users want to multiplex syscall to a
> single unix socket to multiple different processes behind the scenes
> by redirecting the connect() and other syscalls to process specific
> sockets.
>
> We do not implement support for intercepting bind() because when
> using bind() with unix sockets with a pathname address, this creates
> an inode in the filesystem which must be cleaned up. If we rewrite
> the address, the user might try to clean up the wrong file, leaking
> the socket in the filesystem where it is never cleaned up. Until we
> figure out a solution for this (and a use case for intercepting bind()),
> we opt to not allow rewriting the sockaddr in bind() calls.
>
> We also implement recvmsg() support for connected streams so that
> after a connect() that is modified by a sockaddr hook, any corresponding
> recmvsg() on the connected socket can also be modified to make the
> connected program think it is connected to the "intended" remote.
>
> Signed-off-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
next prev parent reply other threads:[~2023-10-10 17:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 7:44 [PATCH bpf-next v9 0/9] Add cgroup sockaddr hooks for unix sockets Daan De Meyer
2023-10-06 7:44 ` [PATCH bpf-next v9 1/9] selftests/bpf: Add missing section name tests for getpeername/getsockname Daan De Meyer
2023-10-06 7:44 ` [PATCH bpf-next v9 2/9] bpf: Propagate modified uaddrlen from cgroup sockaddr programs Daan De Meyer
2023-10-10 16:50 ` Kuniyuki Iwashima
2023-10-11 16:34 ` Daan De Meyer
2023-10-06 7:44 ` [PATCH bpf-next v9 3/9] bpf: Add bpf_sock_addr_set_unix_addr() to allow writing unix sockaddr from bpf Daan De Meyer
2023-10-10 17:00 ` Kuniyuki Iwashima
2023-10-10 20:07 ` Martin KaFai Lau
2023-10-10 20:20 ` Kuniyuki Iwashima
2023-10-06 7:44 ` [PATCH bpf-next v9 4/9] bpf: Implement cgroup sockaddr hooks for unix sockets Daan De Meyer
2023-10-10 17:17 ` Kuniyuki Iwashima [this message]
2023-10-06 7:44 ` [PATCH bpf-next v9 5/9] libbpf: Add support for cgroup unix socket address hooks Daan De Meyer
2023-10-06 7:45 ` [PATCH bpf-next v9 6/9] bpftool: " Daan De Meyer
2023-10-06 7:45 ` [PATCH bpf-next v9 7/9] documentation/bpf: Document " Daan De Meyer
2023-10-06 7:45 ` [PATCH bpf-next v9 8/9] selftests/bpf: Make sure mount directory exists Daan De Meyer
2023-10-06 7:45 ` [PATCH bpf-next v9 9/9] selftests/bpf: Add tests for cgroup unix socket address hooks Daan De Meyer
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=20231010171752.7580-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=bpf@vger.kernel.org \
--cc=daan.j.demeyer@gmail.com \
--cc=kernel-team@meta.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.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;
as well as URLs for NNTP newsgroup(s).