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 <[email protected]> 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/[email protected]?part=1
