Thread (19 messages) 19 messages, 4 authors, 2022-02-01

Re: [PATCH bpf v2 4/4] bpf: Fix documentation of th_len in bpf_tcp_{gen,check}_syncookie

From: Lorenz Bauer <hidden>
Date: 2022-02-01 17:03:08
Also in: bpf

On Mon, 31 Jan 2022 at 13:38, Maxim Mikityanskiy [off-list ref] wrote:
On 2022-01-26 11:45, Lorenz Bauer wrote:
quoted
On Mon, 24 Jan 2022 at 15:13, Maxim Mikityanskiy [off-list ref] wrote:
quoted
bpf_tcp_gen_syncookie and bpf_tcp_check_syncookie expect the full length
of the TCP header (with all extensions). Fix the documentation that says
it should be sizeof(struct tcphdr).
I don't understand this change, sorry. Are you referring to the fact
that the check is len < sizeof(*th) instead of len != sizeof(*th)?

Your commit message makes me think that the helpers will access data
in the extension headers, which isn't true as far as I can tell.
Yes, they will. See bpf_tcp_gen_syncookie -> tcp_v4_get_syncookie ->
tcp_get_syncookie_mss -> tcp_parse_mss_option, which iterates over the
TCP options ("extensions" wasn't the best word I used here). Moreover,
bpf_tcp_gen_syncookie even checks that th_len == th->doff * 4.

Although bpf_tcp_check_syncookie doesn't need the TCP options and
doesn't enforce them to be passed, it's still allowed.
Sorry, I was only looking at bpf_tcp_check_syncookie indeed.
Unfortunate, it would be better if that function had a th->doff check
as well. :(

Acked-by: Lorenz Bauer <redacted>

-- 
Lorenz Bauer  |  Systems Engineer
6th Floor, County Hall/The Riverside Building, SE1 7PB, UK

www.cloudflare.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help