* [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX.
@ 2026-02-03 21:30 Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 1/2] bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr() Kuniyuki Iwashima
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-03 21:30 UTC (permalink / raw)
To: Martin KaFai Lau, Daniel Borkmann
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, bpf
Patch 1 adapts sk_is_XXX() helpers in __cgroup_bpf_run_filter_sock_addr().
Patch 2 removes an unnecessary sk_fullsock() in bpf_skc_to_unix_sock().
Kuniyuki Iwashima (2):
bpf: Use sk_is_inet() and sk_is_unix() in
__cgroup_bpf_run_filter_sock_addr().
bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock().
kernel/bpf/cgroup.c | 6 +-----
net/core/filter.c | 2 +-
2 files changed, 2 insertions(+), 6 deletions(-)
--
2.53.0.rc2.204.g2597b5adb4-goog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v1 bpf-next 1/2] bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr().
2026-02-03 21:30 [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Kuniyuki Iwashima
@ 2026-02-03 21:30 ` Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 2/2] bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock() Kuniyuki Iwashima
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-03 21:30 UTC (permalink / raw)
To: Martin KaFai Lau, Daniel Borkmann
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, bpf
sk->sk_family should be read with READ_ONCE() in
__cgroup_bpf_run_filter_sock_addr() due to IPV6_ADDRFORM.
Also, the comment there is a bit stale since commit 859051dd165e
("bpf: Implement cgroup sockaddr hooks for unix sockets"), and the
kdoc has the same comment.
Let's use sk_is_inet() and sk_is_unix() and remove the comment.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
kernel/bpf/cgroup.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
index 69988af44b37..b029f0369ecf 100644
--- a/kernel/bpf/cgroup.c
+++ b/kernel/bpf/cgroup.c
@@ -1680,11 +1680,7 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
struct cgroup *cgrp;
int ret;
- /* Check socket family since not all sockets represent network
- * endpoint (e.g. AF_UNIX).
- */
- if (sk->sk_family != AF_INET && sk->sk_family != AF_INET6 &&
- sk->sk_family != AF_UNIX)
+ if (!sk_is_inet(sk) && !sk_is_unix(sk))
return 0;
if (!ctx.uaddr) {
--
2.53.0.rc2.204.g2597b5adb4-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 bpf-next 2/2] bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock().
2026-02-03 21:30 [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 1/2] bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr() Kuniyuki Iwashima
@ 2026-02-03 21:30 ` Kuniyuki Iwashima
2026-02-04 1:52 ` [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Stanislav Fomichev
2026-02-04 22:44 ` Martin KaFai Lau
3 siblings, 0 replies; 5+ messages in thread
From: Kuniyuki Iwashima @ 2026-02-03 21:30 UTC (permalink / raw)
To: Martin KaFai Lau, Daniel Borkmann
Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, bpf
AF_UNIX does not use TCP_NEW_SYN_RECV nor TCP_TIME_WAIT and
checking sk->sk_family is sufficient.
Let's remove sk_fullsock() and use sk_is_unix() in
bpf_skc_to_unix_sock().
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
net/core/filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/filter.c b/net/core/filter.c
index f04982d79d72..90bfe5a6c1db 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -12021,7 +12021,7 @@ BPF_CALL_1(bpf_skc_to_unix_sock, struct sock *, sk)
* trigger an explicit type generation here.
*/
BTF_TYPE_EMIT(struct unix_sock);
- if (sk && sk_fullsock(sk) && sk->sk_family == AF_UNIX)
+ if (sk && sk_is_unix(sk))
return (unsigned long)sk;
return (unsigned long)NULL;
--
2.53.0.rc2.204.g2597b5adb4-goog
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX.
2026-02-03 21:30 [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 1/2] bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr() Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 2/2] bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock() Kuniyuki Iwashima
@ 2026-02-04 1:52 ` Stanislav Fomichev
2026-02-04 22:44 ` Martin KaFai Lau
3 siblings, 0 replies; 5+ messages in thread
From: Stanislav Fomichev @ 2026-02-04 1:52 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: Martin KaFai Lau, Daniel Borkmann, Kuniyuki Iwashima, bpf
On 02/03, Kuniyuki Iwashima wrote:
> Patch 1 adapts sk_is_XXX() helpers in __cgroup_bpf_run_filter_sock_addr().
> Patch 2 removes an unnecessary sk_fullsock() in bpf_skc_to_unix_sock().
>
>
> Kuniyuki Iwashima (2):
> bpf: Use sk_is_inet() and sk_is_unix() in
> __cgroup_bpf_run_filter_sock_addr().
> bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock().
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX.
2026-02-03 21:30 [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Kuniyuki Iwashima
` (2 preceding siblings ...)
2026-02-04 1:52 ` [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Stanislav Fomichev
@ 2026-02-04 22:44 ` Martin KaFai Lau
3 siblings, 0 replies; 5+ messages in thread
From: Martin KaFai Lau @ 2026-02-04 22:44 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: Kuniyuki Iwashima, bpf, Daniel Borkmann, Network Development
On 2/3/26 1:30 PM, Kuniyuki Iwashima wrote:
> Patch 1 adapts sk_is_XXX() helpers in __cgroup_bpf_run_filter_sock_addr().
> Patch 2 removes an unnecessary sk_fullsock() in bpf_skc_to_unix_sock().
>
>
> Kuniyuki Iwashima (2):
> bpf: Use sk_is_inet() and sk_is_unix() in
> __cgroup_bpf_run_filter_sock_addr().
> bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock().
>
> kernel/bpf/cgroup.c | 6 +-----
> net/core/filter.c | 2 +-
The bot is slow. The change in filter.c is small and the cycle is
closing, so I have landed them to the bpf_next/master.
I just noticed the netdev list is not in cc, so added it here also.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-04 22:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 21:30 [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 1/2] bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr() Kuniyuki Iwashima
2026-02-03 21:30 ` [PATCH v1 bpf-next 2/2] bpf: Don't check sk_fullsock() in bpf_skc_to_unix_sock() Kuniyuki Iwashima
2026-02-04 1:52 ` [PATCH v1 bpf-next 0/2] bpf: Misc changes around AF_UNIX Stanislav Fomichev
2026-02-04 22:44 ` Martin KaFai Lau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox