Skip to contentSkip to conversation

CVE-2021-47365: afs: Fix page leak

DISCUSSION Greg Kroah-Hartman 1 participant 1 message May 21, 2024

lore
Share & tools
lore
#0 lore raw

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

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

afs: Fix page leak

There's a loop in afs_extend_writeback() that adds extra pages to a write we want to make to improve the efficiency of the writeback by making it larger. This loop stops, however, if we hit a page we can't write back from immediately, but it doesn't get rid of the page ref we speculatively acquired.

This was caused by the removal of the cleanup loop when the code switched from using find_get_pages_contig() to xarray scanning as the latter only gets a single page at a time, not a batch.

Fix this by putting the page on a ref on an early break from the loop. Unfortunately, we can't just add that page to the pagevec we're employing as we'll go through that and add those pages to the RPC call.

This was found by the generic/074 test. It leaks ~4GiB of RAM each time it is run - which can be observed with "top".

The Linux kernel CVE team has assigned CVE-2021-47365 to this issue.

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

	Issue introduced in 5.13 with commit e87b03f5830e and fixed in 5.14.9 with commit d130b5fdd422
	Issue introduced in 5.13 with commit e87b03f5830e and fixed in 5.15 with commit 581b2027af00

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-2021-47365

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/afs/write.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/d130b5fdd42254d92948d06347940276140c927e
	https://git.kernel.org/stable/c/581b2027af0018944ba301d68e7af45c6d1128b5