Skip to content

Commit 08ca140

Browse files
isilenceaxboe
authored andcommitted
io_uring/zcrx: disallow user selected dmabuf offset and size
zcrx shouldn't be so frivolous about cutting a dmabuf sgtable and taking a subrange into it, the dmabuf layer might be not expecting that. It shouldn't be a problem for now, but since the zcrx dmabuf support is new and there shouldn't be any real users, let's play safe and reject user provided ranges into dmabufs. Also, it shouldn't be needed as userspace should size them appropriately. Fixes: a5c98e9 ("io_uring/zcrx: dmabuf backed zerocopy receive") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/be899f1afed32053eb2e2079d0da241514674aca.1752443579.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 9dff55e commit 08ca140

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

io_uring/zcrx.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static int io_import_dmabuf(struct io_zcrx_ifq *ifq,
7676
int dmabuf_fd = area_reg->dmabuf_fd;
7777
int i, ret;
7878

79+
if (off)
80+
return -EINVAL;
7981
if (WARN_ON_ONCE(!ifq->dev))
8082
return -EFAULT;
8183
if (!IS_ENABLED(CONFIG_DMA_SHARED_BUFFER))
@@ -106,7 +108,7 @@ static int io_import_dmabuf(struct io_zcrx_ifq *ifq,
106108
for_each_sgtable_dma_sg(mem->sgt, sg, i)
107109
total_size += sg_dma_len(sg);
108110

109-
if (total_size < off + len) {
111+
if (total_size != len) {
110112
ret = -EINVAL;
111113
goto err;
112114
}

0 commit comments

Comments
 (0)