From patchwork Mon Oct 24 11:32:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9238 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp461131wru; Mon, 24 Oct 2022 06:43:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72B3PtgeEdHo/pEr4FZB73CPyFWsaH7WAtJOCI+heWUhIllMRw7frEsMsiYd7w89gQTWiJ X-Received: by 2002:a17:907:608a:b0:791:9dbc:cc11 with SMTP id ht10-20020a170907608a00b007919dbccc11mr27236182ejc.357.1666618993025; Mon, 24 Oct 2022 06:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618993; cv=none; d=google.com; s=arc-20160816; b=tClFjiDfja1DlAE94Eg0Vd8RnS0oprWWzhekokWVUFgEqiZynxVndc+gvxbKBkBI5R KibDLSixOQg/DiuTwTwHXioeFOCB+0TqyksvJLvdWOALiA8AS8hdH5gGtU4VAy8/X8fF wDrvkY6FVHHB9YSDLJEl+LTiaasV5/eqERKS2ldF2ycAsgh80b+Q3XeLWNcBmd8hDu/L rAbJgph+ebmp/ZngBGcOHPvXJXzvk6Wuz5wpU5JiMmdScxFdtrZQlRcE6cAzi7c0V4jy oO1t8bHxe5fLLCKiePPIwsGTCxJt9ms1qK8bncnsJESKf0KKgdHC8VwkO4dwUc5LCKfG 8FYw== 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=10suO6Ku1BxCpxh9hBNndXSI7ZETMWQubE9F20GAvrE=; b=AnGK9G71pqSpHhvApQsPEfChaRNG1q6Dac3EozyLsJHLwU/3ofL3/BFmr5g/Ti0ZHY 9KV3VenyXuAFpgGww/1Iu/3KJRt2V2P0tuZ6pCTwlQq5mEuwrDFcSDXEhkGJTvcE3IuC L2HOWj0RIQ1560Mo+Zq8TC1AC7uGxYtXdpa8UB042l85AqWKXE5yz+0CH+NiiGc6ox67 mJ4WzvJwUDNu+4oPNnnov9bmJ0ugs9+EKESdDU0rSzDrB0OdTJ6MPU3ZIXVdwAFgu7ks itBtoOyyIcTHC71FfNgigksq2l2gcUZdLj3SzOm/GoK9xg6fWbazMHbRBwtEfLUNKQKb qlWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XiaERIhJ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y17-20020a056402359100b0045d5cf18d4bsi28126327edc.583.2022.10.24.06.42.45; Mon, 24 Oct 2022 06:43:13 -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=XiaERIhJ; 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 S236104AbiJXNh6 (ORCPT + 99 others); Mon, 24 Oct 2022 09:37:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235985AbiJXNeL (ORCPT ); Mon, 24 Oct 2022 09:34:11 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 977B02CE09; Mon, 24 Oct 2022 05:34:57 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3A624B81147; Mon, 24 Oct 2022 12:04:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936ADC433C1; Mon, 24 Oct 2022 12:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613079; bh=9IwWBpBPAy1XPz+qmN4K1594agSedGaY6AGFztpHjGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XiaERIhJoIIZem7Cw4OyLlbUIvsnYq/jMpJupzOGZXgjT2JTjVLEP79uZ9zRRO/41 jBgDT+lTBE9la1CSlp/efoImQJmvvNYEpp3uiYa1Ye+LrpcZW52kZfNYI8Veg1D9yv ONpiwFJFPAfJlF7xRkFu1bF6yuE62p4E7V0htJwA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+79832d33eb89fb3cd092@syzkaller.appspotmail.com, Dongliang Mu , Sasha Levin Subject: [PATCH 4.19 219/229] usb: idmouse: fix an uninit-value in idmouse_open Date: Mon, 24 Oct 2022 13:32:18 +0200 Message-Id: <20221024113006.330019597@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747576677039994543?= X-GMAIL-MSGID: =?utf-8?q?1747576677039994543?= From: Dongliang Mu [ Upstream commit bce2b0539933e485d22d6f6f076c0fcd6f185c4c ] In idmouse_create_image, if any ftip_command fails, it will go to the reset label. However, this leads to the data in bulk_in_buffer[HEADER..IMGSIZE] uninitialized. And the check for valid image incurs an uninitialized dereference. Fix this by moving the check before reset label since this check only be valid if the data after bulk_in_buffer[HEADER] has concrete data. Note that this is found by KMSAN, so only kernel compilation is tested. Reported-by: syzbot+79832d33eb89fb3cd092@syzkaller.appspotmail.com Signed-off-by: Dongliang Mu Link: https://lore.kernel.org/r/20220922134847.1101921-1-dzm91@hust.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/misc/idmouse.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index bb24527f3c70..ba2b6fbab9b8 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -178,10 +178,6 @@ static int idmouse_create_image(struct usb_idmouse *dev) bytes_read += bulk_read; } - /* reset the device */ -reset: - ftip_command(dev, FTIP_RELEASE, 0, 0); - /* check for valid image */ /* right border should be black (0x00) */ for (bytes_read = sizeof(HEADER)-1 + WIDTH-1; bytes_read < IMGSIZE; bytes_read += WIDTH) @@ -193,6 +189,10 @@ static int idmouse_create_image(struct usb_idmouse *dev) if (dev->bulk_in_buffer[bytes_read] != 0xFF) return -EAGAIN; + /* reset the device */ +reset: + ftip_command(dev, FTIP_RELEASE, 0, 0); + /* should be IMGSIZE == 65040 */ dev_dbg(&dev->interface->dev, "read %d bytes fingerprint data\n", bytes_read);