* [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path
@ 2026-11-22 0:03 Falconet3
0 siblings, 0 replies; 3+ messages in thread
From: Falconet3 @ 2026-11-22 0:03 UTC (permalink / raw)
To: sumit.semwal@linaro.org, christian.koenig@amd.com
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
leak of ctx + dmabuf ref on the WARN_ON_ONCE path, new file in v7.4-rc1, patch attached)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path
@ 2026-11-22 0:05 Falconet3
2026-11-22 0:49 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Falconet3 @ 2026-11-22 0:05 UTC (permalink / raw)
To: sumit.semwal@linaro.org, christian.koenig@amd.com
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, axboe@kernel.dk,
io-uring@vger.kernel.org, asml.silence@gmail.com,
linux-kernel@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 89 bytes --]
(leak of ctx + dmabuf ref on the WARN_ON_ONCE path, new file in v7.4-rc1, patch attached)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-dma-buf-fix-leak-in-dma_buf_io_ctx_create-WARN-path.patch --]
[-- Type: text/x-patch; name=0002-dma-buf-fix-leak-in-dma_buf_io_ctx_create-WARN-path.patch, Size: 1957 bytes --]
From: Falconet3 <Falconet3@proton.me>
Date: Sat, 21 Nov 2026 21:05:00 +0000
Subject: [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path
The file drivers/dma-buf/dma-buf-io.c (and the io_uring dmabuf regbuf
feature on top of it) is new in v7.4-rc1. In dma_buf_io_ctx_create(),
the error path of init_dma_buf_io_ctx() correctly does
kfree(ctx) + dma_buf_put(dmabuf) (dma-buf-io.c:178-182), but the
WARN_ON_ONCE() path right below it returns -EINVAL without freeing
either (dma-buf-io.c:184-188):
if (WARN_ON_ONCE(!ctx->dev_ops || ...))
return -EINVAL; /* leaks ctx and the get_dma_buf() ref */
Reachable from userspace via io_uring buffer registration
(IORING_REGISTER_BUF / rsrc update with IO_REGBUF_TYPE_DMABUF,
io_uring/dma-buf.c -> dma_buf_io_ctx_create()) whenever an importer's
init_dma_buf_io_ctx() succeeds but leaves dev_ops incomplete:
kernel memory + dma-buf reference leak (DoS-grade).
Affects v7.4-rc1..v7.4-rc3 only; the file does not exist in v7.3.5.
Fix was verified with git apply --check against v7.4-rc3; not
build-tested and no reproducer available in this environment.
Fixes: FILL-IN-SHA ("dma-buf: introduce ... file I/O ...")
Assisted-by: LLM Mistral Vibe
Signed-off-by: Falconet3 <Falconet3@proton.me>
---
drivers/dma-buf/dma-buf-io.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/dma-buf/dma-buf-io.c b/drivers/dma-buf/dma-buf-io.c
index 0000000..0000000 100644
--- a/drivers/dma-buf/dma-buf-io.c
+++ b/drivers/dma-buf/dma-buf-io.c
@@ -179,13 +179,16 @@ int dma_buf_io_ctx_create(struct file *file,
kfree(ctx);
dma_buf_put(dmabuf);
return ret;
}
if (WARN_ON_ONCE(!ctx->dev_ops ||
!ctx->dev_ops->map ||
!ctx->dev_ops->unmap ||
- !ctx->dev_ops->release))
- return -EINVAL;
+ !ctx->dev_ops->release)) {
+ kfree(ctx);
+ dma_buf_put(dmabuf);
+ return -EINVAL;
+ }
*out_ctx = ctx;
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path
2026-11-22 0:05 [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path Falconet3
@ 2026-11-22 0:49 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2026-11-22 0:49 UTC (permalink / raw)
To: Falconet3, sumit.semwal@linaro.org, christian.koenig@amd.com
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
linaro-mm-sig@lists.linaro.org, io-uring@vger.kernel.org,
asml.silence@gmail.com, linux-kernel@vger.kernel.org
On 11/21/26 5:05 PM, Falconet3 wrote:
> (leak of ctx + dmabuf ref on the WARN_ON_ONCE path, new file in v7.4-rc1, patch attached)
Please see how patches are usually sent - not a huge deal, attachments can
be applied, it's just a lot more inconvenient than a properly sent
patch as you can't comment on it in email. The bigger issue is your
From and Signed-off-by - that needs to be a real identify, not some
leet handle.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-22 0:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-22 0:05 [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path Falconet3
2026-11-22 0:49 ` Jens Axboe
-- strict thread matches above, loose matches on Subject: below --
2026-11-22 0:03 Falconet3
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox