In the Linux kernel, the following vulnerability has been resolved:
block: fix uaf for flush rq while iterating tags
blkmqclearflushrqmapping() is not called during scsi probe, by checking blkqueueinitdone(). However, QUEUEFLAGINITDONE is cleared in delgendisk by commit aec89dc5d421 ("block: keep qusagecounter in atomic mode after delgendisk"), hence for disk like scsi, following blkmqdestroyqueue() will not clear flush rq from tags->rqs[] as well, cause following uaf that is found by our syzkaller for v6.6:
================================================================== BUG: KASAN: slab-use-after-free in blkmqfindandget_req+0x16e/0x1a0 block/blk-mq-tag.c:261 Read of size 4 at addr ffff88811c969c20 by task kworker/1:2H/224909
CPU: 1 PID: 224909 Comm: kworker/1:2H Not tainted 6.6.0-ga836a5060850 #32 Workqueue: kblockd blkmqtimeout_work Call Trace:
_dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0x91/0xf0 lib/dumpstack.c:106 printaddressdescription.constprop.0+0x66/0x300 mm/kasan/report.c:364 printreport+0x3e/0x70 mm/kasan/report.c:475 kasanreport+0xb8/0xf0 mm/kasan/report.c:588 blkmqfindandgetreq+0x16e/0x1a0 block/blk-mq-tag.c:261 btiter block/blk-mq-tag.c:288 [inline] _sbitmapforeachset include/linux/sbitmap.h:295 [inline] sbitmapforeachset include/linux/sbitmap.h:316 [inline] btforeach+0x455/0x790 block/blk-mq-tag.c:325 blkmqqueuetagbusyiter+0x320/0x740 block/blk-mq-tag.c:534 blkmqtimeoutwork+0x1a3/0x7b0 block/blk-mq.c:1673 processonework+0x7c4/0x1450 kernel/workqueue.c:2631 processscheduledworks kernel/workqueue.c:2704 [inline] workerthread+0x804/0xe40 kernel/workqueue.c:2785 kthread+0x346/0x450 kernel/kthread.c:388 retfromfork+0x4d/0x80 arch/x86/kernel/process.c:147 retfromforkasm+0x1b/0x30 arch/x86/entry/entry64.S:293
Allocated by task 942: kasansavestack+0x22/0x50 mm/kasan/common.c:45 kasansettrack+0x25/0x30 mm/kasan/common.c:52 _kasankmalloc mm/kasan/common.c:374 [inline] _kasankmalloc mm/kasan/common.c:383 [inline] _kasankmalloc+0xaa/0xb0 mm/kasan/common.c:380 kasankmalloc include/linux/kasan.h:198 [inline] _dokmallocnode mm/slabcommon.c:1007 [inline] _kmallocnode+0x69/0x170 mm/slabcommon.c:1014 kmallocnode include/linux/slab.h:620 [inline] kzallocnode include/linux/slab.h:732 [inline] blkallocflushqueue+0x144/0x2f0 block/blk-flush.c:499 blkmqallochctx+0x601/0x940 block/blk-mq.c:3788 blkmqallocandinithctx+0x27f/0x330 block/blk-mq.c:4261 blkmqreallochwctxs+0x488/0x5e0 block/blk-mq.c:4294 blkmqinitallocatedqueue+0x188/0x860 block/blk-mq.c:4350 blkmqinitqueuedata block/blk-mq.c:4166 [inline] blkmqinitqueue+0x8d/0x100 block/blk-mq.c:4176 scsiallocsdev+0x843/0xd50 drivers/scsi/scsiscan.c:335 scsiprobeandaddlun+0x77c/0xde0 drivers/scsi/scsiscan.c:1189 _scsiscantarget+0x1fc/0x5a0 drivers/scsi/scsiscan.c:1727 scsiscanchannel drivers/scsi/scsiscan.c:1815 [inline] scsiscanchannel+0x14b/0x1e0 drivers/scsi/scsiscan.c:1791 scsiscanhostselected+0x2fe/0x400 drivers/scsi/scsiscan.c:1844 scsiscan+0x3a0/0x3f0 drivers/scsi/scsisysfs.c:151 storescan+0x2a/0x60 drivers/scsi/scsisysfs.c:191 devattrstore+0x5c/0x90 drivers/base/core.c:2388 sysfskfwrite+0x11c/0x170 fs/sysfs/file.c:136 kernfsfopwriteiter+0x3fc/0x610 fs/kernfs/file.c:338 callwriteiter include/linux/fs.h:2083 [inline] newsyncwrite+0x1b4/0x2d0 fs/readwrite.c:493 vfswrite+0x76c/0xb00 fs/readwrite.c:586 ksyswrite+0x127/0x250 fs/readwrite.c:639 dosyscallx64 arch/x86/entry/common.c:51 [inline] dosyscall64+0x70/0x120 arch/x86/entry/common.c:81 entrySYSCALL64afterhwframe+0x78/0xe2
Freed by task 244687: kasansavestack+0x22/0x50 mm/kasan/common.c:45 kasansettrack+0x25/0x30 mm/kasan/common.c:52 kasansavefreeinfo+0x2b/0x50 mm/kasan/generic.c:522 __kasanslabfree mm/kasan/common.c:236 [inline] _kasanslabfree+0x12a/0x1b0 mm/kasan/common.c:244 kasanslabfree include/linux/kasan.h:164 [in ---truncated---
[ { "signature_type": "Line", "id": "CVE-2024-53170-070c00ba", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1364a29b71c7837770f1902c49e7a6e234d72c92", "signature_version": "v1", "target": { "file": "block/genhd.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "26180347749609627011156492870408266363", "106726058589320586807568975058314335673", "26777224887928278244487086665368094381", "183290086768379264415930562572136826112", "176160636786313398079117350409690657752", "295327700295782710126894612180309810905", "176033935933596329357629572135350890535", "307654399016011541556245066728735573556", "301543497939770554507271172253650122874", "339477210590479008351960029382344081679" ] }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-1ee92a54", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1921fe7d2836f8be1d321cf430d17e0d4e05301b", "signature_version": "v1", "target": { "file": "block/genhd.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "26180347749609627011156492870408266363", "106726058589320586807568975058314335673", "26777224887928278244487086665368094381", "183290086768379264415930562572136826112", "176160636786313398079117350409690657752", "295327700295782710126894612180309810905", "176033935933596329357629572135350890535", "307654399016011541556245066728735573556", "301543497939770554507271172253650122874", "339477210590479008351960029382344081679" ] }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-221d39fd", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61092568f2a9acb0e6e186f03f2e0649a4e86d09", "signature_version": "v1", "target": { "file": "block/genhd.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "26180347749609627011156492870408266363", "106726058589320586807568975058314335673", "26777224887928278244487086665368094381", "183290086768379264415930562572136826112", "176160636786313398079117350409690657752", "295327700295782710126894612180309810905", "176033935933596329357629572135350890535", "304084974934089263834713353246776235363", "244336492328232213662999164982801534182", "316153879444976391627996140833333507965" ] }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-299f3900", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1921fe7d2836f8be1d321cf430d17e0d4e05301b", "signature_version": "v1", "target": { "file": "block/blk-sysfs.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "270011809305292016215858131016489688768", "199075678229977209668127391757345742316", "226321724074582064393835465923396403041", "249394881704994028525975310138935384106", "305573897622035216334142330738292142780", "18122636122904531290347986214510215400", "119518044430877753815539433639373128535" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-43ccbca4", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61092568f2a9acb0e6e186f03f2e0649a4e86d09", "signature_version": "v1", "target": { "function": "blk_register_queue", "file": "block/blk-sysfs.c" }, "digest": { "function_hash": "11631575543803991217179751372086123040", "length": 1512.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-50446f28", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3802f73bd80766d70f319658f334754164075bc3", "signature_version": "v1", "target": { "file": "block/blk-sysfs.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "106531853403570336676129305236485284192", "116155636943175211413161189342956673745", "226321724074582064393835465923396403041", "249394881704994028525975310138935384106", "305573897622035216334142330738292142780", "14423786247845209804175171592951926311", "318392177359290730275528046772630853764" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-506a041c", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1364a29b71c7837770f1902c49e7a6e234d72c92", "signature_version": "v1", "target": { "function": "del_gendisk", "file": "block/genhd.c" }, "digest": { "function_hash": "203618991808990785838927077585283068080", "length": 1565.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-63d5d909", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a0e93b9fefafe97d596f9c98701ae6c3b04b3ff6", "signature_version": "v1", "target": { "file": "block/genhd.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "26180347749609627011156492870408266363", "106726058589320586807568975058314335673", "26777224887928278244487086665368094381", "183290086768379264415930562572136826112", "176160636786313398079117350409690657752", "295327700295782710126894612180309810905", "176033935933596329357629572135350890535", "304084974934089263834713353246776235363", "244336492328232213662999164982801534182", "316153879444976391627996140833333507965" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-6fa698b9", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1921fe7d2836f8be1d321cf430d17e0d4e05301b", "signature_version": "v1", "target": { "function": "blk_register_queue", "file": "block/blk-sysfs.c" }, "digest": { "function_hash": "242624173700129443794055938087567333204", "length": 1273.0 }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-74989cad", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3802f73bd80766d70f319658f334754164075bc3", "signature_version": "v1", "target": { "function": "blk_register_queue", "file": "block/blk-sysfs.c" }, "digest": { "function_hash": "11631575543803991217179751372086123040", "length": 1512.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-96cc082e", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1364a29b71c7837770f1902c49e7a6e234d72c92", "signature_version": "v1", "target": { "file": "block/blk-sysfs.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "106531853403570336676129305236485284192", "116155636943175211413161189342956673745", "226321724074582064393835465923396403041", "249394881704994028525975310138935384106", "305573897622035216334142330738292142780", "14423786247845209804175171592951926311", "318392177359290730275528046772630853764" ] }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-a08a2382", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a0e93b9fefafe97d596f9c98701ae6c3b04b3ff6", "signature_version": "v1", "target": { "file": "block/blk-sysfs.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "106531853403570336676129305236485284192", "116155636943175211413161189342956673745", "226321724074582064393835465923396403041", "249394881704994028525975310138935384106", "305573897622035216334142330738292142780", "14423786247845209804175171592951926311", "318392177359290730275528046772630853764" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-a158c98d", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61092568f2a9acb0e6e186f03f2e0649a4e86d09", "signature_version": "v1", "target": { "function": "del_gendisk", "file": "block/genhd.c" }, "digest": { "function_hash": "73042360516869482484932416720015541984", "length": 1688.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-a47a8b91", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3802f73bd80766d70f319658f334754164075bc3", "signature_version": "v1", "target": { "file": "block/genhd.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "26180347749609627011156492870408266363", "106726058589320586807568975058314335673", "26777224887928278244487086665368094381", "183290086768379264415930562572136826112", "176160636786313398079117350409690657752", "295327700295782710126894612180309810905", "176033935933596329357629572135350890535", "304084974934089263834713353246776235363", "244336492328232213662999164982801534182", "316153879444976391627996140833333507965" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-b1805358", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1364a29b71c7837770f1902c49e7a6e234d72c92", "signature_version": "v1", "target": { "function": "blk_register_queue", "file": "block/blk-sysfs.c" }, "digest": { "function_hash": "62198031984653643182300714801497476326", "length": 1533.0 }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-b209c19c", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@3802f73bd80766d70f319658f334754164075bc3", "signature_version": "v1", "target": { "function": "del_gendisk", "file": "block/genhd.c" }, "digest": { "function_hash": "73042360516869482484932416720015541984", "length": 1688.0 }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-bc651e21", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1921fe7d2836f8be1d321cf430d17e0d4e05301b", "signature_version": "v1", "target": { "function": "del_gendisk", "file": "block/genhd.c" }, "digest": { "function_hash": "140255925300066271539873973410310950382", "length": 1510.0 }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-be13d552", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a0e93b9fefafe97d596f9c98701ae6c3b04b3ff6", "signature_version": "v1", "target": { "function": "blk_register_queue", "file": "block/blk-sysfs.c" }, "digest": { "function_hash": "11631575543803991217179751372086123040", "length": 1512.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2024-53170-d93d1e24", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@61092568f2a9acb0e6e186f03f2e0649a4e86d09", "signature_version": "v1", "target": { "file": "block/blk-sysfs.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "106531853403570336676129305236485284192", "116155636943175211413161189342956673745", "226321724074582064393835465923396403041", "249394881704994028525975310138935384106", "305573897622035216334142330738292142780", "14423786247845209804175171592951926311", "318392177359290730275528046772630853764" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2024-53170-ed4a6a6a", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a0e93b9fefafe97d596f9c98701ae6c3b04b3ff6", "signature_version": "v1", "target": { "function": "del_gendisk", "file": "block/genhd.c" }, "digest": { "function_hash": "73042360516869482484932416720015541984", "length": 1688.0 }, "deprecated": false } ]