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 EDB4013D29F for ; Tue, 21 May 2024 14:40:17 +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=1716302418; cv=none; b=fNfTfw/6VwhrgFGlghItZY9A+amEeg0GwTV0K2JUV56WoKzHq+f0ZHZa7Gy+THqtnpsKCuR7KIGLu8G3oMILns72NJlhJDUIvjJ0ojXLYz4K51IhLd0LwVkTCJnn6KxNa9Njs1IvJojGpsKW03iscvprRNg6iVwEqCiKmoaz+4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716302418; c=relaxed/simple; bh=HErcffZvxXqSlvw6BxA2/Qp3L3f6NsbKj3d33m0XFTA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=B80LHwxjDCQ3xzEwLBzCFWYSYow2t6P/r9R5SzqhtjupMfCAdRpj9S8AV3XxLOcL9JrV48Ph9g80j1CTIdqD+CExooi+6X5Urri0nOFrt/C0siWxMwcQOkzrlGWCaSe5i3ZLStgfmqD9NIo1XqV3vuIk8BXj91PsREDpFxd57NY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=W0MIQ1op; 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="W0MIQ1op" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77B18C2BD11; Tue, 21 May 2024 14:40:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716302417; bh=HErcffZvxXqSlvw6BxA2/Qp3L3f6NsbKj3d33m0XFTA=; h=From:To:Cc:Subject:Date:Reply-to:From; b=W0MIQ1op6WboKkRUl5DZuXiPnMkfPVVrDXHBrgMhncznSUQHh44ApYZIckM/zmgTO CkJF+riC4q++Ha4BZSbLUYR2V/p6RxwCbE60fmSp18+Vp6rdDZuA600et+TU0V82UA 9fu3ZEq3zS8Bex2NBqMCYFnJcoqoSTYOOuis/4cg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47350: powerpc/mm: Fix lockup on kernel exec fault Date: Tue, 21 May 2024 16:36:24 +0200 Message-ID: <2024052140-CVE-2021-47350-08a8@gregkh> X-Mailer: git-send-email 2.45.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=3937; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=HErcffZvxXqSlvw6BxA2/Qp3L3f6NsbKj3d33m0XFTA=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk+G20UW4QO9Blc/n00froQs5lQj3N6YWvYppwJvOZ27 Z3/fvp2xLIwCDIxyIopsnzZxnN0f8UhRS9D29Mwc1iZQIYwcHEKwER+ujHMD7C+Z6/i9mJxyQLH mH6la21xbxSeMiy4ebjCJfz47kapX/bht3e8dO+9HbYWAA== 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/mm: Fix lockup on kernel exec fault The powerpc kernel is not prepared to handle exec faults from kernel. Especially, the function is_exec_fault() will return 'false' when an exec fault is taken by kernel, because the check is based on reading current->thread.regs->trap which contains the trap from user. For instance, when provoking a LKDTM EXEC_USERSPACE test, current->thread.regs->trap is set to SYSCALL trap (0xc00), and the fault taken by the kernel is not seen as an exec fault by set_access_flags_filter(). Commit d7df2443cd5f ("powerpc/mm: Fix spurious segfaults on radix with autonuma") made it clear and handled it properly. But later on commit d3ca587404b3 ("powerpc/mm: Fix reporting of kernel execute faults") removed that handling, introducing test based on error_code. And here is the problem, because on the 603 all upper bits of SRR1 get cleared when the TLB instruction miss handler bails out to ISI. Until commit cbd7e6ca0210 ("powerpc/fault: Avoid heavy search_exception_tables() verification"), an exec fault from kernel at a userspace address was indirectly caught by the lack of entry for that address in the exception tables. But after that commit the kernel mainly relies on KUAP or on core mm handling to catch wrong user accesses. Here the access is not wrong, so mm handles it. It is a minor fault because PAGE_EXEC is not set, set_access_flags_filter() should set PAGE_EXEC and voila. But as is_exec_fault() returns false as explained in the beginning, set_access_flags_filter() bails out without setting PAGE_EXEC flag, which leads to a forever minor exec fault. As the kernel is not prepared to handle such exec faults, the thing to do is to fire in bad_kernel_fault() for any exec fault taken by the kernel, as it was prior to commit d3ca587404b3. The Linux kernel CVE team has assigned CVE-2021-47350 to this issue. Affected and fixed versions =========================== Issue introduced in 4.14 with commit d3ca587404b3 and fixed in 5.4.133 with commit a82471a14aad Issue introduced in 4.14 with commit d3ca587404b3 and fixed in 5.10.51 with commit d2e52d466409 Issue introduced in 4.14 with commit d3ca587404b3 and fixed in 5.12.18 with commit 500f81cec9f1 Issue introduced in 4.14 with commit d3ca587404b3 and fixed in 5.13.3 with commit 8a96ec5ebf96 Issue introduced in 4.14 with commit d3ca587404b3 and fixed in 5.14 with commit cd5d5e602f50 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-47350 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/fault.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/a82471a14aad90f79d1608d2bcbb019f0ffb53f0 https://git.kernel.org/stable/c/d2e52d4664097a6c1f591d869ec594bd7a0d4925 https://git.kernel.org/stable/c/500f81cec9f1bfa5210aa9dd5ba9a06e22f62a35 https://git.kernel.org/stable/c/8a96ec5ebf96ad8e2ba7b1b34103a0be5140fc70 https://git.kernel.org/stable/c/cd5d5e602f502895e47e18cd46804d6d7014e65c