netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Eric Dumazet <edumazet@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net] macsec: avoid use-after-free in macsec_handle_frame()
Date: Wed, 07 Oct 2020 16:45:51 +0200	[thread overview]
Message-ID: <e9c835401b45da48559f4f0c9347b60c2b9c0911.camel@redhat.com> (raw)
In-Reply-To: <CANn89iLcZit_0Og9MbW0x0bQ=-6pz18UpRN6RYOY12Czui1eMQ@mail.gmail.com>

On Wed, 2020-10-07 at 16:31 +0200, Eric Dumazet wrote:
> On Wed, Oct 7, 2020 at 4:09 PM Paolo Abeni <pabeni@redhat.com> wrote:
> > Hi,
> > 
> > On Wed, 2020-10-07 at 01:42 -0700, Eric Dumazet wrote:
> > > @@ -1232,9 +1233,10 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
> > >       macsec_rxsc_put(rx_sc);
> > > 
> > >       skb_orphan(skb);
> > > +     len = skb->len;
> > >       ret = gro_cells_receive(&macsec->gro_cells, skb);
> > >       if (ret == NET_RX_SUCCESS)
> > > -             count_rx(dev, skb->len);
> > > +             count_rx(dev, len);
> > >       else
> > >               macsec->secy.netdev->stats.rx_dropped++;
> > 
> > I'm sorry I'm low on coffee, but I can't see the race?!? here we are in
> > a BH section, and the above code dereference the skb only if it's has
> > been enqueued into the gro_cells napi. It could be dequeued/dropped
> > only after we leave this section ?!?
> 
> We should think of this as an alias for napi_gro_receive(), and not
> make any assumptions.
> Semantically the skb has been given to another layer.
> netif_rx() can absolutely queue the skb to another cpu backlog (RPS,
> RFS...), and the other cpu might have consumed the skb right away.

Ah! I completely missed that code path in gro_cells_receive()!
Thank you for pointing that out!

Acked-by: Paolo Abeni <pabeni@redhat.com>


  reply	other threads:[~2020-10-07 14:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-07  8:42 [PATCH net] macsec: avoid use-after-free in macsec_handle_frame() Eric Dumazet
2020-10-07 14:09 ` Paolo Abeni
2020-10-07 14:31   ` Eric Dumazet
2020-10-07 14:45     ` Paolo Abeni [this message]
2020-10-07 15:54       ` Eric Dumazet
2020-10-08 20:00 ` patchwork-bot+netdevbpf

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=e9c835401b45da48559f4f0c9347b60c2b9c0911.camel@redhat.com \
    --to=pabeni@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.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;
as well as URLs for NNTP newsgroup(s).