Skip to contentSkip to conversation

CVE-2024-56740: nfs/localio: must clear res.replen in nfs_local_read_done

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Dec 29, 2024

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

nfs/localio: must clear res.replen in nfs_local_read_done

Otherwise memory corruption can occur due to NFSv3 LOCALIO reads leaving garbage in res.replen:
- nfs3_read_done() copies that into server->read_hdrsize; from there nfs3_proc_read_setup() copies it to args.replen in new requests.
- nfs3_xdr_enc_read3args() passes that to rpc_prepare_reply_pages() which includes it in hdrsize for xdr_init_pages, so that rq_rcv_buf contains a ridiculous len.
- This is copied to rq_private_buf and xs_read_stream_request() eventually passes the kvec to sock_recvmsg() which receives incoming data into entirely the wrong place.

This is easily reproduced with NFSv3 LOCALIO that is servicing reads when it is made to pivot back to using normal RPC. This switch back to using normal NFSv3 with RPC can occur for a few reasons but this issue was exposed with a test that stops and then restarts the NFSv3 server while LOCALIO is performing heavy read IO.

The Linux kernel CVE team has assigned CVE-2024-56740 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.12 with commit 70ba381e1a431245c137ed597ec6a05991c79bd9 and fixed in 6.12.2 with commit de5dac261eeab99762bbdf7c20cee5d26ef4462e
	Issue introduced in 6.12 with commit 70ba381e1a431245c137ed597ec6a05991c79bd9 and fixed in 6.13-rc1 with commit 650703bc4ed3edf841e851c99ab8e7ba9e5262a3

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2024-56740

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
fs/nfs/localio.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/de5dac261eeab99762bbdf7c20cee5d26ef4462e
	https://git.kernel.org/stable/c/650703bc4ed3edf841e851c99ab8e7ba9e5262a3