From: sashiko-bot@kernel.org
To: "Stanislav Kinsburskii" <skinsburskii@gmail.com>
Cc: linux-hyperv@vger.kernel.org
Subject: Re: [PATCH v6 4/4] mshv: Use hmm_range_fault_unlocked() for region faults
Date: Mon, 06 Jul 2026 18:21:05 +0000 [thread overview]
Message-ID: <20260706182106.2A3DD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <178336052192.504354.1841795575701703197.stgit@skinsburskii>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Missing check for fatal signals in retry loop handling HMM faults.
--
commit 4f92a5b1f4b0160351016ede4e0c8d47d308cbfa
Author: Stanislav Kinsburskii <skinsburskii@gmail.com>
mshv: Use hmm_range_fault_unlocked() for region faults
Convert mshv_region_hmm_fault_and_lock() to use hmm_range_fault_unlocked()
instead of taking mmap_read_lock() around hmm_range_fault() directly.
This allows the MSHV fault path to handle mappings whose fault handlers may
drop mmap_lock.
> diff --git a/drivers/hv/mshv_regions.c b/drivers/hv/mshv_regions.c
> index 6d65e5b421529..04676f06c5c74 100644
> --- a/drivers/hv/mshv_regions.c
> +++ b/drivers/hv/mshv_regions.c
> @@ -388,13 +388,11 @@ int mshv_region_get(struct mshv_mem_region *region)
> *
> * This function performs the following steps:
> * 1. Reads the notifier sequence for the HMM range.
> - * 2. Acquires a read lock on the memory map.
> - * 3. Handles HMM faults for the specified range.
> - * 4. Releases the read lock on the memory map.
> - * 5. If successful, locks the memory region mutex.
> - * 6. Verifies if the notifier sequence has changed during the operation.
> + * 2. Handles HMM faults for the specified range.
> + * 3. If successful, locks the memory region mutex.
> + * 4. Verifies if the notifier sequence has changed during the operation.
> * If it has, releases the mutex and returns -EBUSY to match with
> - * hmm_range_fault() return code for repeating.
> + * hmm_range_fault_unlocked() so the caller retries the range fault.
[Severity: High]
This isn't a bug introduced by this patch, but since we are modifying the
fault retry logic, does the retry loop in mshv_region_range_fault() need to
check for fatal signals?
When mmu_interval_read_retry() detects a collision, this function returns
-EBUSY, which bubbles up to the caller in drivers/hv/mshv_regions.c:
mshv_region_range_fault() {
...
do {
ret = mshv_region_hmm_fault_and_lock(region, &range);
} while (ret == -EBUSY);
...
}
If a userspace program continuously invalidates the memory range concurrently
(for example, via madvise(MADV_DONTNEED)), mmu_interval_read_retry() can
repeatedly return true.
Without a check for fatal_signal_pending(current) inside the loop or before
returning -EBUSY, could this cause the kernel thread to spin indefinitely and
ignore fatal signals like SIGKILL?
> *
> * Return: 0 on success, a negative error code otherwise.
> */
> @@ -404,9 +402,7 @@ static int mshv_region_hmm_fault_and_lock(struct mshv_mem_region *region,
> int ret;
>
> range->notifier_seq = mmu_interval_read_begin(range->notifier);
> - mmap_read_lock(region->mreg_mni.mm);
> - ret = hmm_range_fault(range);
> - mmap_read_unlock(region->mreg_mni.mm);
> + ret = hmm_range_fault_unlocked(range);
> if (ret)
> return ret;
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/178336023903.504354.7500950448226027718.stgit@skinsburskii?part=4
prev parent reply other threads:[~2026-07-06 18:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 17:54 [PATCH v6 0/4] mm/hmm: Add mmap lock-drop support for userfaultfd-backed mappings Stanislav Kinsburskii
2026-07-06 17:55 ` [PATCH v6 1/4] mm/hmm: move page fault handling out of walk callbacks Stanislav Kinsburskii
2026-07-06 17:55 ` [PATCH v6 2/4] mm/hmm: add hmm_range_fault_unlocked() for mmap lock-drop support Stanislav Kinsburskii
2026-07-06 18:02 ` Jason Gunthorpe
2026-07-06 18:16 ` sashiko-bot
2026-07-06 17:55 ` [PATCH v6 3/4] selftests/mm: add userfaultfd test for HMM unlocked path Stanislav Kinsburskii
2026-07-06 17:55 ` [PATCH v6 4/4] mshv: Use hmm_range_fault_unlocked() for region faults Stanislav Kinsburskii
2026-07-06 18:16 ` Jason Gunthorpe
2026-07-06 18:21 ` 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=20260706182106.2A3DD1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=skinsburskii@gmail.com \
/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