In the Linux kernel, the following vulnerability has been resolved:
f2fs: fix to drop all discards after creating snapshot on lvm device
Piergiorgio reported a bug in bugzilla as below:
------------[ cut here ]------------ WARNING: CPU: 2 PID: 969 at fs/f2fs/segment.c:1330 RIP: 0010:_submitdiscardcmd+0x27d/0x400 [f2fs] Call Trace: _issuediscardcmd+0x1ca/0x350 [f2fs] issuediscardthread+0x191/0x480 [f2fs] kthread+0xcf/0x100 retfromfork+0x31/0x50 retfromfork_asm+0x1a/0x30
w/ below testcase, it can reproduce this bug quickly: - pvcreate /dev/vdb - vgcreate myvg1 /dev/vdb - lvcreate -L 1024m -n mylv1 myvg1 - mount /dev/myvg1/mylv1 /mnt/f2fs - dd if=/dev/zero of=/mnt/f2fs/file bs=1M count=20 - sync - rm /mnt/f2fs/file - sync - lvcreate -L 1024m -s -n mylv1-snapshot /dev/myvg1/mylv1 - umount /mnt/f2fs
The root cause is: it will update discardmaxbytes of mounted lvm device to zero after creating snapshot on this lvm device, then, _submitdiscardcmd() will pass parameter @nrsects w/ zero value to _blkdevissue_discard(), it returns a NULL bio pointer, result in panic.
This patch changes as below for fixing: 1. Let's drop all remained discards in f2fsunfreeze() if snapshot of lvm device is created. 2. Checking discardmaxbytes before submitting discard during _submitdiscardcmd().
[
{
"id": "CVE-2024-56565-22114616",
"target": {
"file": "fs/f2fs/segment.c",
"function": "__submit_discard_cmd"
},
"digest": {
"length": 2248.0,
"function_hash": "28988649602554565412159706248488271621"
},
"deprecated": false,
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ed24ab98242f8d22b66fbe0452c97751b5ea4e22",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-7f271f0b",
"target": {
"file": "fs/f2fs/super.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"210501199436615293305636945790992144486",
"221516584328405738861291115831479080362",
"13344009129603348486995185077648335538",
"186612116980301575697612467042581448171"
]
},
"deprecated": false,
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ed24ab98242f8d22b66fbe0452c97751b5ea4e22",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-ab9e6d57",
"target": {
"file": "fs/f2fs/super.c",
"function": "f2fs_unfreeze"
},
"digest": {
"length": 106.0,
"function_hash": "324253641724889932230147165096864332355"
},
"deprecated": false,
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bc8aeb04fd80cb8cfae3058445c84410fd0beb5e",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-cc01d086",
"target": {
"file": "fs/f2fs/super.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"210501199436615293305636945790992144486",
"221516584328405738861291115831479080362",
"13344009129603348486995185077648335538",
"186612116980301575697612467042581448171"
]
},
"deprecated": false,
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bc8aeb04fd80cb8cfae3058445c84410fd0beb5e",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-cd314fef",
"target": {
"file": "fs/f2fs/segment.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"81351116324023368304975508966432714640",
"273517060131469240674833589889993523013",
"11077193207532599465961765752772643059",
"199281926414973772834715802703938385124",
"227206053231670178249867264258912717655",
"150060645206555171340854885233616643621",
"247257027070768571029812874451711116554"
]
},
"deprecated": false,
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bc8aeb04fd80cb8cfae3058445c84410fd0beb5e",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-ce179dab",
"target": {
"file": "fs/f2fs/super.c",
"function": "f2fs_unfreeze"
},
"digest": {
"length": 106.0,
"function_hash": "324253641724889932230147165096864332355"
},
"deprecated": false,
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ed24ab98242f8d22b66fbe0452c97751b5ea4e22",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-cebf22b4",
"target": {
"file": "fs/f2fs/segment.c"
},
"digest": {
"threshold": 0.9,
"line_hashes": [
"85000464429055003619329380220104404157",
"150060645206555171340854885233616643621",
"247257027070768571029812874451711116554"
]
},
"deprecated": false,
"signature_type": "Line",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ed24ab98242f8d22b66fbe0452c97751b5ea4e22",
"signature_version": "v1"
},
{
"id": "CVE-2024-56565-df322b98",
"target": {
"file": "fs/f2fs/segment.c",
"function": "__submit_discard_cmd"
},
"digest": {
"length": 2296.0,
"function_hash": "139271648412557896745493869772292423459"
},
"deprecated": false,
"signature_type": "Function",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@bc8aeb04fd80cb8cfae3058445c84410fd0beb5e",
"signature_version": "v1"
}
]