mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
bpf: tcp: Fix type confusion in sol_tcp_sockopt().
sol_tcp_sockopt() only checks if sk->sk_protocol is IPPROTO_TCP,
but RAW socket can bypass it:
socket(AF_INET, SOCK_RAW, IPPROTO_TCP)
Let's use sk_is_tcp().
Note that initially sol_tcp_sockopt() checked sk->sk_prot->setsockopt.
Fixes: 2ab42c7b87 ("bpf: Check the protocol of a sock to agree the calls to bpf_setsockopt().")
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/20260504210610.180150-7-kuniyu@google.com
This commit is contained in:
parent
843064b0a7
commit
1c2958e4ab
|
|
@ -5481,7 +5481,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
|
|||
char *optval, int *optlen,
|
||||
bool getopt)
|
||||
{
|
||||
if (sk->sk_protocol != IPPROTO_TCP)
|
||||
if (!sk_is_tcp(sk))
|
||||
return -EINVAL;
|
||||
|
||||
switch (optname) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user