linux-stable/include
Martin KaFai Lau 061ff04071 bpf: tcp: Stop bpf_setsockopt(TCP_CONGESTION) in init ops to recur itself
When a bad bpf prog '.init' calls
bpf_setsockopt(TCP_CONGESTION, "itself"), it will trigger this loop:

.init => bpf_setsockopt(tcp_cc) => .init => bpf_setsockopt(tcp_cc) ...
... => .init => bpf_setsockopt(tcp_cc).

It was prevented by the prog->active counter before but the prog->active
detection cannot be used in struct_ops as explained in the earlier
patch of the set.

In this patch, the second bpf_setsockopt(tcp_cc) is not allowed
in order to break the loop.  This is done by using a bit of
an existing 1 byte hole in tcp_sock to check if there is
on-going bpf_setsockopt(TCP_CONGESTION) in this tcp_sock.

Note that this essentially limits only the first '.init' can
call bpf_setsockopt(TCP_CONGESTION) to pick a fallback cc (eg. peer
does not support ECN) and the second '.init' cannot fallback to
another cc.  This applies even the second
bpf_setsockopt(TCP_CONGESTION) will not cause a loop.

Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20220929070407.965581-5-martin.lau@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2022-09-29 09:25:47 -07:00
..
acpi
asm-generic ftrace: Add HAVE_DYNAMIC_FTRACE_NO_PATCHABLE 2022-09-16 22:16:48 +02:00
clocksource
crypto
drm
dt-bindings
keys
kunit
kvm
linux bpf: tcp: Stop bpf_setsockopt(TCP_CONGESTION) in init ops to recur itself 2022-09-29 09:25:47 -07:00
math-emu
media
memory
misc
net bpf: Move nf_conn extern declarations to filter.h 2022-09-20 14:41:35 -07:00
pcmcia
ras
rdma
rv
scsi
soc soc: fsl: qbman: Add CGR update function 2022-09-05 14:27:39 +01:00
sound
target
trace
uapi bpf: Handle bpf_link_info for the parameterized task BPF iterators. 2022-09-28 16:29:55 -07:00
ufs
vdso
video
xen