From: sashiko-bot@kernel.org
To: "Lyude Paul" <lyude@redhat.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 4/5] drm/nouveau/gsp/r570: Start saving comptag backing stores
Date: Tue, 15 Sep 2026 21:20:49 +0000 [thread overview]
Message-ID: <20260915212049.D910E1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260915210647.695187-5-lyude@redhat.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] nouveau: gsp: buffer overflow in r535_fbsr_memlist() due to unaligned compbit_store_size
- [Medium] nouveau: gsp: integer truncation of size leads to tiny DMA allocation
--
commit 2f071ac78fdb305696ed659788ff3cf83d6adc73
Author: Lyude Paul <lyude@redhat.com>
drm/nouveau/gsp/r570: Start saving comptag backing stores
One of the portions of OpenRM's fbsr process that we never implemented is
the saving and restoring of comptag backing stores. This isn't strictly
necessary for fbsr to work (as long as we don't specify bEnteringGcOff =
1), but implementing it brings us much closer to matching OpenRM's fbsr
process - which means we can rely on things being well tested on Nvidia's
side.
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c
> index 569732320f3dd..feef5104a6241 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/fbsr.c
[ ... ]
> @@ -174,6 +197,8 @@ r570_fbsr_suspend(struct nvkm_gsp *gsp)
> size = gsp->fb.heap.size;
> size += gsp->fb.rsvd_size;
> size += gsp->fb.bios.vga_workspace.size;
> + size += compbit_store_size;
> +
[Severity: High]
Does adding the unaligned compbit_store_size directly to size here lead to an
out-of-bounds write in r535_fbsr_memlist()?
When this unaligned size is passed to nvkm_gsp_sg(), it rounds it up using
DIV_ROUND_UP to allocate memory pages. However, when r535_fbsr_memlist()
constructs the memory list, it computes the required RPC array size by
truncation:
const u32 pages = size / GSP_PAGE_SIZE;
This allocates an undersized array for the PTEs. Then the loop inside
r535_fbsr_memlist() iterates based on the rounded-up scatterlist length:
for (int i = 0; i < sg_dma_len(sgl) / GSP_PAGE_SIZE; i++)
This mismatch causes the pte++ index to write 8 bytes (or more) past the end
of the allocated rpc buffer, resulting in kernel heap memory corruption if a
buggy or compromised firmware returns a non-page-aligned size.
[Severity: Medium]
Could an extremely large compbit_store_size from the GSP firmware cause an
integer truncation when passed to sg_alloc_table()?
If size exceeds the 32-bit limit, DIV_ROUND_UP(size, PAGE_SIZE) in
nvkm_gsp_sg() overflows the 32-bit unsigned int nents parameter in
sg_alloc_table(). This truncates the value, resulting in a tiny DMA
allocation.
Meanwhile, this huge size is still passed to the GSP as the length field.
When the GSP attempts to save its state, it will DMA out of the bounds of the
mapped physical pages, potentially leading to a GSP MMU or IOMMU fault.
> nvkm_debug(subdev, "fbsr: size: 0x%llx bytes\n", size);
>
> ret = nvkm_gsp_sg(device, size, &gsp->sr.fbsr);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915210647.695187-1-lyude@redhat.com?part=4
next prev parent reply other threads:[~2026-09-15 21:20 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 18:51 [PATCH v2 0/5] drm/nouveau/gsp/r570: Follow OpenRM's runtime PM process more closely Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 18:51 ` [PATCH v2 1/5] drm/nouveau/gsp/r535: Add support for INTERNAL_GCX_ENTRY_PREREQUISITE Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:17 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 2/5] drm/nouveau/gsp/r535: Add support for MEMSYS_GET_STATIC_CONFIG Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:17 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 3/5] drm/nouveau/gsp/r570: Add comp mode workaround from issue #3172217 Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:21 ` sashiko-bot
2026-09-15 18:51 ` [PATCH v2 4/5] drm/nouveau/gsp/r570: Start saving comptag backing stores Lyude Paul
2026-09-15 18:51 ` Lyude Paul
2026-09-15 21:20 ` sashiko-bot [this message]
2026-09-15 18:51 ` [PATCH v2 5/5] drm/nouveau/gsp/r570: Enable Gcoff in fbsr again Lyude Paul
2026-09-15 18:51 ` Lyude Paul
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=20260915212049.D910E1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lyude@redhat.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.