bpf: check NULL for sk_to_full_sk() return value
Subsystems (4)
PATCH 1/1 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 40304b2a1567 ("bpf: BPF support for sock_ops")
Reported-by David Ahern <[email protected]>
Tested-by David Ahern <[email protected]>
Cc Lawrence Brakmo <[email protected]>
Cc Daniel Borkmann <[email protected]>
Signed-off-by Cong Wang <[email protected]>
--- include/linux/bpf-cgroup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bpf-cgroup.h +1 -1
@@ -85,7 +85,7 @@ int __cgroup_bpf_run_filter_sock_ops(struct sock *sk,int __ret =0 ; \if (cgroup_bpf_enabled && (sock_ops)->sk) { \typeof (sk) __sk =sk_to_full_sk ((sock_ops)->sk); \ -if (sk_fullsock (__sk)) \ +if (__sk &&sk_fullsock (__sk)) \ __ret =__cgroup_bpf_run_filter_sock_ops (__sk, \ sock_ops, \BPF_CGROUP_SOCK_OPS ); \
Signature · 1 line
2.13.0
Quoted 10 lines · Cong Wang
When
req->rsk_listeneris NULL,sk_to_full_sk()returns NULL too, so we have to check its return value against NULL here.Fixes 40304b2a1567 ("bpf: BPF support for sock_ops")Reported-by David Ahern <[email protected]>Tested-by David Ahern <[email protected]>Cc Lawrence Brakmo <[email protected]>Cc Daniel Borkmann <[email protected]>Signed-off-by Cong Wang <[email protected]>
Acked-by Daniel Borkmann <[email protected]>
From: Cong Wang <[email protected]>
Date: Mon, 17 Jul 2017 11:42:55 -0700
Quoted 10 lines
When
req->rsk_listeneris NULL,sk_to_full_sk()returns NULL too, so we have to check its return value against NULL here.Fixes 40304b2a1567 ("bpf: BPF support for sock_ops")Reported-by David Ahern <[email protected]>Tested-by David Ahern <[email protected]>Cc Lawrence Brakmo <[email protected]>Cc Daniel Borkmann <[email protected]>Signed-off-by Cong Wang <[email protected]>
Applied, thanks.