Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp758075pxp; Wed, 16 Mar 2022 16:25:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydaYvP3vNKwqpMXBAnNuYCYfZfOpRWPaz6aQvgOMLzn6fAxjVgPczncsh8njkvVm25ZhSH X-Received: by 2002:a17:90b:384b:b0:1bf:12d8:62c0 with SMTP id nl11-20020a17090b384b00b001bf12d862c0mr13004904pjb.142.1647473112891; Wed, 16 Mar 2022 16:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647473112; cv=none; d=google.com; s=arc-20160816; b=xF5tZeJkhfEah91R4FcdzunlxG4SYV5hK7dU9kb0srFx1QYBA3CG0xSpMK15EFyG3/ Q3MzxKHmLJXJM/mDMakoy+OyGGjwMv1M5Tk/Ix414WAl+nQNvpLSxK8oScMwq0oYL0MI PbWzRuHJZpqo1pwNRMuesw5UZuevfCRsp/YktP4q86iFgWHiqVmh5W9ib8Oa7ScIRrBR 29Z7Vzoy5C/FMTWwQ3CsJIU/Fo+w6ykZ5GyXDLGN6ohWv10OvaS5JTXVtcEUrjenWuSZ e4PSjz+pApRevfUQ7wmoJZ+baWcawAvGfDtfCRfixPYIGl/ryx91PMHUcivrFu18JR0m VclA== 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=L+0A3XCxPoFWaK//S+QyWZbLl6H5riwz9qPKhVrNFtg=; b=xy6M5cPsmZ94rTnsnchrYk/AnZ78boadcr5SrlIC3XZKDplJYoCINFejg5xY/4AKjw q7mvc2eA0II3/BjTxhHbcdK1FGdnPXJiWKK+N19bKIlPVs5D4uY9Z4tNg/x8XdoPO28M lg4V1zR4Ng87bM6+M33XhfskWW+h2WBntUPfAcfVCLmzHrrxAaMB07hpZ54rXFLRy5Zv yrdlEJLS5dGNGFacQoUg0xGPJc1dUWUUDD4cFHCL0KBGxrBNZ3aCIlbHSERJ0F7hnZuZ QZpjMbvn+6u2ZdlTfHSHQ8MNF2Q10OTBc2Ac70m8W4eq8MpsPklrMH95DXiWM35PREFB k1jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qvUTwMRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q22-20020a170902789600b001533a407043si2708669pll.382.2022.03.16.16.24.59; Wed, 16 Mar 2022 16:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qvUTwMRb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236407AbiCNMYq (ORCPT + 99 others); Mon, 14 Mar 2022 08:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241729AbiCNMSV (ORCPT ); Mon, 14 Mar 2022 08:18:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1CFABC0A; Mon, 14 Mar 2022 05:12:54 -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 11B8061382; Mon, 14 Mar 2022 12:12:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D03C0C340E9; Mon, 14 Mar 2022 12:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1647259973; bh=jt+cYboBf6a9eltsE2cy5RocCv4dZOC0FFIQxWaw7dY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qvUTwMRbkcq0fd2ZUNslUtrZEXKMw96l9txMNh4WPKddUbg5al+QMvXcbOAZgb51H BYktA9jfwO6lo9167JmRHuve0WRDYKKpC28ajXS3BGhlwUwwqlYuFKcWLhlgTeiwRA A5pi2zKM+bv3EH9AYpj08T4+76XpTMe1s8jHH7/M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Jiri Kosina , Sasha Levin , syzbot+35eebd505e97d315d01c@syzkaller.appspotmail.com Subject: [PATCH 5.16 004/121] HID: hid-thrustmaster: fix OOB read in thrustmaster_interrupts Date: Mon, 14 Mar 2022 12:53:07 +0100 Message-Id: <20220314112744.246863886@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314112744.120491875@linuxfoundation.org> References: <20220314112744.120491875@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=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 [ Upstream commit fc3ef2e3297b3c0e2006b5d7b3d66965e3392036 ] Syzbot reported an slab-out-of-bounds Read in thrustmaster_probe() bug. The root case is in missing validation check of actual number of endpoints. Code should not blindly access usb_host_interface::endpoint array, since it may contain less endpoints than code expects. Fix it by adding missing validaion check and print an error if number of endpoints do not match expected number Fixes: c49c33637802 ("HID: support for initialization of some Thrustmaster wheels") Reported-and-tested-by: syzbot+35eebd505e97d315d01c@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-thrustmaster.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hid/hid-thrustmaster.c b/drivers/hid/hid-thrustmaster.c index 03b935ff02d5..9da4240530dd 100644 --- a/drivers/hid/hid-thrustmaster.c +++ b/drivers/hid/hid-thrustmaster.c @@ -158,6 +158,12 @@ static void thrustmaster_interrupts(struct hid_device *hdev) return; } + if (usbif->cur_altsetting->desc.bNumEndpoints < 2) { + kfree(send_buf); + hid_err(hdev, "Wrong number of endpoints?\n"); + return; + } + ep = &usbif->cur_altsetting->endpoint[1]; b_ep = ep->desc.bEndpointAddress; -- 2.34.1