netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <edumazet@google.com>
Cc: <davem@davemloft.net>, <dsahern@kernel.org>, <kuba@kernel.org>,
	<kuniyu@amazon.com>, <linux-kernel@vger.kernel.org>,
	<netdev@vger.kernel.org>, <pabeni@redhat.com>,
	<threeearcat@gmail.com>
Subject: Re: general protection fault in raw_seq_start
Date: Fri, 31 Mar 2023 00:17:25 -0700	[thread overview]
Message-ID: <20230331071725.66950-1-kuniyu@amazon.com> (raw)
In-Reply-To: <CANn89iK5D75-SNg28ALi4Zr9JEHnreBpfu_pq0_zLe4jDLT5rw@mail.gmail.com>

From:   Eric Dumazet <edumazet@google.com>
Date:   Fri, 31 Mar 2023 09:04:47 +0200
> On Thu, Mar 30, 2023 at 11:55 PM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
> 
> > Thanks for reporting the issue.
> >
> > It seems we need to use RCU variant in raw_get_first().
> > I'll post a patch.
> >
> > ---
> > diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
> > index 3cf68695b40d..fe0d1ad20b35 100644
> > --- a/net/ipv4/raw.c
> > +++ b/net/ipv4/raw.c
> > @@ -957,7 +957,7 @@ static struct sock *raw_get_first(struct seq_file *seq, int bucket)
> >         for (state->bucket = bucket; state->bucket < RAW_HTABLE_SIZE;
> >                         ++state->bucket) {
> >                 hlist = &h->ht[state->bucket];
> > -               sk_nulls_for_each(sk, hnode, hlist) {
> > +               sk_nulls_for_each_rcu(sk, hnode, hlist) {
> >                         if (sock_net(sk) == seq_file_net(seq))
> >                                 return sk;
> >
> 
> No, we do not want this.
> You missed that sk_nulls_for_each_rcu() needs a specific protocol
> (see Documentation/RCU/rculist_nulls.rst for details)

Ah, exactly SOCK_RAW does not have SLAB_TYPESAFE_BY_RCU.
Thank you for pointing this out!

And I found this seems wrong.

c25b7a7a565e ("inet: ping: use hlist_nulls rcu iterator during lookup")

> 
> RCU is needed in the data path, not for this control path.
> 
> My patch went too far in the RCU conversion. I did not think about
> syzbot harassing /proc files :)
> 
> We need raw_seq_start and friends to go back to use the lock.

Ok, then I'll change /proc/net/{raw, icmp} to use spinlock :)

  reply	other threads:[~2023-03-31  7:17 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-26 12:12 general protection fault in raw_seq_start Dae R. Jeong
2023-03-30 21:55 ` Kuniyuki Iwashima
2023-03-31  5:31   ` Jason Xing
2023-03-31  7:04   ` Eric Dumazet
2023-03-31  7:17     ` Kuniyuki Iwashima [this message]
2023-03-31 10:36       ` Florian Westphal
  -- strict thread matches above, loose matches on Subject: below --
2023-03-31  5:40 Iwashima, Kuniyuki
2023-03-31  6:14 ` Jason Xing

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=20230331071725.66950-1-kuniyu@amazon.com \
    --to=kuniyu@amazon.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=threeearcat@gmail.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).