summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin KaFai Lau <martin.lau@kernel.org>2026-02-04 09:35:06 -0800
committerMartin KaFai Lau <martin.lau@kernel.org>2026-02-04 09:36:10 -0800
commit78a16058e4250daff763c14c3ee76e7830b4fb2e (patch)
treeeb3d2fc4d42d5f1b9433d015e3f037d12892d3d8
parentb28dac3fc99bb6f1d0b029f1b742a96e7bc797d6 (diff)
parentc26b098bf42c71111ca976ce330ea5c66b9a5d8e (diff)
downloadlinux-78a16058e4250daff763c14c3ee76e7830b4fb2e.tar.gz
linux-78a16058e4250daff763c14c3ee76e7830b4fb2e.zip
Merge branch 'bpf-misc-changes-around-af_unix'
Kuniyuki Iwashima says: ==================== bpf: Misc changes around AF_UNIX. 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(). ==================== Link: https://patch.msgid.link/20260203213442.682838-1-kuniyu@google.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
-rw-r--r--kernel/bpf/cgroup.c6
-rw-r--r--net/core/filter.c2
2 files changed, 2 insertions, 6 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) {
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;