From: sashiko-bot@kernel.org
To: "Linmao Li" <lilinmao@kylinos.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 2/2] scsi: leapraid: serialize firmware log mmap with teardown
Date: Thu, 13 Aug 2026 07:39:06 +0000 [thread overview]
Message-ID: <20260813073907.24F541F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813072614.1387555-3-lilinmao@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Device removal and module unloading can be permanently blocked by a userspace process holding an open memory mapping.
--
--- Patch [2]: [PATCH v2 2/2] scsi: leapraid: serialize firmware log mmap with teardown ---
commit 3180bb0e1579b0aca65c2e7927f3bdc91744a626
Author: Linmao Li <lilinmao@kylinos.cn>
scsi: leapraid: serialize firmware log mmap with teardown
This patch addresses a race condition where a firmware log buffer could be
freed during device removal while a concurrent mmap operation is
establishing a userspace mapping. It claims a temporary mmap reference
while looking up the adapter, and drops it on the exit path.
> diff --git a/drivers/scsi/leapraid/leapraid_app.c b/drivers/scsi/leapraid/leapraid_app.c
> index 841027ce2501c..790a3191e9259 100644
> --- a/drivers/scsi/leapraid/leapraid_app.c
> +++ b/drivers/scsi/leapraid/leapraid_app.c
[ ... ]
> @@ -771,6 +773,9 @@ static int leapraid_fw_mmap(struct file *filp, struct vm_area_struct *vma)
>
> rc = 0;
> out_put:
> + if (adapter &&
> + atomic_dec_and_test(&adapter->fw_log_desc.mmap_refcnt))
> + wake_up(&adapter->fw_log_desc.mmap_waitq);
[Severity: High]
This is a pre-existing issue, but can this userspace-controlled reference
count block device removal and module unloading permanently?
Since a userspace process can hold the VMA open indefinitely, and device
removal waits unconditionally in leapraid_fw_log_exit() for the count to
reach zero:
drivers/scsi/leapraid/leapraid_func.c:leapraid_fw_log_exit() {
...
wait_event(adapter->fw_log_desc.mmap_waitq,
!atomic_read(&adapter->fw_log_desc.mmap_refcnt));
...
}
Could a buggy or malicious userspace process that never unmaps the memory
cause the kernel thread handling PCI hotplug or sysfs unbind to hang
forever without a timeout?
> leapraid_ctl_put_adapter(adapter);
> return rc;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813072614.1387555-1-lilinmao@kylinos.cn?part=2
prev parent reply other threads:[~2026-08-13 7:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 7:26 [PATCH v2 0/2] scsi: leapraid: fix firmware log mmap lifetime Linmao Li
2026-08-13 7:26 ` [PATCH v2 1/2] scsi: leapraid: balance host references for firmware log VMAs Linmao Li
2026-08-13 7:39 ` sashiko-bot
2026-08-13 7:26 ` [PATCH v2 2/2] scsi: leapraid: serialize firmware log mmap with teardown Linmao Li
2026-08-13 7:39 ` 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=20260813073907.24F541F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=lilinmao@kylinos.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox