bpf: fix error check in bpf_tcp_gen_syncookie
authorPetar Penkov <ppenkov@google.com>
Tue, 27 Aug 2019 23:46:22 +0000 (16:46 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Fri, 30 Aug 2019 22:58:06 +0000 (00:58 +0200)
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 <sdf@google.com>
Signed-off-by: Petar Penkov <ppenkov@google.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
net/core/filter.c

index 0c1059cdad3d224f555b2d0259da1cd6ddd0552e..17bc9af8f15636e1d16822fd50365a59ddb19617 100644 (file)
@@ -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);