Bug 1902724 (CVE-2020-35508)

Summary: CVE-2020-35508 kernel: fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: acaringi, adscvr, airlied, allarkin, aquini, bhu, blc, bmasney, brdeoliv, bskeggs, chwhite, dhoward, dvlasenk, esammons, eshatokhin, fhrbata, hdegoede, hkrzesin, iboverma, itamar, jarodwilson, jeremy, jforbes, jglisse, jlelli, jonathan, josef, jross, jshortt, jstancek, jwboyer, kcarcia, kernel-maint, kernel-mgr, lgoncalv, linville, masami256, mchehab, mcressma, michael.hebenstreit, mlangsdo, mmilgram, nmurray, pmatouse, ptalbert, qzhao, rt-maint, rvrbovsk, security-response-team, steved, walters, williams
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 20:37:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1895892, 1904784, 1904785, 1908311, 1950760, 1962333, 1962334    
Bug Blocks: 1896156, 1939994    

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)

Comment 35 errata-xmlrpc 2021-05-18 13:20:37 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:1578 https://access.redhat.com/errata/RHSA-2021:1578

Comment 36 errata-xmlrpc 2021-05-18 14:41:03 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8

Via RHSA-2021:1739 https://access.redhat.com/errata/RHSA-2021:1739

Comment 37 Product Security DevOps Team 2021-05-18 20:37:35 UTC
This bug is now closed. Further updates for individual products will be reflected on the CVE page(s):

https://access.redhat.com/security/cve/cve-2020-35508

Comment 39 Michael Hebenstreit 2021-05-20 13:42:23 UTC
the code changes from https://github.com/torvalds/linux/commit/b4e00444cab4c3f3fec876dc0cccc8cbb0d1a948 are not in the RH8.4 kernel just released

could you attach the info from https://mailman-eng.corp.redhat.com/archives/rhkernel-list/2020-December/498644.html here as that address is RedHat internal?

Comment 40 errata-xmlrpc 2021-07-20 21:27:38 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2021:2719 https://access.redhat.com/errata/RHSA-2021:2719

Comment 41 errata-xmlrpc 2021-07-20 22:10:30 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 8.2 Extended Update Support

Via RHSA-2021:2718 https://access.redhat.com/errata/RHSA-2021:2718