Files
linux/include/linux
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
..
2022-04-20 12:59:50 +05:30
2022-05-22 20:44:29 +01:00
2022-03-23 19:58:38 +01:00
2022-06-30 13:40:35 +01:00
2022-07-05 20:25:39 +02:00
2022-07-14 12:14:30 -06:00
2022-06-28 10:37:25 -03:00
2022-07-01 14:53:01 +02:00
2022-06-03 06:52:57 -07:00
2022-08-31 14:57:28 +01:00
2022-06-09 21:53:09 -07:00
2022-06-09 21:53:12 -07:00
2022-06-09 21:53:09 -07:00
2022-06-27 06:29:12 -06:00
2022-06-29 17:42:28 -07:00
2022-07-17 17:31:38 -07:00
2022-05-02 14:06:20 -06:00
2022-05-03 16:09:03 -04:00
2022-06-19 10:38:26 +01:00
2022-07-27 14:04:52 +02:00
2022-08-28 14:02:44 -07:00
2022-04-28 23:16:14 -07:00
2022-07-29 18:07:19 -07:00
2022-08-02 12:34:04 -04:00
2022-04-28 16:31:10 +02:00
2022-09-02 12:41:43 +01:00
2022-08-22 14:26:30 +01:00
2022-05-17 13:32:46 -04:00
2022-08-09 14:11:34 -04:00
2022-07-29 20:16:58 -04:00
2022-07-01 16:38:35 -06:00
2022-09-05 14:30:42 +01:00
2022-03-23 19:58:41 +01:00
2022-05-22 21:03:01 +01:00
2022-04-07 12:53:54 +02:00
2022-06-27 14:41:31 +02:00
2022-05-08 01:33:08 -07:00
2022-04-11 19:18:27 -06:00
2022-03-22 15:57:11 -07:00
2022-08-08 22:37:24 -04:00
2022-08-11 04:31:14 -04:00
2022-06-13 09:54:52 -07:00
2022-07-10 21:17:30 -04:00