Bug 1902724 (CVE-2020-35508) - CVE-2020-35508 kernel: fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent
Summary: CVE-2020-35508 kernel: fork: fix copy_process(CLONE_PARENT) race with the exi...
Keywords:
Status: NEW
Alias: CVE-2020-35508
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1895892 1904785 1908311 1950760 1904784
Blocks: 1896156 1939994
TreeView+ depends on / blocked
 
Reported: 2020-11-30 14:01 UTC by Guilherme de Almeida Suckevicz
Modified: 2021-04-19 00:16 UTC (History)
50 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
A flaw possibility of race condition and incorrect initialization of the process id was found in the Linux kernel child/parent process identification handling while filtering signal handlers. A local attacker is able to abuse this flaw to bypass checks to send any signal to a privileged process.
Clone Of:
Environment:
Last Closed:


Attachments (Terms of Use)

Description Guilherme de Almeida Suckevicz 2020-11-30 14:01:40 UTC
A flaw was found in the Red Hat Linux kernel. It's possible to send arbitrary signals to a privileged (suidroot) parent process.

Comment 1 Alex 2020-12-06 11:29:18 UTC
Mitigation:

Mitigation for this issue is either not available or the currently available options don't meet the Red Hat Product Security criteria comprising ease of use and deployment, applicability to widespread installation base or stability.

Comment 2 Alex 2020-12-06 11:35:04 UTC
The "incorrect initialization of the process id" of the flaw is actual only for Red Hat Enterprise Linux (starting from 8.3), and non-actual for other (upstream) Linux distributions.

More details about this:

In fork.c:dup_task_struct(), after task->task_struct_rh allocated by kmalloc_node(), task_struct_rh->self_exec_id and
task_struct_rh->vtime_cpu are not initialized, which upstream do initialize them in arch_dup_task_struct(). 

Steps to Reproduce:
1. Compile this module

int init_module(void)
{
	printk(KERN_INFO "[parent ] parent_exec_id: %llu, self_exec_id: %llu\n",
               current->real_parent->task_struct_rh->parent_exec_id, current->real_parent->task_struct_rh->self_exec_id);
	printk(KERN_INFO "[current] parent_exec_id: %llu, self_exec_id: %llu\n",
               current->task_struct_rh->parent_exec_id, current->task_struct_rh->self_exec_id);
	return 0;
}

2. Load it and check dmesg output

Actual results:
[264937.255323] [parent ] parent_exec_id: 64, self_exec_id: 481036337297 <-- seems it is some random value from slab
[264937.255324] [current] parent_exec_id: 481036337297, self_exec_id: 481036337297

Expected results:
[264937.255323] [parent ] parent_exec_id: 64, self_exec_id: 65
[264937.255324] [current] parent_exec_id: 65, self_exec_id: 65

Comment 20 Alex 2021-01-07 16:59:56 UTC
Additional information about the possibility of the integer overflow for the value tsk->parent->self_exec_id:
https://lore.kernel.org/kernel-hardening/20200324215049.GA3710@pi3.com.pl/

Comment 26 Alex 2021-01-07 18:34:52 UTC
Statement:

The incorrect initialization of the process id affects Red Hat Enterprise Linux only.

Comment 28 Alex 2021-01-11 09:33:49 UTC
The description of the flaw:
"A flaw possibility of race condition and incorrect initialization of the process id was found in the Linux kernel child/parent process identification handling while filtering signal handlers.  A local attacker is able to abuse this flaw to bypass checks to send any signal to a privileged process."

The patch from the reference is for the "race condition" only:
https://github.com/torvalds/linux/commit/b4e00444cab4c3f3fec876dc0cccc8cbb0d1a948

The other patch for the "incorrect initialization of the process id" is internal and for the Red Hat Enterprise Linux only:
https://mailman-eng.corp.redhat.com/archives/rhkernel-list/2020-December/498644.html

Comment 29 Alex 2021-01-14 12:00:24 UTC
Acknowledgments:

Name: Eddy Wu (trendmicro.com)


Note You need to log in before you can comment on or make changes to this bug.