[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <61efa1032e925_274ca208fb@john.notmuch>
Date: Mon, 24 Jan 2022 23:04:35 -0800
From: John Fastabend <john.fastabend@...il.com>
To: Maxim Mikityanskiy <maximmi@...dia.com>, bpf@...r.kernel.org,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>, netdev@...r.kernel.org
Cc: Tariq Toukan <tariqt@...dia.com>, Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Petar Penkov <ppenkov@...gle.com>,
Lorenz Bauer <lmb@...udflare.com>,
Eric Dumazet <edumazet@...gle.com>,
Maxim Mikityanskiy <maximmi@...dia.com>
Subject: RE: [PATCH bpf v2 2/4] bpf: Support dual-stack sockets in
bpf_tcp_check_syncookie
Maxim Mikityanskiy wrote:
> bpf_tcp_gen_syncookie looks at the IP version in the IP header and
> validates the address family of the socket. It supports IPv4 packets in
> AF_INET6 dual-stack sockets.
>
> On the other hand, bpf_tcp_check_syncookie looks only at the address
> family of the socket, ignoring the real IP version in headers, and
> validates only the packet size. This implementation has some drawbacks:
>
> 1. Packets are not validated properly, allowing a BPF program to trick
> bpf_tcp_check_syncookie into handling an IPv6 packet on an IPv4
> socket.
These programs are all CAP_NET_ADMIN I believe so not so sure this is
critical from a BPF program might trick the helper, but consistency
is nice.
>
> 2. Dual-stack sockets fail the checks on IPv4 packets. IPv4 clients end
> up receiving a SYNACK with the cookie, but the following ACK gets
> dropped.
Agree we need to fix this. Also would be nice to add a test to capture
this case so we don't break it again later. Its a bit subtle so might
not be caught right away without a selftest.
>
> This patch fixes these issues by changing the checks in
> bpf_tcp_check_syncookie to match the ones in bpf_tcp_gen_syncookie. IP
> version from the header is taken into account, and it is validated
> properly with address family.
Code looks good, would be nice to have a test.
Acked-by: John Fastabend <john.fastabend@...il.com>
>
> Fixes: 399040847084 ("bpf: add helper to check for a valid SYN cookie")
> Signed-off-by: Maxim Mikityanskiy <maximmi@...dia.com>
> Reviewed-by: Tariq Toukan <tariqt@...dia.com>
> ---
> net/core/filter.c | 17 +++++++++++++----
Powered by blists - more mailing lists