Bug 1312670 (CVE-2016-2782)

Summary: CVE-2016-2782 kernel: visor: crash on invalid USB device descriptors in treo_attach() in visor driver
Product: [Other] Security Response Reporter: Vladis Dronov <vdronov>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: unspecifiedCC: agordeev, aquini, arm-mgr, bhu, dhoward, esammons, fhrbata, gansalmon, iboverma, itamar, jforbes, jkacur, joelsmith, jonathan, jross, jwboyer, kernel-maint, kernel-mgr, kstutsma, lgoncalv, lwang, madhu.chinakonda, matt, mchehab, mcressma, mguzik, nmurray, pholasek, plougher, rt-maint, rvrbovsk, williams
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-28 19:26:49 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: 1283374, 1312671    
Bug Blocks: 1312672    

Description Vladis Dronov 2016-02-28 16:48:27 UTC
A local kernel crash on invalid USB device requiring the visor driver was reported. The treo_attach() function of the [visor] driver, which is called during the driver initialization process, was dereferencing the bulk-in and interrupt-in urbs without first making sure they had been allocated by core. Due to an incomplete sanity check, the visor driver tries to dereference null-pointers, which results in crash. 

Vulnerable code:

**** CentOS-Kernel linux-3.10.0-229.14.1.el7 (drivers/usb/serial/visor.c)
        ...
554	#define COPY_PORT(dest, src)						\
555	do { \
556		int i;							\
557									\
558		for (i = 0; i < ARRAY_SIZE(src->read_urbs); ++i) {	\
559			dest->read_urbs[i] = src->read_urbs[i];		\ /* Possible Nullpointer-Dereference */
560			dest->read_urbs[i]->context = dest;		\
561			dest->bulk_in_buffers[i] = src->bulk_in_buffers[i]; \
562		}							\
563		dest->read_urb = src->read_urb;				\
564		dest->bulk_in_endpointAddress = src->bulk_in_endpointAddress;\
565		dest->bulk_in_buffer = src->bulk_in_buffer;		\
566		dest->bulk_in_size = src->bulk_in_size;			\
567		dest->interrupt_in_urb = src->interrupt_in_urb;		\
568		dest->interrupt_in_urb->context = dest;			\
569		dest->interrupt_in_endpointAddress = \
570					src->interrupt_in_endpointAddress;\
571		dest->interrupt_in_buffer = src->interrupt_in_buffer;	\
572	} while (0);
573
574	swap_port = kmalloc(sizeof(*swap_port), GFP_KERNEL);
575	if (!swap_port)
576		return -ENOMEM;
577	COPY_PORT(swap_port, serial->port[0]);        /* no sanity-check! */
578	COPY_PORT(serial->port[0], serial->port[1]);  /* no sanity-check! */
579	COPY_PORT(serial->port[1], swap_port);        /* no sanity-check! */
        ...
****

Reproducer can be found in original bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1283374

An upstream patch:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=cb3232138e37129e88240a98a1d2aba2187ff57c

Public via:
http://seclists.org/bugtraq/2016/Mar/86

CVE-ID request and assignment:
http://seclists.org/oss-sec/2016/q1/456
http://seclists.org/oss-sec/2016/q1/458

Comment 1 Vladis Dronov 2016-02-28 16:49:19 UTC
Created kernel tracking bugs for this issue:

Affects: fedora-all [bug 1312671]

Comment 2 Vladis Dronov 2016-02-28 17:09:11 UTC
Acknowledgments:

Name: Ralf Spenneberg (OpenSource Security)

Comment 3 Vladis Dronov 2016-02-28 17:09:53 UTC
Statement:

This issue does not affect the Linux kernel packages as shipped with Red Hat Enterprise Linux 5, 6 as the code with the flaw is not present in the products listed.

This issue affects the Linux kernel packages as shipped with Red Hat Enterprise Linux 7 and MRG-2. This has been rated as having Low security impact and is not currently planned to be addressed in future updates. For additional information, refer to the Red Hat Enterprise Linux Life Cycle: https://access.redhat.com/support/policy/updates/errata/.