Commit 18d6b17
committed
io_uring/rw: check for NULL io_br_sel when putting a buffer
Both the read and write side use kiocb_done() to finish a request, and
kiocb_done() will call io_put_kbuf() in case a provided buffer was used
for the request. Provided buffers are not supported for writes, hence
NULL is being passed in. This normally works fine, as io_put_kbuf()
won't actually use the value unless REQ_F_BUFFER_RING or
REQ_F_BUFFER_SELECTED is set in the request flags. But depending on
compiler (or whether or not CONFIG_CC_OPTIMIZE_FOR_SIZE is set), that
may be done even though the value is never used. This will then cause a
NULL pointer dereference.
Make it a bit more obvious and check for a NULL io_br_sel, and don't
even bother calling io_put_kbuf() for that case.
Fixes: 5fda512 ("io_uring/kbuf: switch to storing struct io_buffer_list locally")
Reported-by: David Howells <[email protected]>
Tested-by: David Howells <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>1 parent 437c233 commit 18d6b17
1 file changed
+5
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
655 | 655 | | |
656 | 656 | | |
657 | 657 | | |
| 658 | + | |
| 659 | + | |
658 | 660 | | |
659 | 661 | | |
660 | 662 | | |
661 | 663 | | |
662 | 664 | | |
663 | 665 | | |
664 | | - | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
665 | 669 | | |
666 | 670 | | |
667 | 671 | | |
| |||
0 commit comments