]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
scsi: core: Drop using the host_lock to protect async_scan race condition
authorChaohai Chen <wdhh6@aliyun.com>
Thu, 5 Mar 2026 02:51:24 +0000 (10:51 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Sat, 7 Mar 2026 15:58:33 +0000 (10:58 -0500)
commit7a3aff163c77159d262217382ec0e9c06c847b46
tree51955c6258877d18fc01c54f13b2c40d8b092c70
parent1bf5c303eb9898930c5313769df14a76c51075c1
scsi: core: Drop using the host_lock to protect async_scan race condition

Previously, host_lock was used to prevent bit-set conflicts in async_scan,
but this approach introduced naked reads in some code paths.

Convert async_scan from a bitfield to a bool type to eliminate bit-level
conflicts entirely. Use __guarded_by(&scan_mutex) to indicate that the
async_scan variable is protected by scan_mutex.

Signed-off-by: Chaohai Chen <wdhh6@aliyun.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://patch.msgid.link/20260305025125.3649517-1-wdhh6@aliyun.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_scan.c
include/scsi/scsi_host.h