History

bpf: tcp: Fix type confusion in bpf_skc_to_tcp6_sock().

bpf_skc_to_tcp6_sock() only checks if sk->sk_protocol is IPPROTO_TCP and sk->sk_family is AF_INET6, but RAW socket can bypass it: socket(AF_INET6, SOCK_RAW, IPPROTO_TCP) Let's check sk->sk_type too.

Kuniyuki Iwashima committed 6 months ago

Commit 843064b1 parent decb84b1 file · +1 −1Browse files

Unified · Split

net/core/filter.c+1−1
@@ -11947,7 +11947,7 @@ BPF_CALL_1(bpf_skc_to_tcp6_sock, struct sock *, sk) · 11946 unmodified lines
1194711947 */
1194811948 BTF_TYPE_EMIT(struct tcp6_sock);
1194911949 if (sk && sk_fullsock(sk) && sk->sk_protocol == IPPROTO_TCP &&
11950− sk->sk_family == AF_INET6)
11950+ sk->sk_type == SOCK_STREAM && sk->sk_family == AF_INET6)
1195111951 return (unsigned long)sk;
1195211952
1195311953 return (unsigned long)NULL;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t