Skip to content

Commit df39a9f

Browse files
congwangdavem330
authored andcommitted
bpf: check NULL for sk_to_full_sk() return value
When req->rsk_listener is NULL, sk_to_full_sk() returns NULL too, so we have to check its return value against NULL here. Fixes: 40304b2 ("bpf: BPF support for sock_ops") Reported-by: David Ahern <dsahern@gmail.com> Tested-by: David Ahern <dsahern@gmail.com> Cc: Lawrence Brakmo <brakmo@fb.com> Cc: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 13c401f commit df39a9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/bpf-cgroup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int __cgroup_bpf_run_filter_sock_ops(struct sock *sk,
8585
int __ret = 0; \
8686
if (cgroup_bpf_enabled && (sock_ops)->sk) { \
8787
typeof(sk) __sk = sk_to_full_sk((sock_ops)->sk); \
88-
if (sk_fullsock(__sk)) \
88+
if (__sk && sk_fullsock(__sk)) \
8989
__ret = __cgroup_bpf_run_filter_sock_ops(__sk, \
9090
sock_ops, \
9191
BPF_CGROUP_SOCK_OPS); \

0 commit comments

Comments
 (0)