Skip to contentSkip to conversation

io_uring/zcrx: improve types for size calculation

PATCH Applied Pavel Begunkov 2 participants 2 messages Feb 5 – Feb 10

Subsystems (4)
lore
Share & tools
lore

Pavel Begunkov

author maintainer
#0 lore raw

PATCH 1/1 io_uring/zcrx: improve types for size calculation

Make sure io_import_umem() promotes the type to long before calculating the area size. While the area size is capped at 1GB by io_validate_user_buf_range() and fits into an "int", it's still too error prone.

---
 io_uring/zcrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/zcrx.c +1 -1
index 8a9df72bc094..6a6e2f8d6133 100644
@@ -205,7 +205,7 @@ static int io_import_umem(struct io_zcrx_ifq *ifq,
 		return PTR_ERR(pages);
 
 	ret = sg_alloc_table_from_pages(&mem->page_sg_table, pages, nr_pages,
-					0, nr_pages << PAGE_SHIFT,
+					0, (unsigned long)nr_pages << PAGE_SHIFT,
 					GFP_KERNEL_ACCOUNT);
 	if (ret) {
 		unpin_user_pages(pages, nr_pages);
Signature · 1 line
2.52.0
maintainer Applied
#1 lore raw
Quoted 6 lines · Pavel Begunkov

Make sure io_import_umem() promotes the type to long before calculating the area size. While the area size is capped at 1GB by io_validate_user_buf_range() and fits into an "int", it's still too error prone.

Applied, thanks!

[1/1] io_uring/zcrx: improve types for size calculation

      commit: 417d029dc412c1028bce3d4685700332c0539a95

Best regards,

Signature · 1 line
Jens Axboe