In the Linux kernel, the following vulnerability has been resolved:
netfs: Only call foliostartfscache() one time for each folio
If a network filesystem using netfs implements a clamp_length() function, it can set subrequest lengths smaller than a page size.
When we loop through the folios in netfsrrequnlockfolios() to set any folios to be written back, we need to make sure we only call foliostart_fscache() once for each folio.
Otherwise, this simple testcase:
mount -o fsc,rsize=1024,wsize=1024 127.0.0.1:/export /mnt/nfs dd if=/dev/zero of=/mnt/nfs/file.bin bs=4096 count=1 1+0 records in 1+0 records out 4096 bytes (4.1 kB, 4.0 KiB) copied, 0.0126359 s, 324 kB/s echo 3 > /proc/sys/vm/drop_caches cat /mnt/nfs/file.bin > /dev/null
will trigger an oops similar to the following:
page dumped because: VMBUGONFOLIO(foliotestprivate2(folio)) ------------[ cut here ]------------ kernel BUG at include/linux/netfs.h:44! ... CPU: 5 PID: 134 Comm: kworker/u16:5 Kdump: loaded Not tainted 6.4.0-rc5 ... RIP: 0010:netfsrrequnlockfolios+0x68e/0x730 [netfs] ... Call Trace: netfsrreqassess+0x497/0x660 [netfs] netfssubreqterminated+0x32b/0x610 [netfs] nfsnetfsreadcompletion+0x14e/0x1a0 [nfs] nfsreadcompletion+0x2f9/0x330 [nfs] rpcfreetask+0x72/0xa0 [sunrpc] rpcasyncrelease+0x46/0x70 [sunrpc] processonework+0x3bd/0x710 workerthread+0x89/0x610 kthread+0x181/0x1c0 retfrom_fork+0x29/0x50
[
{
"deprecated": false,
"id": "CVE-2023-52582-2b09257c",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@df1c357f25d808e30b216188330e708e09e1a412",
"signature_version": "v1",
"target": {
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Line",
"digest": {
"line_hashes": [
"1103911254290833107485493503553493103",
"220279823250454552759725616737849416570",
"29263528188832138081638647027631471330",
"276094685363576041724426195438185923337",
"139691597958359697387365071167653749355",
"327440271564108651529539870785488048564",
"180067503693606059736315308742873854318",
"65342870427259175432657653800494834570",
"291073844654843835699991009715338027043",
"71898752062988006171363805206668205281",
"227249727876901760495635537537004670635",
"320329284946074458925430106574233156523"
],
"threshold": 0.9
}
},
{
"deprecated": false,
"id": "CVE-2023-52582-5b19817e",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@df9950d37df113db59495fa09d060754366a2b7c",
"signature_version": "v1",
"target": {
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Line",
"digest": {
"line_hashes": [
"1103911254290833107485493503553493103",
"220279823250454552759725616737849416570",
"29263528188832138081638647027631471330",
"276094685363576041724426195438185923337",
"139691597958359697387365071167653749355",
"327440271564108651529539870785488048564",
"180067503693606059736315308742873854318",
"65342870427259175432657653800494834570",
"291073844654843835699991009715338027043",
"71898752062988006171363805206668205281",
"227249727876901760495635537537004670635",
"320329284946074458925430106574233156523"
],
"threshold": 0.9
}
},
{
"deprecated": false,
"id": "CVE-2023-52582-aa86b4db",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d9f5537479d4ec97ea92ff24e81a517d5772581a",
"signature_version": "v1",
"target": {
"function": "netfs_rreq_unlock_folios",
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Function",
"digest": {
"function_hash": "327558613466364945104039218964388050390",
"length": 1688.0
}
},
{
"deprecated": false,
"id": "CVE-2023-52582-c95ff3f9",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@d9f5537479d4ec97ea92ff24e81a517d5772581a",
"signature_version": "v1",
"target": {
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Line",
"digest": {
"line_hashes": [
"1103911254290833107485493503553493103",
"220279823250454552759725616737849416570",
"29263528188832138081638647027631471330",
"276094685363576041724426195438185923337",
"139691597958359697387365071167653749355",
"327440271564108651529539870785488048564",
"180067503693606059736315308742873854318",
"65342870427259175432657653800494834570",
"291073844654843835699991009715338027043",
"71898752062988006171363805206668205281",
"227249727876901760495635537537004670635",
"320329284946074458925430106574233156523"
],
"threshold": 0.9
}
},
{
"deprecated": false,
"id": "CVE-2023-52582-cb504cbd",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@df9950d37df113db59495fa09d060754366a2b7c",
"signature_version": "v1",
"target": {
"function": "netfs_rreq_unlock_folios",
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Function",
"digest": {
"function_hash": "327558613466364945104039218964388050390",
"length": 1688.0
}
},
{
"deprecated": false,
"id": "CVE-2023-52582-f8f6c748",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@df1c357f25d808e30b216188330e708e09e1a412",
"signature_version": "v1",
"target": {
"function": "netfs_rreq_unlock_folios",
"file": "fs/netfs/buffered_read.c"
},
"signature_type": "Function",
"digest": {
"function_hash": "327558613466364945104039218964388050390",
"length": 1688.0
}
}
]