Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2579207imu; Thu, 29 Nov 2018 07:10:05 -0800 (PST) X-Google-Smtp-Source: AFSGD/VQy0B9Ew1byXZXWWx07bCNqhJDYSl+6C7OffXSwcZmS7NrJc+pgZF8/nMQL1lQLFlucKgH X-Received: by 2002:a17:902:7443:: with SMTP id e3mr1837191plt.304.1543504205229; Thu, 29 Nov 2018 07:10:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543504205; cv=none; d=google.com; s=arc-20160816; b=cgrURWyugnHNVtnilSnf5z27HiZF2HoqYukoJKBFjE8SubK7FAN2o9KsG5Ipnl/k+k HN5y8P5YfJdmY7yfrWIW524uipXJfM9XEKmvVLYDdcloFZiEgdaFq+zF+v8H+S6kvkl7 gpvcI77NNURYVMN7cBz2DCmYWOUm6dzXs+PTAWY+0OhA+1YbLq5PW//BZQsuY+Gou3Kw 1hb8vwqVNFGbvQAhyOIFRzA3kbhEuy4DVacsd1i/+bjbERKVNGLQdjET+wbg21/u8xyi zZn8lczzvmPKqsKVTg/uYiF23ekl4W79xzEGYK1HWHqyb/g4USKwlo2ZHvBpXV0CDanw dt5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ul88guvjMJTbQVl0kJpPemYIUBT3bEPtnVm5M/+5jVc=; b=GA4HCjylmAb9vVVbZ7bI5BCnyOZGcCadXiaxe/WEPqAB19WHkc9lRlD0H3VnZSQZ2+ YRiPVrECTgK6q/1OISakhKoQ2HVItSX8pH6wlq6ftl9rmL6ou6/5ZY7vBvocvXytVqXY nV64AL2Yq4JKiL9hGJs9UuAJkqPjnm6gZlYle7p7ab5XyAZvKZcO6e35uFUzLjdKtZsq sNlhTa/xXyOgjlG/VjM/8bGtKLUOsYJJrcEIXdEkUgSJV8qUIogDQvjlpBGJIrwexm4z rZ389sN+etSuFaJWs31Viup8e1kFgoWigCoHAYJB2ymaPkX/lPatRxUcpeAszEKat5BD k+qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yuzaAKkx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a6si264899pfa.227.2018.11.29.07.09.42; Thu, 29 Nov 2018 07:10:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yuzaAKkx; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729490AbeK3BUk (ORCPT + 99 others); Thu, 29 Nov 2018 20:20:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:41692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728241AbeK3BUj (ORCPT ); Thu, 29 Nov 2018 20:20:39 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 96DBA21019; Thu, 29 Nov 2018 14:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543500909; bh=09ke7C3qdBawlccInrmcGB+ngRZlvVHAFWticF2xNnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yuzaAKkxkTfm7GJeldXIXyiINGXHcI156RTDD5KqnX61GQJP2kKCeHXd/Fe7navjv 5Y8Js4J06oMZ4DG/AhumEskvmQC1I7lBNhv/hV7tPfvG815tB5N66b6OCL5zxnOwbH uI817dh0WFl8BI78AMdjQHtGkC5bZOxTba8K5D8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Cameron Gutman , Dmitry Torokhov , Sasha Levin Subject: [PATCH 3.18 48/83] Input: xpad - fix oops when attaching an unknown Xbox One gamepad Date: Thu, 29 Nov 2018 15:12:06 +0100 Message-Id: <20181129140140.411763683@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129140138.002176596@linuxfoundation.org> References: <20181129140138.002176596@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit c7f1429389ec1aa25e042bb13451385fbb596f8c ] Xbox One controllers have multiple interfaces which all have the same class, subclass, and protocol. One of the these interfaces has only a single endpoint. When Xpad attempts to bind to this interface, it causes an oops when trying initialize the output URB by trying to access the second endpoint's descriptor. This situation was avoided for known Xbox One devices by checking the XTYPE constant associated with the VID and PID tuple. However, this breaks when new or previously unknown Xbox One controllers are attached to the system. This change addresses the problem by deriving the XTYPE for Xbox One controllers based on the interface protocol before checking the interface number. Fixes: 1a48ff81b391 ("Input: xpad - add support for Xbox One controllers") Signed-off-by: Cameron Gutman Cc: stable@vger.kernel.org Signed-off-by: Dmitry Torokhov Signed-off-by: Sasha Levin --- drivers/input/joystick/xpad.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index 6586d7ae0019..05a5c647ed36 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1442,16 +1442,6 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id break; } - if (xpad_device[i].xtype == XTYPE_XBOXONE && - intf->cur_altsetting->desc.bInterfaceNumber != 0) { - /* - * The Xbox One controller lists three interfaces all with the - * same interface class, subclass and protocol. Differentiate by - * interface number. - */ - return -ENODEV; - } - xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL); if (!xpad) return -ENOMEM; @@ -1483,6 +1473,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) xpad->xtype = XTYPE_XBOX360W; + else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) + xpad->xtype = XTYPE_XBOXONE; else xpad->xtype = XTYPE_XBOX360; } else { @@ -1497,6 +1489,17 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->mapping |= MAP_STICKS_TO_NULL; } + if (xpad->xtype == XTYPE_XBOXONE && + intf->cur_altsetting->desc.bInterfaceNumber != 0) { + /* + * The Xbox One controller lists three interfaces all with the + * same interface class, subclass and protocol. Differentiate by + * interface number. + */ + error = -ENODEV; + goto err_free_in_urb; + } + error = xpad_init_output(intf, xpad); if (error) goto err_free_in_urb; -- 2.17.1