Skip to content

Commit f065813

Browse files
q2venMartin KaFai Lau
authored andcommitted
bpf: Use sk_is_inet() and sk_is_unix() in __cgroup_bpf_run_filter_sock_addr().
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 859051d ("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. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Link: https://patch.msgid.link/20260203213442.682838-2-kuniyu@google.com
1 parent b28dac3 commit f065813

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

kernel/bpf/cgroup.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,11 +1680,7 @@ int __cgroup_bpf_run_filter_sock_addr(struct sock *sk,
16801680
struct cgroup *cgrp;
16811681
int ret;
16821682

1683-
/* Check socket family since not all sockets represent network
1684-
* endpoint (e.g. AF_UNIX).
1685-
*/
1686-
if (sk->sk_family != AF_INET && sk->sk_family != AF_INET6 &&
1687-
sk->sk_family != AF_UNIX)
1683+
if (!sk_is_inet(sk) && !sk_is_unix(sk))
16881684
return 0;
16891685

16901686
if (!ctx.uaddr) {

0 commit comments

Comments
 (0)