Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: sg: Do not sleep in atomic context

sg_finish_rem_req() calls blk_rq_unmap_user(). The latter function may
sleep. Hence, call sg_finish_rem_req() with interrupts enabled instead
of disabled.

Reported-by: syzbot+c01f8e6e73f20459912e@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-scsi/691560c4.a70a0220.3124cb.001a.GAE@google.com/
Cc: Hannes Reinecke <hare@suse.de>
Cc: stable@vger.kernel.org
Fixes: 97d27b0dd015 ("scsi: sg: close race condition in sg_remove_sfp_usercontext()")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Link: https://patch.msgid.link/20251113181643.1108973-1-bvanassche@acm.org
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Bart Van Assche and committed by
Martin K. Petersen
90449f2d e6965188

+9 -1
+9 -1
drivers/scsi/sg.c
··· 2208 2208 write_lock_irqsave(&sfp->rq_list_lock, iflags); 2209 2209 while (!list_empty(&sfp->rq_list)) { 2210 2210 srp = list_first_entry(&sfp->rq_list, Sg_request, entry); 2211 - sg_finish_rem_req(srp); 2212 2211 list_del(&srp->entry); 2212 + write_unlock_irqrestore(&sfp->rq_list_lock, iflags); 2213 + 2214 + sg_finish_rem_req(srp); 2215 + /* 2216 + * sg_rq_end_io() uses srp->parentfp. Hence, only clear 2217 + * srp->parentfp after blk_mq_free_request() has been called. 2218 + */ 2213 2219 srp->parentfp = NULL; 2220 + 2221 + write_lock_irqsave(&sfp->rq_list_lock, iflags); 2214 2222 } 2215 2223 write_unlock_irqrestore(&sfp->rq_list_lock, iflags); 2216 2224