All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Junrui Luo" <moonafterrain@outlook.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/nouveau: bound sync and op counts in EXEC and VM_BIND
Date: Sat, 08 Aug 2026 11:27:12 +0000	[thread overview]
Message-ID: <20260808112713.69CFB1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260808-nouveau-fixes-v1-1-c3ebdc17a89c@outlook.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] Un-rate-limited error logging creates a potential log-spam DoS vector.
- [Medium] Validation of flag-gated syscall parameters outside their flag scope.
- [Low] Format string specifier mismatch in error logging for __u32 counts.
--

--- Patch [1]: [PATCH 1/2] drm/nouveau: bound sync and op counts in EXEC and VM_BIND ---
commit 6d0adda3ff0dd4a0e4440dc92362fcb0ad993d9a
Author: Junrui Luo <moonafterrain@outlook.com>
Subject: drm/nouveau: bound sync and op counts in EXEC and VM_BIND

This commit introduces upper bounds for sync and op counts in the EXEC and
VM_BIND ioctls. By restricting the size of these counts, it prevents potential
excessive memory allocations that could trigger warnings or exhaust memory.

> diff --git a/drivers/gpu/drm/nouveau/nouveau_exec.c b/drivers/gpu/drm/nouveau/nouveau_exec.c
> index a08ab1cfea9be..7bdccbae53b1d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_exec.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_exec.c
> @@ -389,6 +389,18 @@ nouveau_exec_ioctl_exec(struct drm_device *dev,
>  		return nouveau_abi16_put(abi16, -EINVAL);
>  	}
>  
> +	if (unlikely(req->wait_count > NOUVEAU_MAX_SYNCS)) {
> +		NV_PRINTK(err, cli, "exec wait count exceeds limit: %d max %d\n",
> +			  req->wait_count, NOUVEAU_MAX_SYNCS);

[Severity: Low]
Are the format string specifiers correct here? The req->wait_count field is
a __u32 type, so using %d will print large values as negative numbers.

[Severity: Medium]
Could this un-rate-limited NV_PRINTK log be intentionally triggered by
userspace to spam the kernel log buffer and hide other messages?

> +		return nouveau_abi16_put(abi16, -EINVAL);
> +	}
> +
> +	if (unlikely(req->sig_count > NOUVEAU_MAX_SYNCS)) {
> +		NV_PRINTK(err, cli, "exec sig count exceeds limit: %d max %d\n",
> +			  req->sig_count, NOUVEAU_MAX_SYNCS);
> +		return nouveau_abi16_put(abi16, -EINVAL);
> +	}
> +
>  	ret = nouveau_exec_ucopy(&args, req);

[ ... ]

> diff --git a/drivers/gpu/drm/nouveau/nouveau_uvmm.c b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> index f5e4756b4de4a..bced1481674e7 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_uvmm.c
> @@ -1807,6 +1807,24 @@ nouveau_uvmm_ioctl_vm_bind(struct drm_device *dev,
>  	if (unlikely(!nouveau_cli_uvmm_locked(cli)))
>  		return -ENOSYS;
>  
> +	if (unlikely(req->op_count > NOUVEAU_VM_BIND_MAX_OPS)) {
> +		NV_PRINTK(err, cli, "vm_bind op count exceeds limit: %d max %d\n",
> +			  req->op_count, NOUVEAU_VM_BIND_MAX_OPS);
> +		return -EINVAL;
> +	}
> +
> +	if (unlikely(req->wait_count > NOUVEAU_MAX_SYNCS)) {

[Severity: Medium]
According to the userspace API documentation, sync objects are only accepted
when DRM_NOUVEAU_VM_BIND_RUN_ASYNC is set in req->flags. If a user submits a
VM_BIND ioctl without this flag, might wait_count and sig_count contain
uninitialized garbage from userspace stack slots?

If so, is it safe to validate these flag-gated parameters outside the scope
of their flag check, rather than explicitly ignoring or rejecting them when
the flag is absent?

> +		NV_PRINTK(err, cli, "vm_bind wait count exceeds limit: %d max %d\n",
> +			  req->wait_count, NOUVEAU_MAX_SYNCS);
> +		return -EINVAL;
> +	}
> +
> +	if (unlikely(req->sig_count > NOUVEAU_MAX_SYNCS)) {
> +		NV_PRINTK(err, cli, "vm_bind sig count exceeds limit: %d max %d\n",
> +			  req->sig_count, NOUVEAU_MAX_SYNCS);
> +		return -EINVAL;
> +	}
> +
>  	ret = nouveau_uvmm_vm_bind_ucopy(&args, req);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260808-nouveau-fixes-v1-0-c3ebdc17a89c@outlook.com?part=1

  reply	other threads:[~2026-08-08 11:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08 11:14 [PATCH 0/2] drm/nouveau: fix unbounded kernel allocations in the VM_BIND uAPI Junrui Luo via B4 Relay
2026-08-08 11:14 ` Junrui Luo
2026-08-08 11:14 ` [PATCH 1/2] drm/nouveau: bound sync and op counts in EXEC and VM_BIND Junrui Luo via B4 Relay
2026-08-08 11:14   ` Junrui Luo
2026-08-08 11:27   ` sashiko-bot [this message]
2026-08-09 22:43   ` David Airlie
2026-08-09 22:43     ` David Airlie
2026-08-11  4:00     ` Junrui Luo
2026-08-11  4:00       ` Junrui Luo
2026-08-11  4:05       ` Dave Airlie
2026-08-11  4:05         ` Dave Airlie
2026-08-08 11:14 ` [PATCH 2/2] drm/nouveau/uvmm: reject a second VM_INIT Junrui Luo via B4 Relay
2026-08-08 11:14   ` Junrui Luo
2026-08-08 11:35   ` 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=20260808112713.69CFB1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=moonafterrain@outlook.com \
    --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.