In the Linux kernel, the following vulnerability has been resolved:
erofs: handle overlapped pclusters out of crafted images properly
syzbot reported a task hang issue due to a deadlock case where it is waiting for the folio lock of a cached folio that will be used for cache I/Os.
After looking into the crafted fuzzed image, I found it's formed with several overlapped big pclusters as below:
Ext: logical offset | length : physical offset | length 0: 0.. 16384 | 16384 : 151552.. 167936 | 16384 1: 16384.. 32768 | 16384 : 155648.. 172032 | 16384 2: 32768.. 49152 | 16384 : 537223168.. 537239552 | 16384 ...
Here, extent 0/1 are physically overlapped although it's entirely impossible for normal filesystem images generated by mkfs.
First, managed folios containing compressed data will be marked as up-to-date and then unlocked immediately (unlike in-place folios) when compressed I/Os are complete. If physical blocks are not submitted in the incremental order, there should be separate BIOs to avoid dependency issues. However, the current code mis-arranges zerofsfillbiovec() and BIO submission which causes unexpected BIO waits.
Second, managed folios will be connected to their own pclusters for efficient inter-queries. However, this is somewhat hard to implement easily if overlapped big pclusters exist. Again, these only appear in fuzzed images so let's simply fall back to temporary short-lived pages for correctness.
Additionally, it justifies that referenced managed folios cannot be
truncated for now and reverts part of commit 2080ca1ed3e4 ("erofs: tidy
up struct z_erofs_bvec") for simplicity although it shouldn't be any
difference.
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b9b30af0e86ffb485301ecd83b9129c9dfb7ebf8",
"signature_type": "Function",
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "29877983055698798205577251531520993908",
"length": 2403.0
},
"id": "CVE-2024-47736-03d250c7",
"target": {
"function": "z_erofs_submit_queue",
"file": "fs/erofs/zdata.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9e2f9d34dd12e6e5b244ec488bcebd0c2d566c50",
"signature_type": "Line",
"deprecated": false,
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"302471898897965934711275746055357800717",
"72684516893652573072331147459101059581",
"189720238404727451757010781914665013013",
"95764443252241599690604475993743432463",
"64604338933666322055375226620083713332",
"211231387564352489484777683692975677651",
"78551692034975417488085905104977332962",
"336156264441644411974308975798508902274",
"95073786979590998668837861052098450417",
"309775624338105434238311656471893971482",
"70333880335401889743749958957516811466",
"337526749369211802101176196612720654395",
"18440687676575169937616953731617900077",
"11186359371198448966163660814356002577",
"234439078086413143997682317525377562291",
"298238863306050847578406034294597093147",
"184063500549554511732447181811165995552",
"63589226108198027642182188118399938546",
"74176877147334631160526684321275425812",
"120428750938007686291034966630766737036",
"246920886088096470021332920663933540227",
"89992135813014813305757622754196690266",
"312511735003465921687854555916232641244",
"338317350738615301994078848278494907933",
"114904628912700926779032713468585616620",
"308982541165378538681780504085588889500",
"45244689000156189286370137935092813046",
"125609476282926792193855377667412041995",
"41876867109607839313969451598121733173",
"147890373515116680876563854963110788444",
"337120301253651362864323803969152851984",
"113936300148728700588309428132810255291",
"329791826477676308433304900641597698991",
"76945666628637163777741343870554208519",
"55557314997533748833587093315048405071",
"190986061846415837606072842045750650270",
"196332330272754239109074745683478940143",
"35939116874639619238543386175661059371",
"121989458339070935089690442066756114404",
"88835914803348309889796019759827160675",
"153321108666929839776139685174861592068",
"111415801794603501424492681521184233642",
"173000328327456328013706821984174669798",
"75958852780952708669656388222565885670",
"260476725265572946104220152389558828883",
"247975071289809285836813676672204762002",
"73670340687333490597527168862319026651",
"37048714426637547006571239607125670425",
"289131021204126858811254213095507905933",
"127829106219764940289656446654192293042",
"248823934048711807750184983712923631180",
"280342113999918582316187778760035995448",
"17081406646766266207860847668798353263",
"338616447859076546316561312962283127700",
"145887687957168743226546142706936700932",
"166202178551369148535820818613354993828",
"287103650571165965187488093702589796320",
"322835406571537779239708826564322839198",
"2607405567906877075075439728976096220",
"329027165764530149274938498514576347613",
"57066465991894319330962150409794823016",
"339346118894118699372299155007364602235",
"194899238279134889663922572814206056883"
]
},
"id": "CVE-2024-47736-1b7be208",
"target": {
"file": "fs/erofs/zdata.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b9b30af0e86ffb485301ecd83b9129c9dfb7ebf8",
"signature_type": "Function",
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "303716570758851513853727836527034119898",
"length": 1919.0
},
"id": "CVE-2024-47736-9a7b0664",
"target": {
"function": "z_erofs_fill_bio_vec",
"file": "fs/erofs/zdata.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9e2f9d34dd12e6e5b244ec488bcebd0c2d566c50",
"signature_type": "Function",
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "303716570758851513853727836527034119898",
"length": 1919.0
},
"id": "CVE-2024-47736-bd59e2f6",
"target": {
"function": "z_erofs_fill_bio_vec",
"file": "fs/erofs/zdata.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9e2f9d34dd12e6e5b244ec488bcebd0c2d566c50",
"signature_type": "Function",
"deprecated": false,
"signature_version": "v1",
"digest": {
"function_hash": "29877983055698798205577251531520993908",
"length": 2403.0
},
"id": "CVE-2024-47736-c94d4095",
"target": {
"function": "z_erofs_submit_queue",
"file": "fs/erofs/zdata.c"
}
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b9b30af0e86ffb485301ecd83b9129c9dfb7ebf8",
"signature_type": "Line",
"deprecated": false,
"signature_version": "v1",
"digest": {
"threshold": 0.9,
"line_hashes": [
"302471898897965934711275746055357800717",
"72684516893652573072331147459101059581",
"189720238404727451757010781914665013013",
"95764443252241599690604475993743432463",
"64604338933666322055375226620083713332",
"211231387564352489484777683692975677651",
"78551692034975417488085905104977332962",
"336156264441644411974308975798508902274",
"95073786979590998668837861052098450417",
"309775624338105434238311656471893971482",
"70333880335401889743749958957516811466",
"337526749369211802101176196612720654395",
"18440687676575169937616953731617900077",
"11186359371198448966163660814356002577",
"234439078086413143997682317525377562291",
"298238863306050847578406034294597093147",
"184063500549554511732447181811165995552",
"63589226108198027642182188118399938546",
"74176877147334631160526684321275425812",
"120428750938007686291034966630766737036",
"246920886088096470021332920663933540227",
"89992135813014813305757622754196690266",
"312511735003465921687854555916232641244",
"338317350738615301994078848278494907933",
"114904628912700926779032713468585616620",
"308982541165378538681780504085588889500",
"45244689000156189286370137935092813046",
"125609476282926792193855377667412041995",
"41876867109607839313969451598121733173",
"147890373515116680876563854963110788444",
"337120301253651362864323803969152851984",
"113936300148728700588309428132810255291",
"329791826477676308433304900641597698991",
"76945666628637163777741343870554208519",
"55557314997533748833587093315048405071",
"190986061846415837606072842045750650270",
"196332330272754239109074745683478940143",
"35939116874639619238543386175661059371",
"121989458339070935089690442066756114404",
"88835914803348309889796019759827160675",
"153321108666929839776139685174861592068",
"111415801794603501424492681521184233642",
"173000328327456328013706821984174669798",
"75958852780952708669656388222565885670",
"260476725265572946104220152389558828883",
"247975071289809285836813676672204762002",
"73670340687333490597527168862319026651",
"37048714426637547006571239607125670425",
"289131021204126858811254213095507905933",
"127829106219764940289656446654192293042",
"248823934048711807750184983712923631180",
"280342113999918582316187778760035995448",
"17081406646766266207860847668798353263",
"338616447859076546316561312962283127700",
"145887687957168743226546142706936700932",
"166202178551369148535820818613354993828",
"287103650571165965187488093702589796320",
"322835406571537779239708826564322839198",
"2607405567906877075075439728976096220",
"329027165764530149274938498514576347613",
"57066465991894319330962150409794823016",
"339346118894118699372299155007364602235",
"194899238279134889663922572814206056883"
]
},
"id": "CVE-2024-47736-f59577b5",
"target": {
"file": "fs/erofs/zdata.c"
}
}
]