diff mbox series

[PATHC,bpf,v5,2/3] selftests, bpf: Fix test_txmsg_ingress_parser error

Message ID 20211012065705.224643-2-liujian56@huawei.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [PATHC,bpf,v5,1/3] skmsg: lose offset info in sk_psock_skb_ingress | expand

Checks

Context Check Description
netdev/cover_letter warning Series does not have a cover letter
netdev/fixes_present success Fixes tag present in non-next series
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success No Fixes tag
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success No static functions without inline keyword in header files
bpf/vmtest-bpf-PR pending PR summary
bpf/vmtest-bpf pending VM_Test

Commit Message

Liu Jian Oct. 12, 2021, 6:57 a.m. UTC
After "skmsg: lose offset info in sk_psock_skb_ingress", the test case
with ktls failed. This because ktls parser(tls_read_size) return value
is 285 not 256.

the case like this:
	tls_sk1 --> redir_sk --> tls_sk2
tls_sk1 sent out 512 bytes data, after tls related processing redir_sk
recved 570 btyes data, and redirect 512 (skb_use_parser) bytes data to
tls_sk2; but tls_sk2 needs 285 * 2 bytes data, receive timeout occurred.

Signed-off-by: Liu Jian <liujian56@huawei.com>
---
 tools/testing/selftests/bpf/test_sockmap.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

John Fastabend Oct. 22, 2021, 3:22 p.m. UTC | #1
Liu Jian wrote:
> After "skmsg: lose offset info in sk_psock_skb_ingress", the test case
> with ktls failed. This because ktls parser(tls_read_size) return value
> is 285 not 256.
> 
> the case like this:
> 	tls_sk1 --> redir_sk --> tls_sk2
> tls_sk1 sent out 512 bytes data, after tls related processing redir_sk
> recved 570 btyes data, and redirect 512 (skb_use_parser) bytes data to
> tls_sk2; but tls_sk2 needs 285 * 2 bytes data, receive timeout occurred.
> 
> Signed-off-by: Liu Jian <liujian56@huawei.com>
> ---
>  tools/testing/selftests/bpf/test_sockmap.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> index eefd445b96fc..06924917ad77 100644
> --- a/tools/testing/selftests/bpf/test_sockmap.c
> +++ b/tools/testing/selftests/bpf/test_sockmap.c
> @@ -1680,6 +1680,8 @@ static void test_txmsg_ingress_parser(int cgrp, struct sockmap_options *opt)
>  {
>  	txmsg_pass = 1;
>  	skb_use_parser = 512;
> +	if (ktls == 1)
> +		skb_use_parser = 570;
>  	opt->iov_length = 256;
>  	opt->iov_count = 1;
>  	opt->rate = 2;
> -- 
> 2.17.1
> 

Hi Liu LGTM sorry about the delay there I thought I acked this already, but
guess now.

Acked-by: John Fastabend <john.fastabend@gmail.com>
Alexei Starovoitov Oct. 29, 2021, 1:40 a.m. UTC | #2
On Fri, Oct 22, 2021 at 8:22 AM John Fastabend <john.fastabend@gmail.com> wrote:
>
> Liu Jian wrote:
> > After "skmsg: lose offset info in sk_psock_skb_ingress", the test case
> > with ktls failed. This because ktls parser(tls_read_size) return value
> > is 285 not 256.
> >
> > the case like this:
> >       tls_sk1 --> redir_sk --> tls_sk2
> > tls_sk1 sent out 512 bytes data, after tls related processing redir_sk
> > recved 570 btyes data, and redirect 512 (skb_use_parser) bytes data to
> > tls_sk2; but tls_sk2 needs 285 * 2 bytes data, receive timeout occurred.
> >
> > Signed-off-by: Liu Jian <liujian56@huawei.com>
> > ---
> >  tools/testing/selftests/bpf/test_sockmap.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
> > index eefd445b96fc..06924917ad77 100644
> > --- a/tools/testing/selftests/bpf/test_sockmap.c
> > +++ b/tools/testing/selftests/bpf/test_sockmap.c
> > @@ -1680,6 +1680,8 @@ static void test_txmsg_ingress_parser(int cgrp, struct sockmap_options *opt)
> >  {
> >       txmsg_pass = 1;
> >       skb_use_parser = 512;
> > +     if (ktls == 1)
> > +             skb_use_parser = 570;
> >       opt->iov_length = 256;
> >       opt->iov_count = 1;
> >       opt->rate = 2;
> > --
> > 2.17.1
> >
>
> Hi Liu LGTM sorry about the delay there I thought I acked this already, but
> guess now.
>
> Acked-by: John Fastabend <john.fastabend@gmail.com>

Hmm.
patch 1 is causing a crash.

./test_progs -t sockmap
#124 sockmap_basic:OK
#125 sockmap_ktls:OK
[   15.391661] ==================================================================
[   15.392635] BUG: KASAN: null-ptr-deref in dst_release+0x1d/0x80
[   15.393337] Write of size 4 at addr 0000000000000042 by task test_progs/1358
[   15.394144]
[   15.394326] CPU: 3 PID: 1358 Comm: test_progs Tainted: G
O      5.15.0-rc3-01147-ge4bcff4e3384 #3617
[   15.395415] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996),
BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
[   15.396653] Call Trace:
[   15.396929]  <IRQ>
[   15.397163]  dump_stack_lvl+0x44/0x57
[   15.397569]  ? dst_release+0x1d/0x80
[   15.397970]  kasan_report.cold.15+0x66/0xdf
[   15.398430]  ? dst_release+0x1d/0x80
[   15.398824]  ? sk_psock_verdict_apply+0x149/0x460
[   15.399341]  kasan_check_range+0x1c1/0x1e0
[   15.399789]  ? sk_psock_verdict_apply+0x149/0x460
[   15.400308]  dst_release+0x1d/0x80
[   15.400679]  skb_release_head_state+0x100/0x170
[   15.401178]  skb_release_all+0xe/0x50
[   15.401580]  kfree_skb+0xa1/0x230
[   15.401957]  sk_psock_verdict_apply+0x149/0x460
[   15.402450]  ? bpf_sk_redirect_map+0x2b/0x1a0
[   15.402974]  sk_psock_strp_read+0x239/0x550
[   15.403452]  __strp_recv+0x4a7/0x1b70
[   15.403917]  tcp_read_sock+0x1d2/0x760
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c
index eefd445b96fc..06924917ad77 100644
--- a/tools/testing/selftests/bpf/test_sockmap.c
+++ b/tools/testing/selftests/bpf/test_sockmap.c
@@ -1680,6 +1680,8 @@  static void test_txmsg_ingress_parser(int cgrp, struct sockmap_options *opt)
 {
 	txmsg_pass = 1;
 	skb_use_parser = 512;
+	if (ktls == 1)
+		skb_use_parser = 570;
 	opt->iov_length = 256;
 	opt->iov_count = 1;
 	opt->rate = 2;