From: sashiko-bot@kernel.org
To: "Ying Xiao" <eagleshaw@google.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH] dma-buf: heaps: system: zero pages after set_memory_decrypted()
Date: Tue, 17 Nov 2026 16:27:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-219170@kernel.org> (raw)
In-Reply-To: <20261117155431.1654298-1-eagleshaw@google.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] dma-buf: heaps: double encryption and memory leak in
system_heap_allocate() [1]
--
commit 8e29228b9a5d6486d110b63bcefe3df39d060082
Author: Ying Xiao <eagleshaw@google.com>
dma-buf: heaps: system: zero pages after set_memory_decrypted()
This commit skips __GFP_ZERO when allocating pages for the
system_cc_shared heap and zeroes the pages in
system_heap_set_page_decrypted() after set_memory_decrypted() succeeds.
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index c8959eadc71d1..5f98d0df11e76 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
[ ... ]
> @@ -438,7 +453,8 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
> goto free_buffer;
> }
>
> - page = alloc_largest_available(size_remaining, max_order);
> + page = alloc_largest_available(size_remaining, max_order,
> + cc_shared_buffer(buffer));
> if (!page)
> goto free_buffer;
>
[Severity: Critical]
This problem wasn't introduced by this patch, but does the free_pages
error path in system_heap_allocate() call system_heap_set_page_encrypted()
on pages that were never decrypted [1] when
system_heap_set_page_decrypted() fails partway through the scatterlist?
drivers/dma-buf/heaps/system_heap.c:system_heap_allocate() {
...
if (cc_shared_buffer(buffer)) {
for_each_sgtable_sg(table, sg, i) {
ret = system_heap_set_page_decrypted(sg_page(sg));
if (ret)
goto free_pages;
}
}
...
free_pages:
for_each_sgtable_sg(table, sg, i) {
struct page *p = sg_page(sg);
...
if (cc_shared_buffer(buffer) &&
system_heap_set_page_encrypted(p))
continue;
__free_pages(p, compound_order(p));
}
...
}
At free_pages, for_each_sgtable_sg() resets i to 0 and iterates over the
entire scatterlist instead of only the entries that were decrypted.
Calling system_heap_set_page_encrypted() on pages that are still encrypted
can fault in confidential computing guests, or fail and skip
__free_pages(), leaking the pages.
[1] https://sashiko.dev/#/bug/linux-ece74ffb-d452-4ab2-b56e-aa5701dddcf3
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117155431.1654298-1-eagleshaw@google.com?part=1
next prev parent reply other threads:[~2026-11-17 16:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20261117155436eucas1p2fa7d030f5557d1c88d943226d65f69ca@eucas1p2.samsung.com>
2026-11-17 15:54 ` [PATCH] dma-buf: heaps: system: zero pages after set_memory_decrypted() Ying Xiao
2026-11-17 16:27 ` sashiko-bot [this message]
2026-11-18 8:05 ` Marek Szyprowski
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=sashiko-outbox-219170@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eagleshaw@google.com \
--cc=media-ci@linuxtv.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.