io_uring: check for user passing 0 nr_submit
PATCH v2 1/1 io_uring: check for user passing 0 nr_submit
io_submit_sqes() shouldn't be stepping into its main loop when there is nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks, which should follow after all user input truncations.
---
v2: split out of the series with extra tags, no functional changes
io_uring/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
io_uring/io_uring.c +3 -2
@@ -2422,10 +2422,11 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)unsigned int left;int ret; + entries =min (nr, entries);if (unlikely (!entries))return 0 ; -/* make sure SQ entry isn't read before tail */ - ret = left =min (nr, entries); + + ret = left = entries;io_get_task_refs (left);io_submit_state_start (&ctx->submit_state, left);
Signature · 1 line
2.49.0
Quoted 3 lines · Pavel Begunkov
io_submit_sqes()shouldn't be stepping into its main loop when there is nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks, which should follow after all user input truncations.
I see two callers of io_submit_sqes, and neither of them will pass 0 for nr. What am I missing?
-Jeff
Quoted 28 lines
Fixes 6962980947e2b ("io_uring: restructure submit sqes to_submit checks")Signed-off-by Pavel Begunkov <[email protected]>---
v2: split out of the series with extra tags, no functional changes
io_uring/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)io_uring/io_uring.c +3
-2@@ -2422,10 +2422,11 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)unsigned int left;int ret; + entries =min (nr, entries);if (unlikely (!entries))return 0 ; -/* make sure SQ entry isn't read before tail */ - ret = left =min (nr, entries); + + ret = left = entries;io_get_task_refs (left);io_submit_state_start (&ctx->submit_state, left);
Quoted 8 lines · Jeff Moyer
Quoted 3 lines · Pavel Begunkov
io_submit_sqes()shouldn't be stepping into its main loop when there is nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks, which should follow after all user input truncations.I see two callers of
io_submit_sqes, and neither of them will pass 0 for nr. What am I missing?
You're right, we can drop the fixes/stable part. It's still good to have as it's handled not in the best way.
Quoted 28 lines
Quoted 27 lines
Fixes 6962980947e2b ("io_uring: restructure submit sqes to_submit checks")Signed-off-by Pavel Begunkov <[email protected]>---
v2: split out of the series with extra tags, no functional changes
io_uring/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)io_uring/io_uring.c +3
-2@@ -2422,10 +2422,11 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)unsigned int left;int ret; + entries =min (nr, entries);if (unlikely (!entries))return 0 ; -/* make sure SQ entry isn't read before tail */ - ret = left =min (nr, entries); + + ret = left = entries;io_get_task_refs (left);io_submit_state_start (&ctx->submit_state, left);
Signature · 1 line
Pavel Begunkov
Quoted 6 lines · Pavel Begunkov
Quoted 5 lines · Jeff Moyer
Quoted 3 lines · Pavel Begunkov
io_submit_sqes()shouldn't be stepping into its main loop when there is nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks, which should follow after all user input truncations.
Quoted 6 lines
Quoted 3 lines
I see two callers of
io_submit_sqes, and neither of them will pass 0 for
nr. What am I missing?You're right, we can drop the fixes/stable part. It's still good to have as it's handled not in the best way.
Agreed.
Cheers,
Jeff
Quoted 29 lines
Quoted 29 lines
Quoted 28 lines
Fixes 6962980947e2b ("io_uring: restructure submit sqes to_submit checks")Signed-off-by Pavel Begunkov <[email protected]>---
v2: split out of the series with extra tags, no functional changes
io_uring/io_uring.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)io_uring/io_uring.c +2
-2@@ -2422,10 +2422,11 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)unsigned int left;int ret; + entries =min (nr, entries);if (unlikely (!entries))return 0 ; -/* make sure SQ entry isn't read before tail */ - ret = left =min (nr, entries); + + ret = left = entries;io_get_task_refs (left);io_submit_state_start (&ctx->submit_state, left);
Quoted 5 lines · Pavel Begunkov
io_submit_sqes()shouldn't be stepping into its main loop when there is nothing to submit, i.e. nr=0. Fix 0 submission queue entries checks, which should follow after all user input truncations.
Applied, thanks!
[1/1] io_uring: check for user passing 0 nr_submit
commit: dde92a5026d81df1a146e9c243d09b27d1bf04bf
Best regards,
Signature · 1 line
Jens Axboe