Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dma-buf: fix UAF in dma_buf_put() tracepoint

dma_buf_put() may drop the final file reference via fput(), which
can free the dma-buf. The new tracepoint invocation was added
after fput(), and DMA_BUF_TRACE() dereferences dmabuf and takes
dmabuf->name_lock.

This leads to a use-after-free on the final put, visible for
example as a spinlock bad magic fault on a poisoned 0x6b6b6b...
lock.

Move the dma_buf_put tracepoint before fput().

Reported-by: Janusz Krzysztofik <janusz.krzysztofik@linux.intel.com>
Fixes: 281a22631423 ("dma-buf: add some tracepoints to debug.")
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/r/20260408123916.2604101-1-andi.shyti@kernel.org

authored by

Andi Shyti and committed by
Christian König
2d76319c eecdd4bd

+1 -2
+1 -2
drivers/dma-buf/dma-buf.c
··· 845 845 if (WARN_ON(!dmabuf || !dmabuf->file)) 846 846 return; 847 847 848 - fput(dmabuf->file); 849 - 850 848 DMA_BUF_TRACE(trace_dma_buf_put, dmabuf); 849 + fput(dmabuf->file); 851 850 } 852 851 EXPORT_SYMBOL_NS_GPL(dma_buf_put, "DMA_BUF"); 853 852