* [PATCH io_uring-7.1 v3 1/6] io_uring/zcrx: reject REG_NODEV with large rx_buf_size
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 2/6] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring() Pavel Begunkov
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev
The copy fallback path doesn't care about the actual niov size and only
uses first PAGE_SIZE bytes, and any additional space will be wasted.
Since ZCRX_REG_NODEV solely relies on the copy path, it doesn't make
sense to support non-standard rx_buf_len. Reject it for now, and
re-enable once improved.
Fixes: c11728021d5cd ("io_uring/zcrx: implement device-less mode for zcrx")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index f94f74d0f566..1ce867c68446 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -449,6 +449,8 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
return -EINVAL;
buf_size_shift = ilog2(reg->rx_buf_len);
}
+ if (!ifq->dev && buf_size_shift != PAGE_SHIFT)
+ return -EOPNOTSUPP;
ret = -ENOMEM;
area = kzalloc_obj(*area);
@@ -462,7 +464,7 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
if (ifq->dev)
area->is_mapped = true;
- if (buf_size_shift > io_area_max_shift(&area->mem)) {
+ if (ifq->dev && buf_size_shift > io_area_max_shift(&area->mem)) {
ret = -ERANGE;
goto err;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH io_uring-7.1 v3 2/6] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring()
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 1/6] io_uring/zcrx: reject REG_NODEV with large rx_buf_size Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 3/6] io_uring/zcrx: don't use mark0 for allocating xarray Pavel Begunkov
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev, Anas Iqbal
From: Anas Iqbal <mohd.abd.6602@gmail.com>
Smatch warns:
io_uring/zcrx.c:393 io_allocate_rbuf_ring() warn: should 'id << 16' be a 64 bit type?
The expression 'id << IORING_OFF_PBUF_SHIFT' is evaluated using 32-bit
arithmetic because id is a u32. This may overflow before being promoted
to the 64-bit mmap_offset.
Cast id to u64 before shifting to ensure the shift is performed in
64-bit arithmetic.
Signed-off-by: Anas Iqbal <mohd.abd.6602@gmail.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 1ce867c68446..b8f15439d5df 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -384,7 +384,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
return -EINVAL;
mmap_offset = IORING_MAP_OFF_ZCRX_REGION;
- mmap_offset += id << IORING_OFF_PBUF_SHIFT;
+ mmap_offset += (u64)id << IORING_OFF_PBUF_SHIFT;
ret = io_create_region(ctx, &ifq->rq_region, rd, mmap_offset);
if (ret < 0)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH io_uring-7.1 v3 3/6] io_uring/zcrx: don't use mark0 for allocating xarray
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 1/6] io_uring/zcrx: reject REG_NODEV with large rx_buf_size Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 2/6] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring() Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 4/6] io_uring/zcrx: don't clear not allocated niovs Pavel Begunkov
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev
XA_MARK_0 is not compatible with xarray allocating entries, use
XA_MARK_1.
Fixes: fda90d43f4fac ("io_uring/zcrx: return back two step unregistration")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index b8f15439d5df..5c0a49340722 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -929,12 +929,12 @@ int io_register_zcrx(struct io_ring_ctx *ctx,
static inline bool is_zcrx_entry_marked(struct io_ring_ctx *ctx, unsigned long id)
{
- return xa_get_mark(&ctx->zcrx_ctxs, id, XA_MARK_0);
+ return xa_get_mark(&ctx->zcrx_ctxs, id, XA_MARK_1);
}
static inline void set_zcrx_entry_mark(struct io_ring_ctx *ctx, unsigned long id)
{
- xa_set_mark(&ctx->zcrx_ctxs, id, XA_MARK_0);
+ xa_set_mark(&ctx->zcrx_ctxs, id, XA_MARK_1);
}
void io_terminate_zcrx(struct io_ring_ctx *ctx)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH io_uring-7.1 v3 4/6] io_uring/zcrx: don't clear not allocated niovs
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
` (2 preceding siblings ...)
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 3/6] io_uring/zcrx: don't use mark0 for allocating xarray Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 5/6] io_uring/zcrx: use dma_len for chunk size calculation Pavel Begunkov
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev
Now that area->is_mapped is set earlier before niovs array is allocated,
io_zcrx_free_area -> io_zcrx_unmap_area in an error path can try to
clear dma addresses for unallocated niovs, fix it.
Fixes: 8c0cab0b7bf76 ("always dma map in advance")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 5c0a49340722..d84ad40eae49 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -289,8 +289,10 @@ static void io_zcrx_unmap_area(struct io_zcrx_ifq *ifq,
return;
area->is_mapped = false;
- for (i = 0; i < area->nia.num_niovs; i++)
- net_mp_niov_set_dma_addr(&area->nia.niovs[i], 0);
+ if (area->nia.niovs) {
+ for (i = 0; i < area->nia.num_niovs; i++)
+ net_mp_niov_set_dma_addr(&area->nia.niovs[i], 0);
+ }
if (area->mem.is_dmabuf) {
io_release_dmabuf(&area->mem);
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH io_uring-7.1 v3 5/6] io_uring/zcrx: use dma_len for chunk size calculation
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
` (3 preceding siblings ...)
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 4/6] io_uring/zcrx: don't clear not allocated niovs Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 6/6] io_uring/zcrx: use correct mmap off constants Pavel Begunkov
2026-04-01 13:39 ` [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Jens Axboe
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev
Buffers are now dma-mapped earlier and we can sg_dma_len(), otherwise,
since it's walking with for_each_sgtable_dma_sg(), it might wrongfully
reject some configurations. As a bonus, it'd now be able to use larger
chunks if dma addresses are coalesced e.g by iommu.
Fixes: 8c0cab0b7bf76 ("always dma map in advance")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index d84ad40eae49..3bf800426fd2 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -63,7 +63,7 @@ static int io_area_max_shift(struct io_zcrx_mem *mem)
unsigned i;
for_each_sgtable_dma_sg(sgt, sg, i)
- shift = min(shift, __ffs(sg->length));
+ shift = min(shift, __ffs(sg_dma_len(sg)));
return shift;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH io_uring-7.1 v3 6/6] io_uring/zcrx: use correct mmap off constants
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
` (4 preceding siblings ...)
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 5/6] io_uring/zcrx: use dma_len for chunk size calculation Pavel Begunkov
@ 2026-03-31 21:07 ` Pavel Begunkov
2026-04-01 13:39 ` [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Jens Axboe
6 siblings, 0 replies; 8+ messages in thread
From: Pavel Begunkov @ 2026-03-31 21:07 UTC (permalink / raw)
To: io-uring; +Cc: asml.silence, axboe, netdev
zcrx was using IORING_OFF_PBUF_SHIFT during first iterations, but there
is now a separate constant it should use. Both are 16 so it doesn't
change anything, but improve it for the future.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
io_uring/zcrx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/io_uring/zcrx.c b/io_uring/zcrx.c
index 3bf800426fd2..bd970fb084c1 100644
--- a/io_uring/zcrx.c
+++ b/io_uring/zcrx.c
@@ -386,7 +386,7 @@ static int io_allocate_rbuf_ring(struct io_ring_ctx *ctx,
return -EINVAL;
mmap_offset = IORING_MAP_OFF_ZCRX_REGION;
- mmap_offset += (u64)id << IORING_OFF_PBUF_SHIFT;
+ mmap_offset += (u64)id << IORING_OFF_ZCRX_SHIFT;
ret = io_create_region(ctx, &ifq->rq_region, rd, mmap_offset);
if (ret < 0)
--
2.53.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes
2026-03-31 21:07 [PATCH io_uring-7.1 v3 0/6] follow up zcrx fixes Pavel Begunkov
` (5 preceding siblings ...)
2026-03-31 21:07 ` [PATCH io_uring-7.1 v3 6/6] io_uring/zcrx: use correct mmap off constants Pavel Begunkov
@ 2026-04-01 13:39 ` Jens Axboe
6 siblings, 0 replies; 8+ messages in thread
From: Jens Axboe @ 2026-04-01 13:39 UTC (permalink / raw)
To: io-uring, Pavel Begunkov; +Cc: netdev
On Tue, 31 Mar 2026 22:07:37 +0100, Pavel Begunkov wrote:
> Follow up fixes for the recent update flagged by review.
>
> v3: include the mmap_offset cast patch from Anas
> v2: reject REG_NODEV + ->rx_buf_size
>
> Anas Iqbal (1):
> io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring()
>
> [...]
Applied, thanks!
[1/6] io_uring/zcrx: reject REG_NODEV with large rx_buf_size
commit: f13bf23a829f39f21ac6e0757efe11304fff0e6a
[2/6] io_uring: cast id to u64 before shifting in io_allocate_rbuf_ring()
commit: 42cf59688914875d6eb06c9674a4b33984e6dd45
[3/6] io_uring/zcrx: don't use mark0 for allocating xarray
commit: f168ed94b91a63165b99abb868eb3df01b5b5aef
[4/6] io_uring/zcrx: don't clear not allocated niovs
commit: 600bf4721005b73763089328f17e5248dba2c034
[5/6] io_uring/zcrx: use dma_len for chunk size calculation
commit: 5ad086c24beda5154ca21495cbc32903d6d64337
[6/6] io_uring/zcrx: use correct mmap off constants
commit: a49d0b79efc770727ccc9f962afa22fdb99736de
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread