CVE-2021-47326: x86/signal: Detect and prevent an alternate signal stack overflow
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.
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
Quoted 19 lines · Greg Kroah-Hartman
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.
Quoted 6 lines
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.
Quoted 45 lines
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 5bc3ab30db9bPlease 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-47326will 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.hMitigation
==========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
Quoted 27 lines · Nikolay Borisov
Quoted 24 lines · Greg Kroah-Hartman
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.
Quoted 6 lines
Quoted 1 line
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.
Ah, good catch, thanks, I'll go revoke this CVE now.
Thanks for the review, much appreciated!
greg k-h