Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/net: fix zc fixed buf lifetime

Notifications usually outlive requests, so we need to pin buffers with
it by assigning a rsrc to it instead of the request.

Fixed: b48c312be05e8 ("io_uring/net: simplify zerocopy send user API")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/dd6406ff8a90887f2b36ed6205dac9fda17c1f35.1663366886.git.asml.silence@gmail.com
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
e3366e02 fc7222c3

+9 -9
+9 -9
io_uring/net.c
··· 905 905 if (zc->flags & ~(IORING_RECVSEND_POLL_FIRST | 906 906 IORING_RECVSEND_FIXED_BUF)) 907 907 return -EINVAL; 908 - if (zc->flags & IORING_RECVSEND_FIXED_BUF) { 909 - unsigned idx = READ_ONCE(sqe->buf_index); 910 - 911 - if (unlikely(idx >= ctx->nr_user_bufs)) 912 - return -EFAULT; 913 - idx = array_index_nospec(idx, ctx->nr_user_bufs); 914 - req->imu = READ_ONCE(ctx->user_bufs[idx]); 915 - io_req_set_rsrc_node(req, ctx, 0); 916 - } 917 908 notif = zc->notif = io_alloc_notif(ctx); 918 909 if (!notif) 919 910 return -ENOMEM; ··· 912 921 notif->cqe.res = 0; 913 922 notif->cqe.flags = IORING_CQE_F_NOTIF; 914 923 req->flags |= REQ_F_NEED_CLEANUP; 924 + if (zc->flags & IORING_RECVSEND_FIXED_BUF) { 925 + unsigned idx = READ_ONCE(sqe->buf_index); 926 + 927 + if (unlikely(idx >= ctx->nr_user_bufs)) 928 + return -EFAULT; 929 + idx = array_index_nospec(idx, ctx->nr_user_bufs); 930 + req->imu = READ_ONCE(ctx->user_bufs[idx]); 931 + io_req_set_rsrc_node(notif, ctx, 0); 932 + } 915 933 916 934 zc->buf = u64_to_user_ptr(READ_ONCE(sqe->addr)); 917 935 zc->len = READ_ONCE(sqe->len);