From patchwork Mon Oct 24 11:32:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp438363wru; Mon, 24 Oct 2022 06:01:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ZTdWCtI4YgYYz4JB7zFCG4cTAZH0yjiL5XnVEy866x9ipRlUoXvxIl9Z1lHbdhVPztO/n X-Received: by 2002:a05:6e02:1c29:b0:2ff:9ca1:a8f with SMTP id m9-20020a056e021c2900b002ff9ca10a8fmr7795828ilh.47.1666616475056; Mon, 24 Oct 2022 06:01:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616475; cv=none; d=google.com; s=arc-20160816; b=t/AgsAQoNLmep2PUHe/CTD0/V82evMy0mFeZccHzzyO93btTQh8rmfXzet1TFxIcLe nFy0gUKR1QduuQ89GDRBDvXd0f//5o1LtubJKPyW2ICvcOHnXZ2SGBWnfSFSR54O27r0 qSZ3u6yJ46oqfI51WBkIyNbN7P4U1e0iH88UvQwL9HNyXOF+w1Wu+VDKT3noLy1l6RSM GlsDQp+lqKdGsKtubx9Y0tzG7Wnm/md1Pz9p4MV1tB1AOoOEnik+FtZoJo/RSmNOx3T4 GmqpULPAeVUI5XZhUPKCjx+yCw2Lu8P+95onH0wI0pWIF8eC/s2To9+9r3ATHA5OpBq/ VM7w== 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=QhDGDh0OOaAJGc+HBBJms0QiW2tItl2NXXLn2WcuZFVHf08XvVb3wC3/BXY18mGVu2 TIP+nq9PkLGoM8Wih/KjAAxuSj7AmFpOj58xS3Ir30dqzEDbaNQktauX8xdfqoMDczqZ kUSCHxEJo3d0NNbiL+q1Z93rhLnBdEuGpyvg6fL1qaOB0fPxelmxPPHvJ48xPSy6jIQM 8HqtQnn4x+3pY4YoRkATNa1BMSQ7rUQmOCq27kxoDjeGErURN2CshbMFqjsn5TpqIgzl JiDSC8n7wrmPE286EfjOljnatkn3iUiLmwqqbIlHkN38c43rMom/+LvcARYc/4D+aVv5 Q70g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nZ20VDmg; 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 h38-20020a63f926000000b0046ed15b5318si9257702pgi.98.2022.10.24.06.00.50; Mon, 24 Oct 2022 06:01:15 -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=nZ20VDmg; 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 S234886AbiJXNAf (ORCPT + 99 others); Mon, 24 Oct 2022 09:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234896AbiJXM6d (ORCPT ); Mon, 24 Oct 2022 08:58:33 -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 7A50B98357; Mon, 24 Oct 2022 05:17:44 -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 EA5E261329; Mon, 24 Oct 2022 12:15:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D4DC4314A; Mon, 24 Oct 2022 12:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613721; bh=9IwWBpBPAy1XPz+qmN4K1594agSedGaY6AGFztpHjGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZ20VDmgQlUxxj9jkCxBactClz8KR2e6oztdtkgvDV269uK1+6MRivDrr4/Vu8+m9 B50CUla8NIALk8ahdGJSRrmtUW8/4Cbv3pvuf4bkK5jmma/AAhwvUgWCDzVBVzpp5d KegnoHj1z/yj3NugtTu5KsPkb65mlAJaIGx+/GKs= 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 5.4 244/255] usb: idmouse: fix an uninit-value in idmouse_open Date: Mon, 24 Oct 2022 13:32:34 +0200 Message-Id: <20221024113011.373443793@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747574036915316664?= X-GMAIL-MSGID: =?utf-8?q?1747574036915316664?= 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);