-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpf: fix wrong copied_seq calculation and add tests #4742
Conversation
Upstream branch: e2cf913 |
74f8dce
to
a0d3fba
Compare
Upstream branch: e2cf913 |
1032f83
to
9cd063b
Compare
a0d3fba
to
e0813b9
Compare
Upstream branch: 509df67 |
9cd063b
to
b79c25b
Compare
e0813b9
to
d73b5d8
Compare
Upstream branch: 509df67 |
b79c25b
to
0b568da
Compare
d73b5d8
to
e8379c7
Compare
Upstream branch: 509df67 |
0b568da
to
909faec
Compare
e8379c7
to
909449e
Compare
Upstream branch: b5f2170 |
909faec
to
4f2360e
Compare
909449e
to
4ccd610
Compare
Upstream branch: fac04ef |
4f2360e
to
aa3b836
Compare
Upstream branch: fac04ef |
52b222e
to
7bf24ab
Compare
66d7830
to
e002993
Compare
Upstream branch: 78d4f34 |
7bf24ab
to
9d1922c
Compare
e002993
to
4ed2ef9
Compare
Upstream branch: 78d4f34 |
9d1922c
to
7a4d976
Compare
4ed2ef9
to
c61803a
Compare
Upstream branch: 2357901 |
7a4d976
to
f702cf0
Compare
c61803a
to
0970a9d
Compare
Upstream branch: 2357901 |
f702cf0
to
22a0a58
Compare
Upstream branch: 2357901 |
'sk->copied_seq' was updated in the tcp_eat_skb() function when the action of a BPF program was SK_REDIRECT. For other actions, like SK_PASS, the update logic for 'sk->copied_seq' was moved to tcp_bpf_recvmsg_parser() to ensure the accuracy of the 'fionread' feature. It works for a single stream_verdict scenario, as it also modified 'sk_data_ready->sk_psock_verdict_data_ready->tcp_read_skb' to remove updating 'sk->copied_seq'. However, for programs where both stream_parser and stream_verdict are active(strparser purpose), tcp_read_sock() was used instead of tcp_read_skb() (sk_data_ready->strp_data_ready->tcp_read_sock) tcp_read_sock() now still update 'sk->copied_seq', leading to duplicated updates. In summary, for strparser + SK_PASS, copied_seq is redundantly calculated in both tcp_read_sock() and tcp_bpf_recvmsg_parser(). The issue causes incorrect copied_seq calculations, which prevent correct data reads from the recv() interface in user-land. Modifying tcp_read_sock() or strparser implementation directly is unreasonable, as it is widely used in other modules. Here, we introduce a method tcp_bpf_read_sock() to replace 'sk->sk_socket->ops->read_sock' (like 'tls_build_proto()' does in tls_main.c). Such replacement action was also used in updating tcp_bpf_prots in tcp_bpf.c, so it's not weird. (Note that checkpatch.pl may complain missing 'const' qualifier when we define the bpf-specified 'proto_ops', but we have to do because we need update it). Also we remove strparser check in tcp_eat_skb() since we implement custom function tcp_bpf_read_sock() without copied_seq updating. Since strparser currently supports only TCP, it's sufficient for 'ops' to inherit inet_stream_ops. Fixes: e5c6de5 ("bpf, sockmap: Incorrectly handling copied_seq") Signed-off-by: Jiayuan Chen <[email protected]>
Add test cases for bpf + strparser and separated them from sockmap_basic. This is because we need to add more test cases for strparser in the future. Signed-off-by: Jiayuan Chen <[email protected]>
22a0a58
to
12e44fa
Compare
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=918986 expired. Closing PR. |
Pull request for series with
subject: bpf: fix wrong copied_seq calculation and add tests
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=914899