From: Oliver Neukum Date: Tue, 15 Mar 2016 09:14:04 +0000 (+0100) Subject: USB: cdc-acm: more sanity checking X-Git-Tag: v4.1.12-92~150^2~32 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d633c09cbbca18ad166f5a160806e69441bc155b;p=users%2Fjedix%2Flinux-maple.git USB: cdc-acm: more sanity checking Orabug: 23331129 [ Upstream commit 8835ba4a39cf53f705417b3b3a94eb067673f2c9 ] An attack has become available which pretends to be a quirky device circumventing normal sanity checks and crashes the kernel by an insufficient number of interfaces. This patch adds a check to the code path for quirky devices. Signed-off-by: Oliver Neukum CC: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin (cherry picked from commit a635bc779e7b7748c9b0b773eaf08a7f2184ec50) Signed-off-by: Dan Duval --- diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index cd03fe07f1b1..4cb106accd74 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1118,6 +1118,9 @@ static int acm_probe(struct usb_interface *intf, if (quirks == NO_UNION_NORMAL) { data_interface = usb_ifnum_to_if(usb_dev, 1); control_interface = usb_ifnum_to_if(usb_dev, 0); + /* we would crash */ + if (!data_interface || !control_interface) + return -ENODEV; goto skip_normal_probe; }