linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zheyu Ma <zheyuma97@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: nicolas.ferre@microchip.com, claudiu.beznea@microchip.com,
	netdev@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [BUG] net: macb: Use-After-Free when removing the module
Date: Sat, 5 Mar 2022 22:11:48 +0800	[thread overview]
Message-ID: <CAMhUBjm9+nt8j0JFwHEms2Ra1YjhAXquVyHuDYX0_ZZzJyNuZA@mail.gmail.com> (raw)
In-Reply-To: <20220303075738.56a90b79@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>

On Thu, Mar 3, 2022 at 11:57 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 3 Mar 2022 20:24:53 +0800 Zheyu Ma wrote:
> > When removing the macb_pci module, the driver will cause a UAF bug.
> >
> > Commit d82d5303c4c5 ("net: macb: fix use after free on rmmod") moves
> > the platform_device_unregister() after clk_unregister(), but this
> > introduces another UAF bug.
>
> The layering is all weird here. macb_probe() should allocate a private
> structure for the _PCI driver_ which it can then attach to
> struct pci_dev *pdev as driver data. Then free it in remove.
> It shouldn't stuff its information into the platform device.
>
> Are you willing to send a fix like that?

Thanks for your useful suggestion, I'm willing to submit a patch.
But I'm a newbie to kernel and I think I need some time to think about
how to make such changes.

Regards,
Zheyu Ma

      parent reply	other threads:[~2022-03-05 14:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 12:24 [BUG] net: macb: Use-After-Free when removing the module Zheyu Ma
2022-03-03 15:57 ` Jakub Kicinski
2022-03-04  9:49   ` Nicolas Ferre
2022-03-05 14:11   ` Zheyu Ma [this message]

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=CAMhUBjm9+nt8j0JFwHEms2Ra1YjhAXquVyHuDYX0_ZZzJyNuZA@mail.gmail.com \
    --to=zheyuma97@gmail.com \
    --cc=claudiu.beznea@microchip.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.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).