From: Martin KaFai Lau <kafai@fb.com>
To: <jchapman@katalix.com>, David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <gnault@redhat.com>
Subject: Re: [PATCH net] l2tp: add sk_reuseport checks to l2tp_validate_socket
Date: Tue, 7 Jul 2020 11:31:28 -0700 [thread overview]
Message-ID: <20200707183128.owsu62mnxp3k6lae@kafai-mbp> (raw)
In-Reply-To: <20200706.124536.774178117550894539.davem@davemloft.net>
On Mon, Jul 06, 2020 at 12:45:36PM -0700, David Miller wrote:
> From: James Chapman <jchapman@katalix.com>
> Date: Mon, 6 Jul 2020 13:12:59 +0100
>
> > The crash occurs in the socket destroy path. bpf_sk_reuseport_detach
> > assumes ownership of sk_user_data if sk_reuseport is set and writes a
> > NULL pointer to the memory pointed to by
> > sk_user_data. bpf_sk_reuseport_detach is called via
> > udp_lib_unhash. l2tp does its socket cleanup through sk_destruct,
> > which fetches private data through sk_user_data. The BUG_ON fires
> > because this data has been corrupted.
>
> The ownership of sk_user_data has to be handled more cleanly.
>
> BPF really has no business taking over this as it is for the protocols
> to use and what L2TP is doing is quite natural and normal. Exactly
> what sk_user_data was designed to be used for.
>
> I'm not applying this, please take this up with the BPF folks. They
> need to store their metadata elsewhere.
Thanks for the report.
The sk_user_data is used when a sk is added to the bpf's reuseport_sockarray.
Before it can be added, the bpf side does check if the sk_user_data has already been
used or not. It is the similar check like other usages on sk_user_data.
The missing part is the reuseport_detach_sock() should check if a
sk is currently in a reuseport_sockarray before calling bpf_sk_reuseport_detach().
It can be solved by remembering if a sk is added to the reuseport_sockarray.
I will work on a fix by doing this.
next prev parent reply other threads:[~2020-07-07 18:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-06 12:12 [PATCH net] l2tp: add sk_reuseport checks to l2tp_validate_socket James Chapman
2020-07-06 19:45 ` David Miller
2020-07-07 18:31 ` Martin KaFai Lau [this message]
2020-07-08 10:23 ` James Chapman
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=20200707183128.owsu62mnxp3k6lae@kafai-mbp \
--to=kafai@fb.com \
--cc=davem@davemloft.net \
--cc=gnault@redhat.com \
--cc=jchapman@katalix.com \
--cc=netdev@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox