Skip to content

Commit 1c2958e

Browse files
q2venMartin KaFai Lau
authored andcommitted
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: 2ab42c7 ("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
1 parent 843064b commit 1c2958e

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5481,7 +5481,7 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
54815481
char *optval, int *optlen,
54825482
bool getopt)
54835483
{
5484-
if (sk->sk_protocol != IPPROTO_TCP)
5484+
if (!sk_is_tcp(sk))
54855485
return -EINVAL;
54865486

54875487
switch (optname) {

0 commit comments

Comments
 (0)