From patchwork Mon Oct 24 11:31:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8838 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp431558wru; Mon, 24 Oct 2022 05:44:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM79u8NOkTYBG34Uj2syKZQUMTmgyRT71NZCeXvmK5aRCzJnCtRjQUnif80F6IBiGsyj4as1 X-Received: by 2002:a17:903:3011:b0:186:892d:1c4c with SMTP id o17-20020a170903301100b00186892d1c4cmr12407819pla.152.1666615450691; Mon, 24 Oct 2022 05:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615450; cv=none; d=google.com; s=arc-20160816; b=nePbiimgIe+Yxs1fz3lqze9GE55eLR57K+Vo42hR2OAGYtLcP+85ZztBIb3zgmC5ef qReGyTiPr5T0OXfyZXaKDWqveyyx9FcQgNz0FmU7DrdfGdoKABsdInu+M57mLhXm1M84 UGhyIDz2cfsSvsOyvBoaxajnGZ2TUNPPV82zZWTVCsm66/D6PGVwHDpnfoPZdyC5Bc3p gGkiIu3kN7tdlBNiTGXTcMgtL8w7D83cdfiZy/d9GI6GhkfPr5cl7CIktM59XLZgi/be A3aWT7vMOijm/uP6pHyj6lOAiYr1fFhU3azI/HG0GumLmk3qm0ewMGyJnozCvi1lN3ms aO/g== 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=hA6+ohBTG+rRER4WNI0emvGPoBr2lMDjPZwMQNWLX6Y=; b=vMT66XxuMyjX0hkuBJvdHRl2t/cPxbpmOOJ/i0YRc/Y0F4/Wl5D0bUrWOdgotRy4zx mR0eM4XIhwmB+AxuQzhWhnMmUQdj2nvmw4PF+fD9umNxgqm/L1pvCP2Pg6cjwWTGf8Vt q2ea3UTZDQ5lkIZ70B7q4ZY3Rc+sQJdgDIpNAU2tDCkQJVKq8LU/rE/OI/lI/pDF9oSg HEjnOguMF9+y11Fz2GyqerKsdEaZ0ISZl5E0RZ6xDftHR+SRgjHEXYz6GI2nRAsWzUEE OKO9XrT59cFtmpfAkKeWCE1VMMRfnn3UHySEd9rjqty4tyJknwUV5mCPXFiog+93VUK/ NDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GJUtFvGJ; 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 bk13-20020a056a02028d00b0045fe55a7d06si34542239pgb.377.2022.10.24.05.43.56; Mon, 24 Oct 2022 05:44:10 -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=GJUtFvGJ; 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 S234530AbiJXMfY (ORCPT + 99 others); Mon, 24 Oct 2022 08:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234247AbiJXM3u (ORCPT ); Mon, 24 Oct 2022 08:29:50 -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 9AF2A3334D; Mon, 24 Oct 2022 05:03: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 ams.source.kernel.org (Postfix) with ESMTPS id B700EB81195; Mon, 24 Oct 2022 11:45:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E3F2C433D6; Mon, 24 Oct 2022 11:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611925; bh=Mj21hyBrDjmSdd2jWfMhrCp60Lexb3CWLmw3cQrt69Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GJUtFvGJwGS8BLBZUndiGOpb1Y1LF/b4v5yXFm7yN8gjvAA5SdgEX+qbtp0VGVczX +BShqVyllmwPuPKp+ya/u+vbTNfZagAtdHOOpeJ8or+OhRfibzAZVqdV9NwuQ1vIxg 92H5jydW5wHEBTuqikJJvsqcqy6sV12TlXQ+1tmI= 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.9 152/159] usb: idmouse: fix an uninit-value in idmouse_open Date: Mon, 24 Oct 2022 13:31:46 +0200 Message-Id: <20221024112954.968123565@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747572963206165274?= X-GMAIL-MSGID: =?utf-8?q?1747572963206165274?= 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 9cf8a9b16336..51f5cee880b2 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -183,10 +183,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) @@ -198,6 +194,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);