Bug 1784911 (CVE-2019-19813)

Summary: CVE-2019-19813 kernel: use-after-free in __mutex_lock in kernel/locking/mutex.c
Product: [Other] Security Response Reporter: Guilherme de Almeida Suckevicz <gsuckevi>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: acaringi, airlied, allarkin, bdettelb, bhu, blc, brdeoliv, bskeggs, dhoward, dvlasenk, esammons, fhrbata, hdegoede, hkrzesin, iboverma, ichavero, itamar, jarodwilson, jeremy, jforbes, jglisse, jlelli, john.j5live, jonathan, josef, jross, jschorr, jshortt, jstancek, jwboyer, kernel-maint, kernel-mgr, labbott, lgoncalv, linville, masami256, matt, mchehab, mcressma, mjg59, mlangsdo, nmurray, qzhao, rt-maint, rvrbovsk, steved, williams, yozone
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-03-31 16:31:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On: 1784913    
Bug Blocks: 1784914    

Description Guilherme de Almeida Suckevicz 2019-12-18 17:28:58 UTC
In the Linux kernel 5.0.21, mounting a crafted btrfs filesystem image, performing some operations, and then making a syncfs system call can lead to a use-after-free in __mutex_lock in kernel/locking/mutex.c. This is related to mutex_can_spin_on_owner in kernel/locking/mutex.c, __btrfs_qgroup_free_meta in fs/btrfs/qgroup.c, and btrfs_insert_delayed_items in fs/btrfs/delayed-inode.c.

Reference:
https://github.com/bobfuzzer/CVE/tree/master/CVE-2019-19813

Comment 1 Guilherme de Almeida Suckevicz 2019-12-18 17:34:17 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1784913]

Comment 2 Alex 2020-03-31 13:19:27 UTC
For Rhel8 the BTRFS not being used ("CONFIG_BTRFS_FS is not set"), so bug not actual for Rhel8.

Before Rhel8 this bug was not actual, because function mutex_can_spin_on_owner(..) was different:
the code in Rhel7 didn't contain "owner = __mutex_owner(lock)" yet and the bug is because of this line of code and then check "owner->on_cpu" where owner could be already freed even it was not NULL a moment before;

also __mutex_owner(..) could return NULL by design and should not be called directly;
for more details regarding __mutex_owner(..), see https://github.com/torvalds/linux/blob/master/kernel/locking/mutex.c , and example of usage in func mutex_is_locked(..).

The provided info above could be used to develop patch (since I didn't find ready to use patch).

Comment 3 Product Security DevOps Team 2020-03-31 16:31:56 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-2019-19813