In the Linux kernel, the following vulnerability has been resolved:
f2fs: don't reset unchangable mount option in f2fs_remount()
syzbot reports a bug as below:
general protection fault, probably for non-canonical address 0xdffffc0000000009: 0000 [#1] PREEMPT SMP KASAN RIP: 0010:_lockacquire+0x69/0x2000 kernel/locking/lockdep.c:4942 Call Trace: lockacquire+0x1e3/0x520 kernel/locking/lockdep.c:5691 _rawwritelock include/linux/rwlockapismp.h:209 [inline] rawwritelock+0x2e/0x40 kernel/locking/spinlock.c:300 _dropextenttree+0x3ac/0x660 fs/f2fs/extentcache.c:1100 f2fsdropextenttree+0x17/0x30 fs/f2fs/extentcache.c:1116 f2fsinsertrange+0x2d5/0x3c0 fs/f2fs/file.c:1664 f2fsfallocate+0x4e4/0x6d0 fs/f2fs/file.c:1838 vfsfallocate+0x54b/0x6b0 fs/open.c:324 ksysfallocate fs/open.c:347 [inline] _dosysfallocate fs/open.c:355 [inline] _sesysfallocate fs/open.c:353 [inline] _x64sysfallocate+0xbd/0x100 fs/open.c:353 dosyscallx64 arch/x86/entry/common.c:50 [inline] dosyscall64+0x41/0xc0 arch/x86/entry/common.c:80 entrySYSCALL64after_hwframe+0x63/0xcd
The root cause is race condition as below: - since it tries to remount rw filesystem, so that doremount won't call sbprepareremountreadonly to block fallocate, there may be race condition in between remount and fallocate. - in f2fsremount(), defaultoptions() will reset mount option to default one, and then update it based on result of parse_options(), so there is a hole which race condition can happen.
Thread A Thread B - f2fsfillsuper - parseoptions - clearopt(READEXTENTCACHE)
[
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@115557cc226a927924f2d7d1980ccbf6e3b3bb36",
"target": {
"function": "default_options",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-2621253a",
"deprecated": false,
"digest": {
"function_hash": "211061857075594305065289802674226993448",
"length": 2029.0
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@458c15dfbce62c35fefd9ca637b20a051309c9f1",
"target": {
"function": "f2fs_remount",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-3f95238e",
"deprecated": false,
"digest": {
"function_hash": "94338907244433599195305326304735611165",
"length": 6087.0
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@115557cc226a927924f2d7d1980ccbf6e3b3bb36",
"target": {
"function": "f2fs_remount",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-56022b49",
"deprecated": false,
"digest": {
"function_hash": "94338907244433599195305326304735611165",
"length": 6087.0
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@458c15dfbce62c35fefd9ca637b20a051309c9f1",
"target": {
"function": "default_options",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-68198f87",
"deprecated": false,
"digest": {
"function_hash": "211061857075594305065289802674226993448",
"length": 2029.0
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@458c15dfbce62c35fefd9ca637b20a051309c9f1",
"target": {
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-9a0af9ea",
"deprecated": false,
"digest": {
"line_hashes": [
"160163876570008939168140686315332029534",
"101438908262445355999502066059733696806",
"277566865991583756555846844419415480998",
"33906992988402966142156938721855472473",
"308029683719975523527200361382431880915",
"244105314421942006911374618481762419901",
"10655008309403596629276018708097715293",
"52895699475835010618111071299828054738",
"290841741902725507021108637348592775104",
"294279826663350481939026580281132849738",
"245774084144300936150265328339302554379",
"293449566555766674375638220371511849082",
"236553437066323627762601204028902592884",
"294435777098616799149109195239146923837",
"149707570088996919141195681714828304792",
"80984655400748947140517180549138677574",
"146315558556040414640556046213477073444",
"241806455978480474288030640059138721539",
"254158886195083768098991004715160765465",
"277994919497675392293101631940882495175",
"9025937658555747227663760686058135104",
"173732190944416571402727376775366962192",
"294666783262630133422352948889986296076",
"290244503243202264899360419688813209018",
"306553616434771744198227153248978835088",
"285561883391811383558487871023807640170",
"217629582972436398848137186635374749279",
"63868552619502867672737885130281333249",
"199717112902552000796715806920126312395",
"77359623364027727690878577258299878621",
"155988043304680420051297307806627514474",
"87885279676159392764755818900254197365",
"100558606163512976724764116012398141271"
],
"threshold": 0.9
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@115557cc226a927924f2d7d1980ccbf6e3b3bb36",
"target": {
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-c62aa3ce",
"deprecated": false,
"digest": {
"line_hashes": [
"160163876570008939168140686315332029534",
"101438908262445355999502066059733696806",
"277566865991583756555846844419415480998",
"33906992988402966142156938721855472473",
"308029683719975523527200361382431880915",
"244105314421942006911374618481762419901",
"10655008309403596629276018708097715293",
"52895699475835010618111071299828054738",
"290841741902725507021108637348592775104",
"294279826663350481939026580281132849738",
"245774084144300936150265328339302554379",
"293449566555766674375638220371511849082",
"236553437066323627762601204028902592884",
"294435777098616799149109195239146923837",
"149707570088996919141195681714828304792",
"80984655400748947140517180549138677574",
"146315558556040414640556046213477073444",
"241806455978480474288030640059138721539",
"254158886195083768098991004715160765465",
"277994919497675392293101631940882495175",
"9025937658555747227663760686058135104",
"173732190944416571402727376775366962192",
"294666783262630133422352948889986296076",
"290244503243202264899360419688813209018",
"306553616434771744198227153248978835088",
"285561883391811383558487871023807640170",
"217629582972436398848137186635374749279",
"63868552619502867672737885130281333249",
"199717112902552000796715806920126312395",
"77359623364027727690878577258299878621",
"155988043304680420051297307806627514474",
"87885279676159392764755818900254197365",
"100558606163512976724764116012398141271"
],
"threshold": 0.9
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@458c15dfbce62c35fefd9ca637b20a051309c9f1",
"target": {
"function": "f2fs_fill_super",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-cec69816",
"deprecated": false,
"digest": {
"function_hash": "126289210384802218248264887643716535314",
"length": 10680.0
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@115557cc226a927924f2d7d1980ccbf6e3b3bb36",
"target": {
"function": "f2fs_fill_super",
"file": "fs/f2fs/super.c"
},
"id": "CVE-2023-53447-da545118",
"deprecated": false,
"digest": {
"function_hash": "126289210384802218248264887643716535314",
"length": 10680.0
},
"signature_type": "Function",
"signature_version": "v1"
}
]