From: sashiko-bot@kernel.org
To: "Andrey Misiurov" <andrey.misyrov@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 6.1.y] scsi: lpfc: Fix use-after-free of mboxq in lpfc_sli4_driver_resource_setup()
Date: Thu, 08 Oct 2026 18:53:52 +0000 [thread overview]
Message-ID: <sashiko-outbox-164482@kernel.org> (raw)
In-Reply-To: <20261008184328.2857037-1-andrey.misyrov@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: lpfc: Double free / UAF of mboxq on mailbox timeout in lpfc_get_sli4_parameters()
--
commit 7386b919d763fc6f447906aaee405cec863dac39
Author: Andrey Misiurov <andrey.misyrov@gmail.com>
scsi: lpfc: Fix use-after-free of mboxq in lpfc_sli4_driver_resource_setup()
This commit moves the mempool_free() of mboxq in
lpfc_sli4_driver_resource_setup() after the error handling for
lpfc_get_sli4_parameters() to fix a previous incorrect backport.
> diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
> index 13ebbe4a71c47..fc5a640b7f742 100644
> --- a/drivers/scsi/lpfc/lpfc_init.c
> +++ b/drivers/scsi/lpfc/lpfc_init.c
> @@ -8175,7 +8175,6 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
> }
> }
> }
> - mempool_free(mboxq, phba->mbox_mem_pool);
>
> lpfc_nvme_mod_param_dep(phba);
>
[ ... ]
> @@ -8209,6 +8208,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
> goto out_free_bsmbx;
> }
> }
> + mempool_free(mboxq, phba->mbox_mem_pool);
[Severity: High]
Does this unconditionally free mboxq even when lpfc_get_sli4_parameters()
encounters a timeout?
If the mailbox command issued by lpfc_get_sli4_parameters() times out, it
returns MBX_TIMEOUT. On this path, the driver retains the mboxq and
delegates cleanup to the asynchronous completion handler:
drivers/scsi/lpfc/lpfc_sli.c:lpfc_sli_issue_mbox_wait() {
...
} else {
retval = MBX_TIMEOUT;
pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl;
}
...
}
Because mboxq is freed unconditionally here on the success path (and also
on the error goto paths above this), could this lead to a double-free and
use-after-free when the async handler later attempts to clean it up?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261008184328.2857037-1-andrey.misyrov@gmail.com?part=1
next prev parent reply other threads:[~2026-10-08 18:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 18:43 [PATCH 6.1.y] scsi: lpfc: Fix use-after-free of mboxq in lpfc_sli4_driver_resource_setup() Andrey Misiurov
2026-10-08 18:53 ` sashiko-bot [this message]
2026-10-09 17:09 ` Sasha Levin
2026-10-10 5:49 ` Abdun Nihaal
2026-10-13 20:31 ` Андрей Мисюров
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-164482@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=andrey.misyrov@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox