All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Linmao Li" <lilinmao@kylinos.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 2/2] scsi: leapraid: serialize firmware log mmap with teardown
Date: Fri, 14 Aug 2026 03:52:54 +0000	[thread overview]
Message-ID: <20260814035254.85FA01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260814033845.2971706-3-lilinmao@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unbounded wait in `leapraid_fw_log_exit()` allows userspace to block PCI device removal indefinitely.
--

--- Patch [2]: [PATCH v3 2/2] scsi: leapraid: serialize firmware log mmap with teardown ---
commit f76020cc63b98ce5d018410c191835d8ffc2261a
Author: Linmao Li <lilinmao@kylinos.cn>

scsi: leapraid: serialize firmware log mmap with teardown

This commit fixes a race condition during firmware log teardown by
claiming a temporary mmap reference during adapter lookup. It ensures
the driver does not free the coherent buffer while the mmap path is
still establishing a mapping.

> diff --git a/drivers/scsi/leapraid/leapraid_app.c b/drivers/scsi/leapraid/leapraid_app.c
> index 841027ce2501c..84eef50947aea 100644
> --- a/drivers/scsi/leapraid/leapraid_app.c
> +++ b/drivers/scsi/leapraid/leapraid_app.c

[ ... ]

> @@ -771,6 +774,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 since we are modifying the mmap teardown
synchronization here, I noticed a potential problem on the wait side of this
logic.

If a userspace process keeps the VMA open indefinitely, won't the unbind
process hang forever?

Looking at the teardown side in 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));
}

Since this waits in uninterruptible sleep without a timeout, could a rogue
or stuck userspace application block PCI device removal or module unloading
permanently? 

It seems like the kernel shouldn't rely on cooperative userspace behavior 
during hardware unbind, perhaps this needs an unmap_mapping_range() or 
similar asynchronous shootdown mechanism to ensure the wait completes?

>  	leapraid_ctl_put_adapter(adapter);
>  	return rc;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260814033845.2971706-1-lilinmao@kylinos.cn?part=2

      reply	other threads:[~2026-08-14  3:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  3:38 [PATCH v3 0/2] scsi: leapraid: fix firmware log mmap lifetime Linmao Li
2026-08-14  3:38 ` [PATCH v3 1/2] scsi: leapraid: balance host references for firmware log VMAs Linmao Li
2026-08-14  3:56   ` sashiko-bot
2026-08-14  3:38 ` [PATCH v3 2/2] scsi: leapraid: serialize firmware log mmap with teardown Linmao Li
2026-08-14  3:52   ` 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=20260814035254.85FA01F000E9@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 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.