Re: CVE-2021-47326: x86/signal: Detect and prevent an alternate signal stack overflow

From: Nikolay Borisov
Date: Thu May 23 2024 - 06:19:32 EST




On 21.05.24 г. 17:36 ч., Greg Kroah-Hartman wrote:
Description
===========

In the Linux kernel, the following vulnerability has been resolved:

x86/signal: Detect and prevent an alternate signal stack overflow

The kernel pushes context on to the userspace stack to prepare for the
user's signal handler. When the user has supplied an alternate signal
stack, via sigaltstack(2), it is easy for the kernel to verify that the
stack size is sufficient for the current hardware context.

Check if writing the hardware context to the alternate stack will exceed
it's size. If yes, then instead of corrupting user-data and proceeding with
the original signal handler, an immediate SIGSEGV signal is delivered.

Refactor the stack pointer check code from on_sig_stack() and use the new
helper.

While the kernel allows new source code to discover and use a sufficient
alternate signal stack size, this check is still necessary to protect
binaries with insufficient alternate signal stack size from data
corruption.

The Linux kernel CVE team has assigned CVE-2021-47326 to this issue.


I'd like to dispute this CVE. Basically a process can pass in a wrongly-sized stack which will cause its own stack to be corrupted. If anything this affects the process rather than the kernel.



Affected and fixed versions
===========================

Issue introduced in 3.15 with commit c2bc11f10a39 and fixed in 5.4.134 with commit 00fcd8f33e9b
Issue introduced in 3.15 with commit c2bc11f10a39 and fixed in 5.10.52 with commit 74569cb9ed7b
Issue introduced in 3.15 with commit c2bc11f10a39 and fixed in 5.12.19 with commit 74d6fcea1d89
Issue introduced in 3.15 with commit c2bc11f10a39 and fixed in 5.13.4 with commit afb04d0b5543
Issue introduced in 3.15 with commit c2bc11f10a39 and fixed in 5.14 with commit 2beb4a53fc3f
Issue introduced in 3.14.3 with commit 5bc3ab30db9b

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-47326
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/signal.c
include/linux/sched/signal.h


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/00fcd8f33e9b9f57115c3b1cfc4cb96450c18796
https://git.kernel.org/stable/c/74569cb9ed7bc60e395927f55d3dc3be143a0164
https://git.kernel.org/stable/c/74d6fcea1d896800e60f1c675137efebd1a6c9a6
https://git.kernel.org/stable/c/afb04d0b5543a5bf8e157b9119fbfc52606f4c11
https://git.kernel.org/stable/c/2beb4a53fc3f1081cedc1c1a198c7f56cc4fc60c