From patchwork Tue Sep 12 18:12:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cameron Gutman X-Patchwork-Id: 9949885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7184E6024A for ; Tue, 12 Sep 2017 18:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6031729089 for ; Tue, 12 Sep 2017 18:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 543862908C; Tue, 12 Sep 2017 18:12:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB90E29089 for ; Tue, 12 Sep 2017 18:12:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751452AbdILSMO (ORCPT ); Tue, 12 Sep 2017 14:12:14 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:38899 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbdILSMO (ORCPT ); Tue, 12 Sep 2017 14:12:14 -0400 Received: by mail-pg0-f65.google.com with SMTP id m30so1562874pgn.5; Tue, 12 Sep 2017 11:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7C2Hy1OrTKxfdIZlAi+nXZ80EMQVl+xLtbAkoRIxQM0=; b=KOA9iW927AHOTNs22YRt05FplhYwWG3QACGuWBpgpJdDHfLmeQ/UXptKr3XT6gE0tl Is/n1OBNVlCnGJkgk3HAW/k7PujtAcu5bEpVCJU5TpmDqyXHimPRN0fq55j2M5i2yVT9 0GEBJvBhyh9BmDu5Q1Qn1yIMgHc1ECwXxRyoWFudR1DgqvUZQz33uaRSNfOURjEBZAJV xc6jSM/k4MsUSIzFm2EkuaLXnD/zgnuKmRYZPL4he4Jf/d//aqQvHMeJO/OHWSRtXxY1 0e2YqGRZf1GEMnszl9A+bOJCVMMW4RJzpFuz2Qt1zA4BTkwSyESqkRQO3nNzYqHkyPVe fJJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7C2Hy1OrTKxfdIZlAi+nXZ80EMQVl+xLtbAkoRIxQM0=; b=RFZL0bUYUZ9dgnEdnXYial89sL0nPN/VxzVjxDNQqGrG1vRvubcRHPxr7tGBXsf/3u UvuuwSAyJrGlFF4QjjfxQ/uPG7wrdPhk4QBE2VxWnfOmNThUxYwlxll8M11WPKdkvfKu UPRnddFhIrEr3OG4wBcBxklN8SHyiEjNIW9n8l0upHdXMaPnMYvBEW4UrI2YTXCfSUXa GAtfS/ZRX4CpiYkycvxZfCEjoIcqdByQwvY9VjoooN4xbubsmg8wwUFZwgT4Nnom9ocA PNVkF2WwopcT0v4Sx1ByOKA6iundHk8xXVtapPfuK5TV/GEDwbh/NwE38JPU6Wxg8V4t 2BiQ== X-Gm-Message-State: AHPjjUhaC2I1YZ4oIl6E3cXehioexMf28P7PwuWT0YQBjTC5Se/Q1ePS sCNMmwGxPG4owA== X-Google-Smtp-Source: ADKCNb4eELex7jD/8O1RbYpdNyRmCE3Q7rwOZ0iT0pWs30IWKR/4uRhgcFDQJckYDau2YnMmrwZLzw== X-Received: by 10.98.205.197 with SMTP id o188mr15609560pfg.29.1505239933665; Tue, 12 Sep 2017 11:12:13 -0700 (PDT) Received: from jupiter.localdomain ([2001:470:b:b46:6245:cbff:fe9b:2853]) by smtp.gmail.com with ESMTPSA id m5sm21545853pfh.35.2017.09.12.11.12.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 11:12:13 -0700 (PDT) From: Cameron Gutman To: dmitry.torokhov@gmail.com, rojtberg@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, andreyknvl@google.com, Cameron Gutman Subject: [PATCH] Input: xpad - validate USB endpoint type during probe Date: Tue, 12 Sep 2017 11:12:12 -0700 Message-Id: <20170912181212.15427-1-aicommander@gmail.com> X-Mailer: git-send-email 2.14.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We should only see devices with interrupt endpoints. Ignore any other endpoints that we find, so we don't send try to send them interrupt URBs and trigger a WARN down in the USB stack. Reported-by: Andrey Konovalov Tested-by: Andrey Konovalov Cc: # c01b5e7464f0 Input: xpad - don't depend on endpoint order Cc: Signed-off-by: Cameron Gutman --- To be able to hit any of the LTS kernels, we'll need to also cherry pick c01b5e7464f0 ("Input: xpad - don't depend on endpoint order"). In hindsight, this commit also addresses a malicious USB device case, since a device could purposefully trick us into sending URBs to an endpoint in the wrong direction. --- drivers/input/joystick/xpad.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index f8e34ef643c7..d86e59515b9c 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c @@ -1764,10 +1764,12 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id struct usb_endpoint_descriptor *ep = &intf->cur_altsetting->endpoint[i].desc; - if (usb_endpoint_dir_in(ep)) - ep_irq_in = ep; - else - ep_irq_out = ep; + if (usb_endpoint_xfer_int(ep)) { + if (usb_endpoint_dir_in(ep)) + ep_irq_in = ep; + else + ep_irq_out = ep; + } } if (!ep_irq_in || !ep_irq_out) {