Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 605A71DF754 for ; Mon, 21 Oct 2024 18:02:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729533730; cv=none; b=YeE89jC9NhgOfl/TC5ae1sEjEmqVNacFrb0US+XvPFYQUBZeOvkVamqspuKIKGcL4jYnwyqD4NoxR5K1M+dVVqke1TPFVZHG62oKXc1rLDHMJvT02Y/FGIHmk7s1eIJzdzYWp4GU3CWasczDzrPRScpnGvBOVPdcYNRUK8FyWwE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729533730; c=relaxed/simple; bh=wXUr2HFdqacJcMXyuygn3+5A8ZVEeQ+cXQKAwGvd7mY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uuQmaJOaTcr/YZE5PUX618OWUldqfK093YFwlhvurl7fstMbwFaraNBJk72zhwq0xjIzud6deLd4qzXGCVAhT71iqQ2AvORK+TGlKwq56UihWrfuVFWmO8xrMgUHZjK2F6qJLhAthTmVvyVJVNSy19DBToe0bJy+LNEdtQVjWl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K52TWJaH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="K52TWJaH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 973F7C4CEC7; Mon, 21 Oct 2024 18:02:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729533730; bh=wXUr2HFdqacJcMXyuygn3+5A8ZVEeQ+cXQKAwGvd7mY=; h=From:To:Cc:Subject:Date:Reply-to:From; b=K52TWJaHRhnLrFyUx991+IJuSc4divknBscof2x7istHZsYgTtBN4MIrDh1ZkBZ9x LF+3WCv0rz8pgp7mlsGHRrlqg0na/y2tXpmHm5mzHrlVYo9TAZsZjJkuQcKBr0UjU5 FiKxcsXYh7J2MgC8tbCektPeuYnBA4gDQrsuQb3g= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-49873: mm/filemap: fix filemap_get_folios_contig THP panic Date: Mon, 21 Oct 2024 20:01:21 +0200 Message-ID: <2024102114-CVE-2024-49873-3190@gregkh> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3098; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=wXUr2HFdqacJcMXyuygn3+5A8ZVEeQ+cXQKAwGvd7mY=; b=owGbwMvMwCRo6H6F97bub03G02pJDOli015p+IVpcVelbjlTmtz8p5BLg8Hv7Ew9yx8zg8Wrr Ja/42nsiGVhEGRikBVTZPmyjefo/opDil6Gtqdh5rAygQxh4OIUgIksrGKYK3hmU3pnltidDbK7 nvBZaPzYKeTJw7Dg0Dynd8ffrzjZyPJArzUielLDeVkbAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: mm/filemap: fix filemap_get_folios_contig THP panic Patch series "memfd-pin huge page fixes". Fix multiple bugs that occur when using memfd_pin_folios with hugetlb pages and THP. The hugetlb bugs only bite when the page is not yet faulted in when memfd_pin_folios is called. The THP bug bites when the starting offset passed to memfd_pin_folios is not huge page aligned. See the commit messages for details. This patch (of 5): memfd_pin_folios on memory backed by THP panics if the requested start offset is not huge page aligned: BUG: kernel NULL pointer dereference, address: 0000000000000036 RIP: 0010:filemap_get_folios_contig+0xdf/0x290 RSP: 0018:ffffc9002092fbe8 EFLAGS: 00010202 RAX: 0000000000000002 RBX: 0000000000000002 RCX: 0000000000000002 The fault occurs here, because xas_load returns a folio with value 2: filemap_get_folios_contig() for (folio = xas_load(&xas); folio && xas.xa_index <= end; folio = xas_next(&xas)) { ... if (!folio_try_get(folio)) <-- BOOM "2" is an xarray sibling entry. We get it because memfd_pin_folios does not round the indices passed to filemap_get_folios_contig to huge page boundaries for THP, so we load from the middle of a huge page range see a sibling. (It does round for hugetlbfs, at the is_file_hugepages test). To fix, if the folio is a sibling, then return the next index as the starting point for the next call to filemap_get_folios_contig. The Linux kernel CVE team has assigned CVE-2024-49873 to this issue. Affected and fixed versions =========================== Issue introduced in 6.11 with commit 89c1905d9c14 and fixed in 6.11.3 with commit 570dd14bfecf Issue introduced in 6.11 with commit 89c1905d9c14 and fixed in 6.12-rc1 with commit c225c4f6056b 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-49873 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: mm/filemap.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/570dd14bfecf281fa467c80f8ec92b26370ee36a https://git.kernel.org/stable/c/c225c4f6056b46a8a5bf2ed35abf17a2d6887691