Bug 1548412 (CVE-2017-13166)

Summary: CVE-2017-13166 kernel: v4l2: disabled memory access protection mechanism allowing privilege escalation
Product: [Other] Security Response Reporter: Vladis Dronov <vdronov>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: airlied, ajax, bskeggs, ewk, hdegoede, ichavero, itamar, jarodwilson, jforbes, jglisse, john.j5live, jonathan, josef, jwboyer, kernel-maint, labbott, linville, mchehab, mjg59, steved
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 bug in the 32-bit compatibility layer of the ioctl handling code of the v4l2 video driver in the Linux kernel has been found. A memory protection mechanism ensuring that user-provided buffers always point to a userspace memory were disabled, allowing destination address to be in a kernel space. This flaw could be exploited by an attacker to overwrite a kernel memory from an unprivileged userspace process, leading to privilege escalation.
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-08 03:41:04 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: 1548413, 1548429, 1548430, 1548431, 1548432, 1548726, 1548727, 1548728, 1550058, 1550059, 1550060    
Bug Blocks: 1548415    

Description Vladis Dronov 2018-02-23 12:43:00 UTC
A bug in the 32-bit compatibility layer of the ioctl handling code of the v4l2 video driver in the Linux kernel has been found. A memory protection mechanism ensuring that user-provided buffers always point to a userspace memory were disabled, allowing destination address to be in a kernel space. This flaw could be exploited by an attacker to overwrite a kernel memory from an unprivileged userspace process, leading to privilege escalation.

References:

https://source.android.com/security/bulletin/pixel/2017-12-01#kernel-components

https://nvd.nist.gov/vuln/detail/CVE-2017-13166

An upstream fix:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a1dfb4c48cc1e64eeb7800a27c66a6f7e88d075a

Comment 1 Vladis Dronov 2018-02-23 12:43:43 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1548413]

Comment 2 Vladis Dronov 2018-02-23 12:53:23 UTC
details of the flaw impact per upstream commit a1dfb4c48cc1:

...As a workaround, set_fs(KERNEL_DS) is called to temporarily disable this extra safety check and allow kernel pointers. However, this might introduce a security vulnerability: The result of the 32-bit to 64-bit conversion is writeable by user space because the output buffer has been allocated via compat_alloc_user_space(). A malicious user space process could then manipulate pointers inside this output buffer, and due to the previous set_fs(KERNEL_DS) call, functions like get_user() or put_user() no longer prevent kernel memory access.

Comment 6 Justin M. Forbes 2018-02-23 15:17:37 UTC
This was fixed for Fedora with the 4.15.4 stable updates.

Comment 9 Vladis Dronov 2018-02-28 12:18:04 UTC
Mitigation:

A systemtap script intercepting v4l2_compat_ioctl32() function of the [videodev] module and making it to return -ENOIOCTLCMD error value would work just fine, except breaking all 32bit video capturing software, but not 64bit ones.

Alternatively, blacklisting [videodev] module will work too, but it will break all video capturing software.

Comment 12 errata-xmlrpc 2018-04-10 08:19:44 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2018:0676 https://access.redhat.com/errata/RHSA-2018:0676

Comment 13 errata-xmlrpc 2018-04-10 09:43:49 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2018:1062 https://access.redhat.com/errata/RHSA-2018:1062

Comment 14 errata-xmlrpc 2018-04-17 15:33:19 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise MRG 2

Via RHSA-2018:1170 https://access.redhat.com/errata/RHSA-2018:1170

Comment 15 errata-xmlrpc 2018-04-17 16:23:55 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7.4 Extended Update Support

Via RHSA-2018:1130 https://access.redhat.com/errata/RHSA-2018:1130

Comment 16 errata-xmlrpc 2018-05-08 18:59:41 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6

Via RHSA-2018:1319 https://access.redhat.com/errata/RHSA-2018:1319

Comment 17 errata-xmlrpc 2018-10-30 08:58:01 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2018:2948 https://access.redhat.com/errata/RHSA-2018:2948