From: Paolo Abeni <pabeni@redhat.com>
To: Breno Leitao <leitao@debian.org>, Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: alex.aring@gmail.com, andrea.righi@canonical.com,
asml.silence@gmail.com, ast@kernel.org, axboe@kernel.dk,
courmisch@gmail.com, davem@davemloft.net, dccp@vger.kernel.org,
dsahern@kernel.org, edumazet@google.com, gnault@redhat.com,
hbh25y@gmail.com, joannelkoong@gmail.com,
kernelxing@tencent.com, kuba@kernel.org, leit@fb.com,
linux-kernel@vger.kernel.org, linux-sctp@vger.kernel.org,
linux-wpan@vger.kernel.org, lucien.xin@gmail.com,
marcelo.leitner@gmail.com, martin.lau@kernel.org,
martineau@kernel.org, matthieu.baerts@tessares.net,
miquel.raynal@bootlin.com, mptcp@lists.linux.dev,
netdev@vger.kernel.org, stefan@datenfreihafen.org,
willemdebruijn.kernel@gmail.com, wojciech.drewek@intel.com
Subject: Re: [PATCH net-next v6] net: ioctl: Use kernel memory on protocol ioctl callbacks
Date: Thu, 08 Jun 2023 15:57:48 +0200 [thread overview]
Message-ID: <5bd6ced877e97ac674d1308eab0b8d2107b7ab85.camel@redhat.com> (raw)
In-Reply-To: <ZIGUofpP4k24qfQs@gmail.com>
On Thu, 2023-06-08 at 01:43 -0700, Breno Leitao wrote:
> Hello Kuniyuki,
> On Wed, Jun 07, 2023 at 10:31:42AM -0700, Kuniyuki Iwashima wrote:
> > > +/* This is the most common ioctl prep function, where the result (4 bytes) is
> > > + * copied back to userspace if the ioctl() returns successfully. No input is
> > > + * copied from userspace as input argument.
> > > + */
> > > +static int sock_ioctl_out(struct sock *sk, unsigned int cmd, void __user *arg)
> > > +{
> > > + int ret, karg = 0;
> > > +
> > > + ret = sk->sk_prot->ioctl(sk, cmd, &karg);
> >
> > We need READ_ONCE(sk->sk_prot) as IPv4 conversion or ULP chnage could
> > occur at the same time.
>
> Thanks for the heads-up. I would like to pick you brain and understand
> a bit more about READ_ONCE() and what is the situation that READ_ONCE()
> will solve.
AFAICS, in this specific case READ_ONCE() should not address any "real"
bug causing visible issue.
Still the lack of it will likely cause syzkaller report for (harmless,
AFAICS) 'data races' around sk->sk_prot. We want to avoid such reports,
even if harmless, because they can end-up hiding more relevant bugs.
> Is the situation related to when sock_ioctl_out() start to execute, and
> "sk->sk_prot" changes in a different thread? If that is the case, the
> arguments (cmd and arg) will be from the "previous" instance.
>
> Also, grepping for "sk->sk_prot->", I see more than a bunch of calls
> that do not use READ_ONCE() barrier. Why is this case different?
Races on sk->sk_prot can happen only on inet6_stream_ops (due to ulp
and/or ADDRFORM) inet6_dgram_ops (due to ADDRFORM). AFAICS here
READ_ONCE() is needed as we can reach here via inet6_stream_ops-
>inet6_ioctl
Cheers,
Paolo
next prev parent reply other threads:[~2023-06-08 13:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-06 18:00 [PATCH net-next v6] net: ioctl: Use kernel memory on protocol ioctl callbacks Breno Leitao
2023-06-07 12:15 ` Willem de Bruijn
2023-06-07 14:45 ` David Ahern
2023-06-08 7:39 ` Ido Schimmel
2023-06-07 17:31 ` Kuniyuki Iwashima
2023-06-08 8:43 ` Breno Leitao
2023-06-08 13:57 ` Paolo Abeni [this message]
2023-06-08 14:35 ` Breno Leitao
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=5bd6ced877e97ac674d1308eab0b8d2107b7ab85.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=alex.aring@gmail.com \
--cc=andrea.righi@canonical.com \
--cc=asml.silence@gmail.com \
--cc=ast@kernel.org \
--cc=axboe@kernel.dk \
--cc=courmisch@gmail.com \
--cc=davem@davemloft.net \
--cc=dccp@vger.kernel.org \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=gnault@redhat.com \
--cc=hbh25y@gmail.com \
--cc=joannelkoong@gmail.com \
--cc=kernelxing@tencent.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=leit@fb.com \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=martin.lau@kernel.org \
--cc=martineau@kernel.org \
--cc=matthieu.baerts@tessares.net \
--cc=miquel.raynal@bootlin.com \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=stefan@datenfreihafen.org \
--cc=willemdebruijn.kernel@gmail.com \
--cc=wojciech.drewek@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).