Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2305303pxp; Mon, 21 Mar 2022 16:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWFOAUCznUeXZ0i0M+uDOR7RF4eyq34yLaaytFSuQK+kia7Hwb7rxKznGBbhR0Q6zz26di X-Received: by 2002:a63:31cf:0:b0:382:2647:d3a9 with SMTP id x198-20020a6331cf000000b003822647d3a9mr15986483pgx.306.1647905167141; Mon, 21 Mar 2022 16:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647905167; cv=none; d=google.com; s=arc-20160816; b=KRXlk5xyReBq+GzJIdw63AGm3KqI6KFDLXhBgAIrFJgmCgKUZKtFr/rKpo7Jl4RGfd /6r8duBgPZ0PS+WmEaEfF5owGfafgQ7uaOtC+pmjiLj5+/mFw604HgVlSA/pBFm1mcxG gweGIpT0km8gc95llORZ1ZLWidwcIggNCHmAdx/YrT78nrw38QUGGwNk946W1oaMy8PM Um6l6qc3vLvhEEV90sLeN0k5YIKGsQVOUJUWO0DVvxcYUNQeCM8BNhzpF80so/0+u656 MKV0tnHel8flsbqge4zIfCM3a8kgtYi7IxXS4L26LFGBBNTWgLet8KHazOpynEknVtUj 8DGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OmmvTS574F2TLGA1k+CPVPSsUSVscLOfKwhcjjj3Fw0=; b=a1gcgFZzxWTg/jmeBKAygummPHI4vignmxb72CDlPByiyMOajMpdqcqgtf858MMJuG de5VPMPUKPTrrri2FvOusz07znv5mAth515tp4HshdWFD6kmbTIU1syTNjg3e20e35HH l/E/ae4BxlY1Wo5T5Ez+opkYoTm3XV07ACck2xquyxrYUKcaGPPDdWX+3hVdv5dNWpGt ynvS/0JdGtG4ovsD/QgcLNb+QebBIQtr/617pN6wjyhLn+k1KHThEuWb5vXHtc3qTNuW yDDv9kQxbuALZYD0/E/CaAPtDl35v28pep/zXvVsmrlI5xfondZqfNRdssaStfUx8bRf bP+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wNYvsx8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e2-20020a63e002000000b003816043ef3bsi14564233pgh.304.2022.03.21.16.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wNYvsx8q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 58D6F45643C; Mon, 21 Mar 2022 15:16:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348704AbiCUOFX (ORCPT + 99 others); Mon, 21 Mar 2022 10:05:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349147AbiCUN7Y (ORCPT ); Mon, 21 Mar 2022 09:59:24 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6422D7672; Mon, 21 Mar 2022 06:57:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F3D19611D5; Mon, 21 Mar 2022 13:57:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AB74C340E8; Mon, 21 Mar 2022 13:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871077; bh=dGOcXsBKGb+pa/3WupTRMH4qEFSFdcbUJ2kNGLJFczo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wNYvsx8qu26nv3wSAKblb/LEd3/1mpmDYk8Rjtpp3v0ZBt+fND6vYqo40LCbaGIAt xOtGCsA3lpCKE94SOdu/BjzvDWal1CNzoI23Kb4ehsgKY17NaI1x5lMY2Lm04aymwL d+HGK9/rXMvQh9fEiJCXvOYpAxbRNT4/QHcYXL0k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Dmitry Torokhov , syzbot+75cccf2b7da87fb6f84b@syzkaller.appspotmail.com Subject: [PATCH 5.4 15/17] Input: aiptek - properly check endpoint type Date: Mon, 21 Mar 2022 14:52:51 +0100 Message-Id: <20220321133217.597455661@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133217.148831184@linuxfoundation.org> References: <20220321133217.148831184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin commit 5600f6986628dde8881734090588474f54a540a8 upstream. Syzbot reported warning in usb_submit_urb() which is caused by wrong endpoint type. There was a check for the number of endpoints, but not for the type of endpoint. Fix it by replacing old desc.bNumEndpoints check with usb_find_common_endpoints() helper for finding endpoints Fail log: usb 5-1: BOGUS urb xfer, pipe 1 != type 3 WARNING: CPU: 2 PID: 48 at drivers/usb/core/urb.c:502 usb_submit_urb+0xed2/0x18a0 drivers/usb/core/urb.c:502 Modules linked in: CPU: 2 PID: 48 Comm: kworker/2:2 Not tainted 5.17.0-rc6-syzkaller-00226-g07ebd38a0da2 #0 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.14.0-2 04/01/2014 Workqueue: usb_hub_wq hub_event ... Call Trace: aiptek_open+0xd5/0x130 drivers/input/tablet/aiptek.c:830 input_open_device+0x1bb/0x320 drivers/input/input.c:629 kbd_connect+0xfe/0x160 drivers/tty/vt/keyboard.c:1593 Fixes: 8e20cf2bce12 ("Input: aiptek - fix crash on detecting device without endpoints") Reported-and-tested-by: syzbot+75cccf2b7da87fb6f84b@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/20220308194328.26220-1-paskripkin@gmail.com Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/input/tablet/aiptek.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/drivers/input/tablet/aiptek.c +++ b/drivers/input/tablet/aiptek.c @@ -1801,15 +1801,13 @@ aiptek_probe(struct usb_interface *intf, input_set_abs_params(inputdev, ABS_TILT_Y, AIPTEK_TILT_MIN, AIPTEK_TILT_MAX, 0, 0); input_set_abs_params(inputdev, ABS_WHEEL, AIPTEK_WHEEL_MIN, AIPTEK_WHEEL_MAX - 1, 0, 0); - /* Verify that a device really has an endpoint */ - if (intf->cur_altsetting->desc.bNumEndpoints < 1) { + err = usb_find_common_endpoints(intf->cur_altsetting, + NULL, NULL, &endpoint, NULL); + if (err) { dev_err(&intf->dev, - "interface has %d endpoints, but must have minimum 1\n", - intf->cur_altsetting->desc.bNumEndpoints); - err = -EINVAL; + "interface has no int in endpoints, but must have minimum 1\n"); goto fail3; } - endpoint = &intf->cur_altsetting->endpoint[0].desc; /* Go set up our URB, which is called when the tablet receives * input.