Re: [PATCH v7] loop: Fix NULL pointer dereference in lo_rw_aio()

From: Tetsuo Handa

Date: Sat Aug 29 2026 - 01:56:30 EST


On 2026/08/29 14:17, Tetsuo Handa wrote:
> Also, this
> synchronize_rcu() => drain_workqueue() => blk_mq_freeze_queue() ordering
> guarantees that q_usage_counter won't be incremented again after it once
> reached 0, due to the lo->lo_state != Lo_bound check in loop_queue_rq().

Well, this part was inaccurate. Since q_usage_counter is incremented before
loop_queue_rq() is called, it is possible that q_usage_counter itself can be
incremented even after synchronize_rcu() => drain_workqueue() => blk_mq_freeze_queue()
sequence.

But what makes this ordering safe are

(1) since we are in lo_release() with disk_openers(disk) == 0, the activity of
incrementing/decrementing q_usage_counter (incremented before loop_queue_rq()
is called, and decremented after loop_queue_rq() returned BLK_STS_IOERR)) will
cease shortly

(2) since there is no pending work in lo->workqueue, no I/O will be made to
backing file

.