From: Petar Penkov Date: Tue, 27 Aug 2019 23:46:22 +0000 (-0700) Subject: bpf: fix error check in bpf_tcp_gen_syncookie X-Git-Tag: v5.15~5506^2~62^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0741be358d5adc266244f909e4434fe17fe1a109;p=platform%2Fkernel%2Flinux-starfive.git bpf: fix error check in bpf_tcp_gen_syncookie If a SYN cookie is not issued by tcp_v#_gen_syncookie, then the return value will be exactly 0, rather than <= 0. Let's change the check to reflect that, especially since mss is an unsigned value and cannot be negative. Fixes: 70d66244317e ("bpf: add bpf_tcp_gen_syncookie helper") Reported-by: Stanislav Fomichev Signed-off-by: Petar Penkov Acked-by: Song Liu Signed-off-by: Daniel Borkmann --- diff --git a/net/core/filter.c b/net/core/filter.c index 0c1059c..17bc9af 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -5903,7 +5903,7 @@ BPF_CALL_5(bpf_tcp_gen_syncookie, struct sock *, sk, void *, iph, u32, iph_len, default: return -EPROTONOSUPPORT; } - if (mss <= 0) + if (mss == 0) return -ENOENT; return cookie | ((u64)mss << 32);