The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Johannes Thumshirn <morbidrsa@gmail.com>
To: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com>
Cc: linux-kernel@vger.kernel.org,
	Filip Jensen <dev-Felipe.Jensen@duagon.com>
Subject: Re: [PATCH] mcb: fix KASAN bug slab-use-after-free while removing mcb-pci
Date: Fri, 15 May 2026 11:18:50 +0200	[thread overview]
Message-ID: <7504d205-a1fe-4514-aff4-a883cd290dbe@gmail.com> (raw)
In-Reply-To: <20260427134608.37474-1-dev-josejavier.rodriguez@duagon.com>

On 4/27/26 3:46 PM, Jose Javier Rodriguez Barbarin wrote:
> Fix KASAN bug reported when removing mcb-pci module.
>
> slab-use-after-free in mcb_release_bus drivers/mcb/mcb-core.c:73
> Read of size 8 at addr ffff888101e52060 by task modprobe/4993
>
> mcb_release_bus+0x3e/0x40 drivers/mcb/mcb-core.c:73
> mcb_pci_remove+0x4e/0x70 [mcb_pci]
> pci_device_remove+0xaa/0x1d0 drivers/pci/pci-driver.c:503
> ...
>
> The bug is caused by an incorrect usage of bus_for_each_dev(), thus
> if there are more than one pci mcb board, __mcb_bus_add_devices()
> adds all bus devices recursively, so for mcb:0 it adds its devices
> and for mcb:1 it adds the devices of mcb:0 and mcb:1.
>
> The same behaviour is observed on __mcb_devices_unregister(). So
> when unregistering process happens, for mcb:1, all devices are unregisted,
> even the devices of mcb:0 so when mcb:0 tries to unregister its
> devices, slab-use-after-free happens.
>
> To fix that, just register/unregister the devices on the correct bus.
> Additonally, with this change, mcb_bus have to be explicitly unregistered.
>
> Reviewed-by: Filip Jensen <dev-Felipe.Jensen@duagon.com>
> Signed-off-by: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com>


Looks good, thanks.


      reply	other threads:[~2026-05-15  9:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 13:46 [PATCH] mcb: fix KASAN bug slab-use-after-free while removing mcb-pci Jose Javier Rodriguez Barbarin
2026-05-15  9:18 ` Johannes Thumshirn [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=7504d205-a1fe-4514-aff4-a883cd290dbe@gmail.com \
    --to=morbidrsa@gmail.com \
    --cc=dev-Felipe.Jensen@duagon.com \
    --cc=dev-josejavier.rodriguez@duagon.com \
    --cc=linux-kernel@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