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 0DCC7199242 for ; Tue, 16 Jul 2024 11:47:37 +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=1721130457; cv=none; b=Ae7gqxppXjLGyghZBSXz+j/0SFkKaKtbB5WB3z6hW59UnAR/VKf5+NiP1uITI9sblLSevzUZzbm+XndHxyQyHH96378g/LlnnsvXfAlO7NnzCub1EsanjfxBNoaLEIECJteBno6nglDMix/6jRPaSWRlpmkvuraeLB81S6/MvGs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721130457; c=relaxed/simple; bh=eZAymzDJtdZV/RLihHhCoFnA6Rc6+zo8gdZkgwJ0J9Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UB3IGLmuByElkNWIrkCPPJeI+qh+/kOlRxYwO3wtkGzV3l+xXuSVKP/dHiVuVMsYeDRuHVs3U53ryz8mALVOVs+RqeKGHsgIqhDJ2Q7XsjawSdlbXYtTGXvAYJjUKnSou8a5ubd6MLQt7l1Uv5VWqV044qS81g6W9Xn7Q9OT7As= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Uf7od+4o; 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="Uf7od+4o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 880EFC116B1; Tue, 16 Jul 2024 11:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721130456; bh=eZAymzDJtdZV/RLihHhCoFnA6Rc6+zo8gdZkgwJ0J9Y=; h=From:To:Cc:Subject:Date:Reply-to:From; b=Uf7od+4oZZE+Q3xJ/zMeVcQjqW2/YgNBROqXCQGTw0YAOpNN8yTXqzoYcer1wUi5N UTPQJvfzku7Xh8rIsaR35g3ILjbUeFOlyOdVTkr6NpCB0b+41kUxgBx7oRPtpQj1Us wIVO6fpYStswqDDPgcwTn6A3w0IAHw70ATMrGYpU= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48797: mm: don't try to NUMA-migrate COW pages that have other uses Date: Tue, 16 Jul 2024 13:45:49 +0200 Message-ID: <2024071642-CVE-2022-48797-b404@gregkh> X-Mailer: git-send-email 2.45.2 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=3959; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=eZAymzDJtdZV/RLihHhCoFnA6Rc6+zo8gdZkgwJ0J9Y=; b=owGbwMvMwCRo6H6F97bub03G02pJDGnTYtOtdNM/r7PZuyFFpfZs/DydBrPurr19GUGzzXdJ7 6i8YcTdEcvCIMjEICumyPJlG8/R/RWHFL0MbU/DzGFlAhnCwMUpABOp2sUwv5S/PGFirfwDRUZ2 a0mDjGPXBNZbMszhcDGYsNdyUfg3EzGf30vnfUkNc5wFAA== 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: don't try to NUMA-migrate COW pages that have other uses Oded Gabbay reports that enabling NUMA balancing causes corruption with his Gaudi accelerator test load: "All the details are in the bug, but the bottom line is that somehow, this patch causes corruption when the numa balancing feature is enabled AND we don't use process affinity AND we use GUP to pin pages so our accelerator can DMA to/from system memory. Either disabling numa balancing, using process affinity to bind to specific numa-node or reverting this patch causes the bug to disappear" and Oded bisected the issue to commit 09854ba94c6a ("mm: do_wp_page() simplification"). Now, the NUMA balancing shouldn't actually be changing the writability of a page, and as such shouldn't matter for COW. But it appears it does. Suspicious. However, regardless of that, the condition for enabling NUMA faults in change_pte_range() is nonsensical. It uses "page_mapcount(page)" to decide if a COW page should be NUMA-protected or not, and that makes absolutely no sense. The number of mappings a page has is irrelevant: not only does GUP get a reference to a page as in Oded's case, but the other mappings migth be paged out and the only reference to them would be in the page count. Since we should never try to NUMA-balance a page that we can't move anyway due to other references, just fix the code to use 'page_count()'. Oded confirms that that fixes his issue. Now, this does imply that something in NUMA balancing ends up changing page protections (other than the obvious one of making the page inaccessible to get the NUMA faulting information). Otherwise the COW simplification wouldn't matter - since doing the GUP on the page would make sure it's writable. The cause of that permission change would be good to figure out too, since it clearly results in spurious COW events - but fixing the nonsensical test that just happened to work before is obviously the CorrectThing(tm) to do regardless. The Linux kernel CVE team has assigned CVE-2022-48797 to this issue. Affected and fixed versions =========================== Issue introduced in 5.9 with commit 09854ba94c6a and fixed in 5.10.102 with commit 254090925e16 Issue introduced in 5.9 with commit 09854ba94c6a and fixed in 5.15.25 with commit b3dc4b9d3ca6 Issue introduced in 5.9 with commit 09854ba94c6a and fixed in 5.16.11 with commit d187eeb02d18 Issue introduced in 5.9 with commit 09854ba94c6a and fixed in 5.17 with commit 80d47f5de5e3 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-2022-48797 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/mprotect.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/254090925e16abd914c87b4ad1b489440d89c4c3 https://git.kernel.org/stable/c/b3dc4b9d3ca68b370c4aeab5355007eedf948849 https://git.kernel.org/stable/c/d187eeb02d18446e5e54ed6bcbf8b47e6551daea https://git.kernel.org/stable/c/80d47f5de5e311cbc0d01ebb6ee684e8f4c196c6