Bug 1905497 (CVE-2020-29534)

Summary: CVE-2020-29534 kernel: io_uring takes a non-refcounted reference to the files_struct of the process that submitted a request, causing execve() to incorrectly optimize unshare_fd() allowing for privileges escalation
Product: [Other] Security Response Reporter: Marian Rehak <mrehak>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: acaringi, adscvr, airlied, bhu, blc, bmasney, brdeoliv, bskeggs, dhoward, dvlasenk, fhrbata, hdegoede, hkrzesin, itamar, jarodwilson, jeremy, jforbes, jglisse, jlelli, jonathan, josef, jshortt, jstancek, jwboyer, kcarcia, kernel-maint, kernel-mgr, lgoncalv, linville, masami256, mchehab, mlangsdo, nmurray, ptalbert, qzhao, rvrbovsk, 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:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-12-08 15:41:47 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: 1905498, 1906390    
Bug Blocks: 1905499    

Description Marian Rehak 2020-12-08 13:58:52 UTC
io_uring takes a non-refcounted reference to the files_struct of the process that submitted a request (relying on ->flush() for being notified before the files_struct can go away). Unfortunately, unshare_fd(), which is used by bprm_execve() via unshare_files(), doesn't know about that, and assumes that if the files_struct's refcount is 1, it is okay to keep using the old files_struct. Therefore, an attacker can cause io_uring to fiddle around in the file descriptor table of a privileged process, and in particular steal file descriptors using IORING_OP_FILES_UPDATE.

References:

https://bugs.chromium.org/p/project-zero/issues/detail?id=2089
https://cdn.kernel.org/pub/linux/kernel/v5.x/ChangeLog-5.9.3
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0f2122045b946241a9e549c2a76cea54fa58a7ff

Comment 1 Marian Rehak 2020-12-08 13:59:31 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1905498]

Comment 2 Justin M. Forbes 2020-12-08 15:13:32 UTC
This was fixed for Fedora with the 5.8.18 stable kernel updates.