From mboxrd@z Thu Jan 1 00:00:00 1970 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 4B98019F11B for ; Wed, 26 Feb 2025 01:57:20 +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=1740535041; cv=none; b=OfKMJYbTm50PtE4Xrpx4zKhYXDLL+Ar+puXekyPhcUOQmqp9lqDbEJACbN+ICYIrejuTEhWjMpGfIUyeT49hBmdLiht4S37s/cHj8PVl4e1xAcCIsUiDpJnJZNrDBoMMOrVHIxGYZMza4HGo0aSCaKh3RlnP/0nUMkPY17ht3zs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740535041; c=relaxed/simple; bh=fagLdNP+Yi7xF2ClRd2HweYtP5GiNEASGiwbqnM0UEc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Hx97SXBGL99iiAQvYNHTFbnTFsZABXzxc8PqCdVFp6OiC7CKgCGJVv4+SiiCWAEtKxI+MRkd7Oz3ys7ZAOlgv/+0Ywth0GfrWRUZdFeSlmn8VFgyP9SyaCpcylqih/LUM03MEYmT6OHOnO42wyl/iNUEU6jpwIsiUFHcTipbBco= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BxRxHEwc; 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="BxRxHEwc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04355C4CEDD; Wed, 26 Feb 2025 01:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740535040; bh=fagLdNP+Yi7xF2ClRd2HweYtP5GiNEASGiwbqnM0UEc=; h=From:To:Cc:Subject:Date:Reply-to:From; b=BxRxHEwcz/7kZS5D/pFKWEunRU21jT2PdtD1B4dj9QgiOu36OEAdptwU/UncEJc5h 8jltTNM2AU/CSydH8UZxx09a9JhgvSCtK1LgazdigUt9Lp6Gtdf1f6hSQ/Cl8BZTQD 1Td73JdJ3Sg6A6yxb89wg5LHHrlOjiMCX++tSB2Y= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47632: powerpc/set_memory: Avoid spinlock recursion in change_page_attr() Date: Wed, 26 Feb 2025 02:53:43 +0100 Message-ID: <2025022646-CVE-2021-47632-c136@gregkh> X-Mailer: git-send-email 2.48.1 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=4330; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=fagLdNP+Yi7xF2ClRd2HweYtP5GiNEASGiwbqnM0UEc=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7SrRKJNvmnFe6lj4tOW6/Xe212k/ntv68xMH976jWx eC1XInzO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiE14zLOhcs6RJpVfJQLB+ 2hnDSycm/vxQZcgwz9Qls33rugcKItWuFhYnjgsfTPP+DAA= 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: powerpc/set_memory: Avoid spinlock recursion in change_page_attr() Commit 1f9ad21c3b38 ("powerpc/mm: Implement set_memory() routines") included a spin_lock() to change_page_attr() in order to safely perform the three step operations. But then commit 9f7853d7609d ("powerpc/mm: Fix set_memory_*() against concurrent accesses") modify it to use pte_update() and do the operation safely against concurrent access. In the meantime, Maxime reported some spinlock recursion. [ 15.351649] BUG: spinlock recursion on CPU#0, kworker/0:2/217 [ 15.357540] lock: init_mm+0x3c/0x420, .magic: dead4ead, .owner: kworker/0:2/217, .owner_cpu: 0 [ 15.366563] CPU: 0 PID: 217 Comm: kworker/0:2 Not tainted 5.15.0+ #523 [ 15.373350] Workqueue: events do_free_init [ 15.377615] Call Trace: [ 15.380232] [e4105ac0] [800946a4] do_raw_spin_lock+0xf8/0x120 (unreliable) [ 15.387340] [e4105ae0] [8001f4ec] change_page_attr+0x40/0x1d4 [ 15.393413] [e4105b10] [801424e0] __apply_to_page_range+0x164/0x310 [ 15.400009] [e4105b60] [80169620] free_pcp_prepare+0x1e4/0x4a0 [ 15.406045] [e4105ba0] [8016c5a0] free_unref_page+0x40/0x2b8 [ 15.411979] [e4105be0] [8018724c] kasan_depopulate_vmalloc_pte+0x6c/0x94 [ 15.418989] [e4105c00] [801424e0] __apply_to_page_range+0x164/0x310 [ 15.425451] [e4105c50] [80187834] kasan_release_vmalloc+0xbc/0x134 [ 15.431898] [e4105c70] [8015f7a8] __purge_vmap_area_lazy+0x4e4/0xdd8 [ 15.438560] [e4105d30] [80160d10] _vm_unmap_aliases.part.0+0x17c/0x24c [ 15.445283] [e4105d60] [801642d0] __vunmap+0x2f0/0x5c8 [ 15.450684] [e4105db0] [800e32d0] do_free_init+0x68/0x94 [ 15.456181] [e4105dd0] [8005d094] process_one_work+0x4bc/0x7b8 [ 15.462283] [e4105e90] [8005d614] worker_thread+0x284/0x6e8 [ 15.468227] [e4105f00] [8006aaec] kthread+0x1f0/0x210 [ 15.473489] [e4105f40] [80017148] ret_from_kernel_thread+0x14/0x1c Remove the read / modify / write sequence to make the operation atomic and remove the spin_lock() in change_page_attr(). To do the operation atomically, we can't use pte modification helpers anymore. Because all platforms have different combination of bits, it is not easy to use those bits directly. But all have the _PAGE_KERNEL_{RO/ROX/RW/RWX} set of flags. All we need it to compare two sets to know which bits are set or cleared. For instance, by comparing _PAGE_KERNEL_ROX and _PAGE_KERNEL_RO you know which bit gets cleared and which bit get set when changing exec permission. The Linux kernel CVE team has assigned CVE-2021-47632 to this issue. Affected and fixed versions =========================== Fixed in 5.15.34 with commit 6def4eaf0391f24be541633a954c0e4876858b1e Fixed in 5.16.20 with commit 96917107e67846f1d959ed03be281048efad14c5 Fixed in 5.17.3 with commit 6ebe5ca2cbe438a688f2ae238ef5a0b0b5f3468a Fixed in 5.18 with commit a4c182ecf33584b9b2d1aa9dad073014a504c01f 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-47632 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: arch/powerpc/mm/pageattr.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/6def4eaf0391f24be541633a954c0e4876858b1e https://git.kernel.org/stable/c/96917107e67846f1d959ed03be281048efad14c5 https://git.kernel.org/stable/c/6ebe5ca2cbe438a688f2ae238ef5a0b0b5f3468a https://git.kernel.org/stable/c/a4c182ecf33584b9b2d1aa9dad073014a504c01f