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 11CA72D7BF for ; Thu, 1 May 2025 14:11:32 +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=1746108692; cv=none; b=eJoNfTOiv+M/sScTwL/Hv1bZwUUyNbo256vghfNyBhnQSFGni7hsu8QNrP3SLEPAuhSzNNdnTL3z0eQ/3WLJZ8fn6EI8RX0Qi3ImtqcsUHHDCOUfXX+oWYhQH1gpSqGLiQLsvZtItPcinqPxwxs8yj14FBAv4fi30hhCFkIF+Qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746108692; c=relaxed/simple; bh=28nY8b7xYFk9b6boddnaA6V2HryR3rxwN+yCftsOjQI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=JuvrPK9DGFnpL4dMMeB8qtOzO5kUbS2excPs5vKfLmpEk8qXpR0fjudzsE8LVBVRmt9bgW7N1Xt6iga6BTeDZBX8N1PE7wXUDkIn7Uu6sa5mXLdlSyXf8x5dG8TsQnz1/UXkh3slPJaYfXoCB2WRwwsqa8J6xMaAM2lPH2X6i+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uKfBkqCs; 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="uKfBkqCs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 904A0C4CEE3; Thu, 1 May 2025 14:11:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746108691; bh=28nY8b7xYFk9b6boddnaA6V2HryR3rxwN+yCftsOjQI=; h=From:To:Cc:Subject:Date:Reply-to:From; b=uKfBkqCsXzJd2rJxaHrnJ3X/PzM8b5cuXGKotYA7zHtlPkdS3JV3ViAQcjEE9uMm1 //LW+BD1En0QoNVhEv1TuLamm2zHhuR1iDkakWGAOrX1Jpic99HVq3cNKmrFWTXtMW 2wyCgSgtq1nvrtOmfbxB3gFFHV9DVdMPm/JcSBPk= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-49783: x86/fpu: Drop fpregs lock before inheriting FPU permissions Date: Thu, 1 May 2025 16:09:33 +0200 Message-ID: <2025050120-CVE-2022-49783-a870@gregkh> X-Mailer: git-send-email 2.49.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=4004; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=fDJfc23zKFPHi+B340U27Zs8q8mQNQsCpdhGrdA1dNk=; b=owGbwMvMwCRo6H6F97bub03G02pJDBnCDRNOK0VtWbNI6+KBqcsTf2W7N61fu+jXU80jx/rdH zou2/tjcUcsC4MgE4OsmCLLl208R/dXHFL0MrQ9DTOHlQlkCAMXpwBMxPM+w4I9kw7+n+mqcPsQ m87kXxxWEy5rT45mmF9fVnpDnWGZUUNLwqam62mzxDv3ywEA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: x86/fpu: Drop fpregs lock before inheriting FPU permissions Mike Galbraith reported the following against an old fork of preempt-rt but the same issue also applies to the current preempt-rt tree. BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:46 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 1, name: systemd preempt_count: 1, expected: 0 RCU nest depth: 0, expected: 0 Preemption disabled at: fpu_clone CPU: 6 PID: 1 Comm: systemd Tainted: G E (unreleased) Call Trace: dump_stack_lvl ? fpu_clone __might_resched rt_spin_lock fpu_clone ? copy_thread ? copy_process ? shmem_alloc_inode ? kmem_cache_alloc ? kernel_clone ? __do_sys_clone ? do_syscall_64 ? __x64_sys_rt_sigprocmask ? syscall_exit_to_user_mode ? do_syscall_64 ? syscall_exit_to_user_mode ? do_syscall_64 ? syscall_exit_to_user_mode ? do_syscall_64 ? exc_page_fault ? entry_SYSCALL_64_after_hwframe Mike says: The splat comes from fpu_inherit_perms() being called under fpregs_lock(), and us reaching the spin_lock_irq() therein due to fpu_state_size_dynamic() returning true despite static key __fpu_state_size_dynamic having never been enabled. Mike's assessment looks correct. fpregs_lock on a PREEMPT_RT kernel disables preemption so calling spin_lock_irq() in fpu_inherit_perms() is unsafe. This problem exists since commit 9e798e9aa14c ("x86/fpu: Prepare fpu_clone() for dynamically enabled features"). Even though the original bug report should not have enabled the paths at all, the bug still exists. fpregs_lock is necessary when editing the FPU registers or a task's FP state but it is not necessary for fpu_inherit_perms(). The only write of any FP state in fpu_inherit_perms() is for the new child which is not running yet and cannot context switch or be borrowed by a kernel thread yet. Hence, fpregs_lock is not protecting anything in the new child until clone() completes and can be dropped earlier. The siglock still needs to be acquired by fpu_inherit_perms() as the read of the parent's permissions has to be serialised. [ bp: Cleanup splat. ] The Linux kernel CVE team has assigned CVE-2022-49783 to this issue. Affected and fixed versions =========================== Issue introduced in 5.16 with commit 9e798e9aa14c45fb94e47b30bf6347b369ce9df7 and fixed in 6.0.10 with commit c6e8a7a1780af3da65e78a615f7d0874da6aabb0 Issue introduced in 5.16 with commit 9e798e9aa14c45fb94e47b30bf6347b369ce9df7 and fixed in 6.1 with commit 36b038791e1e2baea892e9276588815fd14894b4 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-49783 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/x86/kernel/fpu/core.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/c6e8a7a1780af3da65e78a615f7d0874da6aabb0 https://git.kernel.org/stable/c/36b038791e1e2baea892e9276588815fd14894b4