From: Geliang Tang <geliang@kernel.org>
To: John Fastabend <john.fastabend@gmail.com>
Cc: Jakub Sitnicki <jakub@cloudflare.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
David Ahern <dsahern@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Mykola Lysenko <mykolal@fb.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>,
Eric Dumazet <edumazet@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
Mykyta Yatsenko <yatsenko@meta.com>, Miao Xu <miaxu@meta.com>,
Yuran Pereira <yuran.pereira@hotmail.com>,
Huacai Chen <chenhuacai@kernel.org>,
Tiezhu Yang <yangtiezhu@loongson.cn>,
Geliang Tang <tanggeliang@kylinos.cn>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 1/4] skmsg: null check for sg_page in sk_msg_recvmsg
Date: Wed, 26 Jun 2024 21:05:44 +0800 [thread overview]
Message-ID: <c94c939ffe846c7f86daaddaef8661cdfe3f0b8f.camel@kernel.org> (raw)
In-Reply-To: <667b1c8325bf1_54242089e@john.notmuch>
On Tue, 2024-06-25 at 12:37 -0700, John Fastabend wrote:
> Eric Dumazet wrote:
> > On Tue, Jun 25, 2024 at 10:25 AM Geliang Tang <geliang@kernel.org>
> > wrote:
> > >
> > > From: Geliang Tang <tanggeliang@kylinos.cn>
> > >
> > > Run the following BPF selftests on Loongarch:
> > >
> > > ./test_progs -t sockmap_basic
> > >
> > > A Kernel panic occurs:
> > >
> > > '''
> > > Oops[#1]:
> > > CPU: 22 PID: 2824 Comm: test_progs Tainted: G OE
> > > 6.10.0-rc2+ #18
> > > Hardware name: LOONGSON Dabieshan/Loongson-TC542F0, BIOS
> > > Loongson-UDK2018-V4.0.11
> > > pc 9000000004162774 ra 90000000048bf6c0 tp 90001000aa16c000 sp
> > > 90001000aa16fb90
> > > a0 0000000000000000 a1 0000000000000000 a2 0000000000000000 a3
> > > 90001000aa16fd70
> > > a4 0000000000000800 a5 0000000000000000 a6 000055557b63aae8 a7
> > > 00000000000000cf
> > > t0 0000000000000000 t1 0000000000004000 t2 0000000000000048 t3
> > > 0000000000000000
> > > t4 0000000000000001 t5 0000000000000002 t6 0000000000000001 t7
> > > 0000000000000002
> > > t8 0000000000000018 u0 9000000004856150 s9 0000000000000000 s0
> > > 0000000000000000
> > > s1 0000000000000000 s2 90001000aa16fd70 s3 0000000000000000 s4
> > > 0000000000000000
> > > s5 0000000000004000 s6 900010009284dc00 s7 0000000000000001 s8
> > > 900010009284dc00
> > > ra: 90000000048bf6c0 sk_msg_recvmsg+0x120/0x560
> > > ERA: 9000000004162774 copy_page_to_iter+0x74/0x1c0
> > > CRMD: 000000b0 (PLV0 -IE -DA +PG DACF=CC DACM=CC -WE)
> > > PRMD: 0000000c (PPLV0 +PIE +PWE)
> > > EUEN: 00000007 (+FPE +SXE +ASXE -BTE)
> > > ECFG: 00071c1d (LIE=0,2-4,10-12 VS=7)
> > > ESTAT: 00010000 [PIL] (IS= ECode=1 EsubCode=0)
> > > BADV: 0000000000000040
> > > PRID: 0014c011 (Loongson-64bit, Loongson-3C5000)
> > > Modules linked in: bpf_testmod(OE) xt_CHECKSUM xt_MASQUERADE
> > > xt_conntrack
> > > Process test_progs (pid: 2824, threadinfo=0000000000863a31,
> > > task=000000001cba0874)
> > > Stack : 0000000000000001 fffffffffffffffc 0000000000000000
> > > 0000000000000000
> > > 0000000000000018 0000000000000000 0000000000000000
> > > 90000000048bf6c0
> > > 90000000052cd638 90001000aa16fd70 900010008bf51580
> > > 900010009284f000
> > > 90000000049f2b90 900010009284f188 900010009284f178
> > > 90001000861d4780
> > > 9000100084dccd00 0000000000000800 0000000000000007
> > > fffffffffffffff2
> > > 000000000453e92f 90000000049aae34 90001000aa16fd60
> > > 900010009284f000
> > > 0000000000000000 0000000000000000 900010008bf51580
> > > 90000000049f2b90
> > > 0000000000000001 0000000000000000 9000100084dc3a10
> > > 900010009284f1ac
> > > 90001000aa16fd40 0000555559953278 0000000000000001
> > > 0000000000000000
> > > 90001000aa16fdc8 9000000005a5a000 90001000861d4780
> > > 0000000000000800
> > > ...
> > > Call Trace:
> > > [<9000000004162774>] copy_page_to_iter+0x74/0x1c0
> > > [<90000000048bf6c0>] sk_msg_recvmsg+0x120/0x560
> > > [<90000000049f2b90>] tcp_bpf_recvmsg_parser+0x170/0x4e0
> > > [<90000000049aae34>] inet_recvmsg+0x54/0x100
> > > [<900000000481ad5c>] sock_recvmsg+0x7c/0xe0
> > > [<900000000481e1a8>] __sys_recvfrom+0x108/0x1c0
> > > [<900000000481e27c>] sys_recvfrom+0x1c/0x40
> > > [<9000000004c076ec>] do_syscall+0x8c/0xc0
> > > [<9000000003731da4>] handle_syscall+0xc4/0x160
> > >
> > > Code: 0010b09b 440125a0 0011df8d <28c10364> 0012b70c
> > > 00133305 0013b1ac 0010dc84 00151585
> > >
> > > ---[ end trace 0000000000000000 ]---
> > > Kernel panic - not syncing: Fatal exception
> > > Kernel relocated by 0x3510000
> > > .text @ 0x9000000003710000
> > > .data @ 0x9000000004d70000
> > > .bss @ 0x9000000006469400
> > > ---[ end Kernel panic - not syncing: Fatal exception ]---
> > > '''
> > >
> > > This is because "sg_page(sge)" is NULL in that case. This patch
> > > adds null
> > > check for it in sk_msg_recvmsg() to fix this error.
> > >
> > > Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg
> > > interface")
> > > Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
> > > ---
> > > net/core/skmsg.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> > > index fd20aae30be2..bafcc1e2eadf 100644
> > > --- a/net/core/skmsg.c
> > > +++ b/net/core/skmsg.c
> > > @@ -432,6 +432,8 @@ int sk_msg_recvmsg(struct sock *sk, struct
> > > sk_psock *psock, struct msghdr *msg,
> > > sge = sk_msg_elem(msg_rx, i);
> > > copy = sge->length;
> > > page = sg_page(sge);
> > > + if (!page)
> > > + goto out;
> > > if (copied + copy > len)
> > > copy = len - copied;
> > > copy = copy_page_to_iter(page, sge-
> > > >offset, copy, iter);
> > > --
> > > 2.43.0
> > >
> >
> > This looks pretty much random to me.
> >
> > Please find the root cause, instead of desperately trying to fix
> > 'tests'.
>
> If this happens then either we put a bad msg_rx on the queue see a
> few lines
> up and we need to sort out why that msg_rx was built. Or we walked
> off the
> end of a scatter gather list and need to see why this test isn't
> sufficient?
>
> } while ((i != msg_rx->sg.end) && !sg_is_last(sge))
>
> is this happening every time you run the command or did you run this
> for
> a long iteration and eventually hit this? I don't see why this would
> be
This happens every time when run test_sockmap_skb_verdict_shutdown test
in sockmap_basic. It hits this null page case on X86_64 platform too.
> specific to your arch though.
Kernel panics when a null page is passed to kmap_local_page() on
Loongarch only, and this function is an arch specific one. I think this
issue is somehow related to Loongarch's memory management.
Thanks,
-Geliang
next prev parent reply other threads:[~2024-06-26 13:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-25 8:24 [PATCH bpf-next v2 0/4] Fixes for BPF selftests on Loongarch Geliang Tang
2024-06-25 8:24 ` [PATCH bpf-next v2 1/4] skmsg: null check for sg_page in sk_msg_recvmsg Geliang Tang
2024-06-25 8:33 ` Eric Dumazet
2024-06-25 19:37 ` John Fastabend
2024-06-26 13:05 ` Geliang Tang [this message]
2024-06-27 7:38 ` Geliang Tang
2024-06-25 8:24 ` [PATCH bpf-next v2 2/4] skmsg: null check for sg_page in sk_msg_memcopy_from_iter Geliang Tang
2024-06-25 8:24 ` [PATCH bpf-next v2 3/4] inet: null check for close in inet_release Geliang Tang
2024-06-25 8:31 ` Eric Dumazet
2024-06-25 8:24 ` [PATCH bpf-next v2 4/4] selftests/bpf: Null checks for link in bpf_tcp_ca Geliang Tang
2024-06-25 8:29 ` [PATCH bpf-next v2 0/4] Fixes for BPF selftests on Loongarch Huacai Chen
2024-06-25 9:08 ` Geliang Tang
2024-06-25 9:14 ` Huacai Chen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c94c939ffe846c7f86daaddaef8661cdfe3f0b8f.camel@kernel.org \
--to=geliang@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chenhuacai@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=haoluo@google.com \
--cc=jakub@cloudflare.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=miaxu@meta.com \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@google.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=tanggeliang@kylinos.cn \
--cc=yangtiezhu@loongson.cn \
--cc=yatsenko@meta.com \
--cc=yonghong.song@linux.dev \
--cc=yuran.pereira@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.