All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: mptfusion: Fix potential chain array leaks on attach failure
Date: Fri, 13 Nov 2026 14:35:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-212996@kernel.org> (raw)
In-Reply-To: <20261113-4e14e563a1-scsi-mptfusion@mail.sdu.edu.cn>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] message/fusion: lockless list modification in mpt_attach()
  [1]
--

commit bd21a339f04c74107336a8df0b58bbfb54c0a200
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>

scsi: mptfusion: Fix potential chain array leaks on attach failure

This commit frees the ChainToChain, RequestNB, and ReqToChain arrays in
mpt_attach() when mpt_do_ioc_recovery() fails during adapter bring-up.

> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index 3a431ffd3e2eb..a0592404472cc 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -2015,6 +2015,9 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
>  		destroy_workqueue(ioc->reset_work_q);
>  		ioc->reset_work_q = NULL;
>  
> +		kfree(ioc->ChainToChain);
> +		kfree(ioc->RequestNB);
> +		kfree(ioc->ReqToChain);
>  		kfree(ioc);
>  		return r;
>  	}

[Severity: Critical]
This problem wasn't introduced by this patch, but can uncoordinated
modifications to the global ioc_list [1] cause a use-after-free?

mpt_attach() and mpt_adapter_dispose() add and remove ioc from ioc_list
without holding any lock.  Meanwhile, mptctl_fasync() iterates over
ioc_list under mpctl_mutex (which is private to mptctl.c and not held by
writers), and mpt_verify_adapter() iterates over ioc_list without any
lock at all.  During hotplug or sysfs bind/unbind, a reader can traverse
a broken list pointer or access a freed ioc:

CPU0                              CPU1
mpt_attach() / mpt_adapter_dispose()
                                  mptctl_fasync()
                                    mutex_lock(&mpctl_mutex)
                                    list_for_each_entry(ioc, &ioc_list, list)
  list_del(&ioc->list)
  kfree(ioc)
                                      ioc->aen_event_read_flag = 0;  <-- use-after-free

[1] https://sashiko.dev/#/bug/linux-3331f265-1868-460b-9ec0-3fe42034986b

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261113-4e14e563a1-scsi-mptfusion@mail.sdu.edu.cn?part=1

      reply	other threads:[~2026-11-13 14:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 14:18 [PATCH] scsi: mptfusion: Fix potential chain array leaks on attach failure Guangshuo Li
2026-11-13 14:35 ` sashiko-bot [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=sashiko-outbox-212996@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=liguangshuo@mail.sdu.edu.cn \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.