Re: [PATCH v7] loop: Fix NULL pointer dereference in lo_rw_aio()
From: Bart Van Assche
Date: Mon Aug 31 2026 - 16:56:36 EST
On 8/31/26 7:11 AM, Tao Cui wrote:
From: Tao Cui <cuitao@xxxxxxxxxx>This is the code that protects .queue_rq() implementations like
Hi Tetsuo, Bart,
+ /* Step 1: Flush all outstanding I/O, without open_mutex held. */
+ /*
+ * Now that loop_queue_rq() sees lo->lo_state != Lo_bound,
+ * wait for already started loop_queue_rq() to complete.
+ */
+ synchronize_rcu();
Your reply to Bart says loop_queue_rq() is called with RCU read
lock, but I don't see one.
loop_queue_rq() with an rcu_read_lock() / rcu_read_unlock() pair:
/* run the code block in @dispatch_ops with rcu/srcu read lock held */
#define __blk_mq_run_dispatch_ops(q, check_sleep, dispatch_ops) \
do { \
if ((q)->tag_set->flags & BLK_MQ_F_BLOCKING) { \
struct blk_mq_tag_set *__tag_set = (q)->tag_set; \
int srcu_idx; \
\
might_sleep_if(check_sleep); \
srcu_idx = srcu_read_lock(__tag_set->srcu); \
(dispatch_ops); \
srcu_read_unlock(__tag_set->srcu, srcu_idx); \
} else { \
rcu_read_lock(); \
(dispatch_ops); \
rcu_read_unlock(); \
} \
} while (0)
Bart.