]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, net: Avoid loading module when calling bpf_setsockopt(TCP_CONGESTION)
authorMartin KaFai Lau <martin.lau@linux.dev>
Tue, 30 Aug 2022 23:19:46 +0000 (16:19 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Wed, 31 Aug 2022 20:21:45 +0000 (22:21 +0200)
commit0fbe0a3a495362789a33c580e1c5686a57d5b341
tree3eb366755911c11a8e262a2aae1d68c569d25f36
parentacc71c5bdab824010bb8490ecbf2475073098335
bpf, net: Avoid loading module when calling bpf_setsockopt(TCP_CONGESTION)

When bpf prog changes tcp-cc by calling bpf_setsockopt(TCP_CONGESTION),
it should not try to load module which may be a blocking operation.
This details was correct in the v1 [0] but missed by mistake in the
later revision in commit abdbaeaf7b65 ("bpf: net: Change do_tcp_setsockopt()
to use the sockopt's lock_sock() and capable()"). This patch fixes it by
checking the has_current_bpf_ctx().

  [0] https://lore.kernel.org/bpf/20220727060921.2373314-1-kafai@fb.com/

Fixes: abdbaeaf7b65 ("bpf: net: Change do_tcp_setsockopt() to use the sockopt's lock_sock() and capable()")
Signed-off-by: Martin KaFai Lau <martin.lau@linux.dev>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220830231946.791504-1-martin.lau@linux.dev
net/ipv4/tcp.c