Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2274640pxp; Mon, 21 Mar 2022 15:36:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbO74FynCXeTQ4RtpfL9AMdt50X2PEzfgk/kWYEgCuiMg5HAy3iPNMekmMbAJ75Hq9o1uf X-Received: by 2002:a17:90b:1e04:b0:1c6:fb36:9d93 with SMTP id pg4-20020a17090b1e0400b001c6fb369d93mr1412339pjb.57.1647902162775; Mon, 21 Mar 2022 15:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902162; cv=none; d=google.com; s=arc-20160816; b=dOT2Zk4wAqvc+YC9h5vDdUTHV/UmVQb7lhDx1MV8JzFRGxu0GNQb5V1AGtbkTGSLXf xYeryLji2f57AXc8oADcTzJFTpFxdqHCJmDEv7k1HUigATLLpI4THBucY79k19dBmN1F PfdvuFrHVgkTd23tGJd0ZOQQt7Pwi/d6el4UssE6U4nkcQZ8XEui3cha3ShlY7qPGtl0 1NeLyp3LnHTOd0SAprucKUsRwYHT7A4Y4hkAm6Y9jQJnXVunVjQPLjABA6hdQI8PPkx5 wAlIoZZTJizlEJzLVgyHJE03YXxMKwwt1xi2vJ4Ti6pqUZRSnHwfrJaznUiDcbV8kK1w ZzMA== 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=vK0Ct1owvQeDEf8xGIMjV2lRFXOB4nN0/Y3F8Rc+2G8=; b=oqhPUKb3ynNTvxFp6poejRCj6OUS09pnwzIw/EMReg/MWGLJ24/HBtP37x7CDrkn6N kNBwlmm8sSPoauN4p4Nlh1WoQMx/z4jMG3geuElm6/EFRLz4PhP1Uz8LcF+qmPgjJfPF 4WREH1vfSjC4c9aUDxI1QACdFclNu0DgmXuZKr6BAcsBRdIWm/ulN0944xcNDNybb5ZG tUFIteuuDmXoZJbNl9/Sy5Xwvbi0GwqZwcf43nOBN2g8NLVwIJrrY2tmW+7y2bfTKKCc IeeDSt6MGrFjS4k1TyYFRLy6jts1jWZQgnbywbZTgNlpG4Xc+n6Kd0c8JwETe0YNjEHa NrYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YRV8wkcL; 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 s12-20020a056a0008cc00b004fa3a8e0040si9486770pfu.247.2022.03.21.15.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:36:02 -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=YRV8wkcL; 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 BF0483B8C28; Mon, 21 Mar 2022 14:49:02 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351123AbiCUOKk (ORCPT + 99 others); Mon, 21 Mar 2022 10:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349405AbiCUODm (ORCPT ); Mon, 21 Mar 2022 10:03:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E06D17C404; Mon, 21 Mar 2022 07:01:03 -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 F3497611D5; Mon, 21 Mar 2022 14:01:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FA2AC340E8; Mon, 21 Mar 2022 14:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647871262; bh=ZaI+z8jCsQjDVirhHnBpi8JKgIL/KUzOPVBzH8tgTL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRV8wkcLg+d9V8eYwvuk2RIB1V0NeFyH/KOq4lZX9spEwf8EcjVnsAJPVlsOkHzDI xU7mmp6znbGIBC9rwgPKpwBMEupguios8TGAwaAFZJSJCFj++/nZC9/2QBTfG3JGbu w2pfbtRjMvenDXFsteTPuBl9RP6pem4iOpNS309A= 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.15 30/32] Input: aiptek - properly check endpoint type Date: Mon, 21 Mar 2022 14:53:06 +0100 Message-Id: <20220321133221.432170158@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321133220.559554263@linuxfoundation.org> References: <20220321133220.559554263@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 @@ -1787,15 +1787,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.