]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
dma-buf: improve sg_table debugging hack v4
authorChristian König <christian.koenig@amd.com>
Fri, 19 Sep 2025 14:40:06 +0000 (16:40 +0200)
committerChristian König <christian.koenig@amd.com>
Mon, 8 Dec 2025 15:39:09 +0000 (16:39 +0100)
commit51db5336e16de25074ef63d29b8a762a25d193d3
treef66261555d669866b76643991b72ded12479ab5b
parent4ebaaa3b622238ea44fbaa21998ad76bd8417a8c
dma-buf: improve sg_table debugging hack v4

This debugging hack is important to enforce the rule that importers
should *never* touch the underlying struct page of the exporter.

Instead of just mangling the page link create a copy of the sg_table
but only copy over the DMA addresses and not the pages.

This will cause a NULL pointer de-reference if the importer tries to
touch the struct page. Still quite a hack but this at least allows the
exporter to properly keeps it's sg_table intact while allowing the
DMA-buf maintainer to find and fix misbehaving importers and finally
switch over to using a different data structure in the future.

v2: improve the hack further by using a wrapper structure and explaining
the background a bit more in the commit message.
v3: fix some whitespace issues, use sg_assign_page().
v4: give the functions a better name

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Link: https://lore.kernel.org/r/20251205130604.1582-1-christian.koenig@amd.com
drivers/dma-buf/dma-buf.c