In the Linux kernel, the following vulnerability has been resolved:
mm/memory-failure: make sure wait for page writeback in memory_failure
Our syzkaller trigger the "BUGON(!listempty(&inode->iwblist))" in clear_inode:
kernel BUG at fs/inode.c:519! Internal error: Oops - BUG: 0 [#1] SMP Modules linked in: Process syz-executor.0 (pid: 249, stack limit = 0x00000000a12409d7) CPU: 1 PID: 249 Comm: syz-executor.0 Not tainted 4.19.95 Hardware name: linux,dummy-virt (DT) pstate: 80000005 (Nzcv daif -PAN -UAO) pc : clearinode+0x280/0x2a8 lr : clearinode+0x280/0x2a8 Call trace: clearinode+0x280/0x2a8 ext4clearinode+0x38/0xe8 ext4freeinode+0x130/0xc68 ext4evictinode+0xb20/0xcb8 evict+0x1a8/0x3c0 iput+0x344/0x460 dounlinkat+0x260/0x410 _arm64sysunlinkat+0x6c/0xc0 el0svccommon+0xdc/0x3b0 el0svchandler+0xf8/0x160 el0svc+0x10/0x218 Kernel panic - not syncing: Fatal exception
A crash dump of this problem show that someone called __munlockpagevec to clear page LRU without lockpage: dommap -> mmapregion -> domunmap -> munlockvmapagesrange -> _munlockpagevec.
As a result memoryfailure will call identifypagestate without waitonpagewriteback. And after truncateerrorpage clear the mapping of this page. endpagewriteback won't call sbclearinodewriteback to clear inode->iwblist. That will trigger BUGON in clear_inode!
Fix it by checking PageWriteback too to help determine should we skip waitonpage_writeback.
[
{
"events": [
{
"introduced": "3.16"
},
{
"fixed": "4.14.238"
}
]
},
{
"events": [
{
"introduced": "4.15"
},
{
"fixed": "4.19.196"
}
]
},
{
"events": [
{
"introduced": "4.20"
},
{
"fixed": "5.4.128"
}
]
},
{
"events": [
{
"introduced": "5.5"
},
{
"fixed": "5.10.46"
}
]
},
{
"events": [
{
"introduced": "5.11"
},
{
"fixed": "5.12.13"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc1"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc2"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc3"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc4"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc5"
}
]
},
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "5.13-rc6"
}
]
}
]
"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2021-47256.json"