From: Jens Axboe <axboe@kernel.dk>
To: stable@vger.kernel.org
Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org
Subject: [PATCH 6.18.y 14/14] io_uring/zcrx: don't sync dma-bufs
Date: Sat, 5 Dec 2026 23:11:47 +0000 [thread overview]
Message-ID: <20261205231147.4095031-15-axboe@kernel.dk> (raw)
In-Reply-To: <20261205231147.4095031-1-axboe@kernel.dk>
From: Pavel Begunkov <asml.silence@gmail.com>
Commit 7e3dc305a86e40ce1f9cd926ecd06d339468f5cb upstream.
dma-bufs follow different synchronisation rules comparing to normal
memory, the user accessing it must use proper API like
DMA_BUF_IOCTL_SYNC. Don't sync dma-buf backed buffers with the
dma_sync_*() family of helpers.
Fixes: a5c98e9424573 ("io_uring/zcrx: dmabuf backed zerocopy receive")
Cc: stable@vger.kernel.org
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Reviewed-by: Mina Almasry <almasrymina@google.com>
Link: https://patch.msgid.link/8e93a756a3b8fea2be7935d34e1b833fd98e40ea.1796301395.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[axboe: 6.18 syncs one niov at a time in io_zcrx_sync_for_device(),
which gets the ifq from io_pp_to_ifq(), and io_pp_zc_init() takes a
ctx ref rather than an ifq ref]
---
io_uring/zcrx.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 385e6d793d17..133c0ca0a559 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -299,14 +299,15 @@ static void io_zcrx_sync_for_device(struct page_pool *pool,
struct net_iov *niov)
{
#if defined(CONFIG_HAS_DMA) && defined(CONFIG_DMA_NEED_SYNC)
+ struct io_zcrx_ifq *ifq = io_pp_to_ifq(pool);
dma_addr_t dma_addr;
unsigned niov_size;
- if (!dma_dev_need_sync(pool->p.dev))
+ if (!ifq->kern_readable || !dma_dev_need_sync(pool->p.dev))
return;
- niov_size = 1U << io_pp_to_ifq(pool)->niov_shift;
+ niov_size = 1U << ifq->niov_shift;
dma_addr = page_pool_get_dma_addr_netmem(net_iov_to_netmem(niov));
__dma_sync_single_for_device(pool->p.dev, dma_addr + pool->p.offset,
niov_size, pool->p.dma_dir);
@@ -902,6 +903,10 @@ static int io_pp_zc_init(struct page_pool *pp)
if (ret)
return ret;
+ if (!ifq->kern_readable) {
+ pp->dma_sync_for_cpu = false;
+ pp->dma_sync = false;
+ }
percpu_ref_get(&ifq->ctx->refs);
return 0;
}
--
2.55.0
prev parent reply other threads:[~2026-12-05 23:12 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 23:11 [PATCH 6.18.y 00/14] io_uring fixes for 6.18-stable Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 01/14] io_uring/net: don't charge the folio offset to truesize for managed frags Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 02/14] io_uring/net: don't copy msg_name on a recvmsg retry Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 03/14] io_uring/kbuf: clear REQ_F_BL_NO_RECYCLE on buffer put Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 04/14] io_uring/tctx: add separate lock for list of tctx's in ctx Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 05/14] io_uring: free the task context after a grace period Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 06/14] io_uring: free the ring " Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 07/14] io_uring/filetable: don't install O_PATH files Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 08/14] io_uring/cancel: always walk links under timeout_lock Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 09/14] io_uring/net: don't count the buffers of a send bundle Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 10/14] io_uring/net: restore the cmsg buffer on recvmsg retry Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 11/14] io_uring: close poll activation race when enabling rings Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 12/14] io_uring/cancel: arm local work wakeups only for submitter Jens Axboe
2026-12-05 23:11 ` [PATCH 6.18.y 13/14] io_uring/zcrx: cache fallback availability in zcrx ctx Jens Axboe
2026-12-05 23:11 ` Jens Axboe [this message]
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=20261205231147.4095031-15-axboe@kernel.dk \
--to=axboe@kernel.dk \
--cc=gregkh@linuxfoundation.org \
--cc=io-uring@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox