dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stanislav Kinsburskii" <skinsburskii@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 2/4] fixup! drm/nouveau: use hmm_range_fault_unlocked_timeout() for SVM faults
Date: Tue, 14 Jul 2026 20:30:07 +0000	[thread overview]
Message-ID: <20260714203008.506B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <178406001808.1082778.17299764648397654220.stgit@skinsburskii>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Removal of the absolute timeout in nouveau_range_fault() allows an attacker to cause an infinite loop in the global GPU page fault worker thread, stalling all SVM faults.
--

--- Patch [2]: [PATCH 2/4] fixup! drm/nouveau: use hmm_range_fault_unlocked_timeout() for SVM faults ---
commit acde5c43961cd86d28658d26f11cdfcde5a9ad23
Author: Stanislav Kinsburskii <skinsburskii@gmail.com>

fixup! drm/nouveau: use hmm_range_fault_unlocked_timeout() for SVM faults

This commit updates nouveau_range_fault() to pass the full relative timeout
to hmm_range_fault_unlocked_timeout() on each attempt. It also removes the
open-coded absolute deadline and remaining-time calculation, replacing the
bounded while loop with a goto-based retry loop.

> diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
> index 4cfb6eb7c7715..b1415c2e49fcc 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_svm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
[ ... ]
> @@ -677,25 +676,16 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
>  	range.start = notifier->notifier.interval_tree.start;
>  	range.end = notifier->notifier.interval_tree.last + 1;
>  
> -	while (true) {
> -		if (time_after(jiffies, timeout)) {
> -			ret = -EBUSY;
> -			goto out;
> -		}
> -
> -		ret = hmm_range_fault_unlocked_timeout(&range,
> -						       max(timeout - jiffies,
> -							   1L));
> -		if (ret)
> -			goto out;
> +again:
> +	ret = hmm_range_fault_unlocked_timeout(&range, timeout);
> +	if (ret)
> +		goto out;
>  
> -		mutex_lock(&svmm->mutex);
> -		if (mmu_interval_read_retry(range.notifier,
> -					    range.notifier_seq)) {
> -			mutex_unlock(&svmm->mutex);
> -			continue;
> -		}
> -		break;
> +	mutex_lock(&svmm->mutex);
> +	if (mmu_interval_read_retry(range.notifier,
> +				    range.notifier_seq)) {
> +		mutex_unlock(&svmm->mutex);
> +		goto again;

[Severity: High]
Can this sequence lead to an infinite loop and stall the global GPU page fault
worker thread?

If a user-space program triggers an SVM page fault and simultaneously runs
memory invalidations like madvise(MADV_DONTNEED) in a loop on the same
memory range, mmu_interval_read_retry() will continuously return true.

Since this runs in a kernel worker thread, fatal_signal_pending(current)
inside hmm_range_fault_unlocked_timeout() will check the worker thread rather
than the user process. With the absolute timeout removed from
nouveau_range_fault(), does this allow an attacker to loop here indefinitely
and block all other SVM faults?

>  	}
>  
>  	nouveau_hmm_convert_pfn(drm, &range, args);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/178405975214.1082778.5193079941156341151.stgit@skinsburskii?part=2

  reply	other threads:[~2026-07-14 20:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 20:13 [PATCH 0/4] mm/hmm: Clarify notifier retry state and scope HMM timeouts Stanislav Kinsburskii
2026-07-14 20:13 ` [PATCH 1/4] fixup! mm/hmm: add hmm_range_fault_unlocked_timeout() for mmap lock-drop support Stanislav Kinsburskii
2026-07-14 20:13 ` [PATCH 2/4] fixup! drm/nouveau: use hmm_range_fault_unlocked_timeout() for SVM faults Stanislav Kinsburskii
2026-07-14 20:30   ` sashiko-bot [this message]
2026-07-14 21:33   ` Stanislav Kinsburskii
2026-07-14 20:13 ` [PATCH 3/4] fixup! accel/amdxdna: use hmm_range_fault_unlocked_timeout() for range population Stanislav Kinsburskii
2026-07-14 20:27   ` sashiko-bot
2026-07-14 20:13 ` [PATCH 4/4] fixup! drm/gpusvm: use hmm_range_fault_unlocked_timeout() for range faults Stanislav Kinsburskii
2026-07-14 20:24   ` sashiko-bot

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=20260714203008.506B61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.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