Commit 0741be35 authored by Petar Penkov's avatar Petar Penkov Committed by Daniel Borkmann
Browse files

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: 70d66244 ("bpf: add bpf_tcp_gen_syncookie helper")
Reported-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarPetar Penkov <ppenkov@google.com>
Acked-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 736a5530
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);