ublk: fix null-ptr-deref in ublk_queue_cmd#917
Conversation
|
Upstream branch: e43ffb6 |
c6dc343 to
fc36596
Compare
|
Upstream branch: ba3e43a |
f266c19 to
f2d87d4
Compare
fc36596 to
7bed9c3
Compare
|
Upstream branch: ddd664b |
f2d87d4 to
07251c7
Compare
7bed9c3 to
a7bb5c5
Compare
|
Upstream branch: 979c294 |
07251c7 to
48b4d93
Compare
a7bb5c5 to
5e41a3b
Compare
|
Upstream branch: acb7500 |
48b4d93 to
24308c5
Compare
5e41a3b to
c3a084b
Compare
|
Upstream branch: 9716c08 |
24308c5 to
f1a0a92
Compare
c3a084b to
5f78e5d
Compare
|
Upstream branch: 2a2974b |
f1a0a92 to
8b0e958
Compare
5f78e5d to
e48f9db
Compare
|
Upstream branch: 062871f |
8b0e958 to
eedaf12
Compare
199644a to
e6d9eb8
Compare
|
Upstream branch: 66affa3 |
eedaf12 to
7151b53
Compare
e6d9eb8 to
7d8604f
Compare
ublk_queue_cmd() dereferences ios[tag].cmd without NULL check. The cmd
pointer can be NULL when ublk_cancel_cmd() races with IO dispatch during
server teardown:
CPU0 (partition scan work) CPU1 (io_uring cancel callback)
ublk_queue_rq()
ublk_prep_req() -> OK
check canceling -> false
ublk_start_cancel()
quiesce, set canceling, unquiesce
ublk_cancel_cmd()
io->cmd = NULL
ublk_queue_cmd()
cmd = ios[tag].cmd -> NULL
ublk_get_uring_cmd_pdu(cmd) -> null-ptr-deref
The race window exists because ublk_cancel_cmd() can execute between the
canceling flag check and the cmd dereference in ublk_queue_cmd(). This
cannot be closed with simple synchronization since blk_mq_quiesce_queue
only waits for in-flight dispatches, not requests already past the
canceling check.
Fix by checking cmd for NULL before dereferencing. When NULL, abort the
request via __ublk_abort_rq() which handles both recovery (requeue) and
non-recovery (end with IOERR) cases.
Fixes: 71f28f3 ("ublk_drv: add io_uring based userspace block driver")
Reported-by: syzbot+415b9ec753cd2a196087@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=415b9ec753cd2a196087
Signed-off-by: Yun Zhou <yun.zhou@windriver.com>
|
Upstream branch: bade58e |
7151b53 to
2cb8d67
Compare
Pull request for series with
subject: ublk: fix null-ptr-deref in ublk_queue_cmd
version: 1
url: https://patchwork.kernel.org/project/linux-block/list/?series=1104193