Skip to content

Commit

Permalink
bpf: fix error check in bpf_tcp_gen_syncookie
Browse files Browse the repository at this point in the history
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: 70d6624 ("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>
  • Loading branch information
Petar Penkov authored and Daniel Borkmann committed Aug 30, 2019
1 parent 736a553 commit 0741be3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/core/filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0741be3

Please sign in to comment.