Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp886307rwi; Wed, 19 Oct 2022 04:19:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6DQ1iJ5e9ofuoxvz2Dj9IoroSixWr41SAcF2L8H2fiMDGffNdMdVmpFgp1LXY3YWwRP+DR X-Received: by 2002:a17:90a:2bcb:b0:20a:ea55:32ef with SMTP id n11-20020a17090a2bcb00b0020aea5532efmr44816821pje.59.1666178363024; Wed, 19 Oct 2022 04:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178363; cv=none; d=google.com; s=arc-20160816; b=t3eIsU/Ei/f9Kdl+pMnGPQEoroGtUKABp20ECv+8MlMA/aFStluS0VVzHmSGqGUxDY iTSoqJqw58cRgmhrMqz0SFl6AnSJJxz53GnGRce8yiGWWNnV/x9JE34kkmcQCf3z525r RQ9TO+TaUcpeus3+/aA4Li45zFFEVw6FSickLWSG3U9UFaDqAlpyvLMxtz8AhMPiIK82 NXuNuJMkfRrCJUhvPMjYY6iWcMkyWScAWL3h6iFcuD/wO6hw+QS5XWjEaurBKSgyzcXm CJhw2I4pBQ722z3eLChW/4Fu4EtAhsnLTq6YY3Xw0wjr769CKnHlJMB6f4jPT9txSVtW BcmA== 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=iEyLnsxdEbZpgMXxUMGXoRqchhpdzybvnC2uj9cSaYU=; b=GHD5kScGD0XgtkTGLQukwJUQ8qEnFw4fMEMPJ3gFLaSjOcip8KcdsrTUYCvIBED/IX Tu+bKcl9y3vzQbOY+/cRyvrm5gTSRYwTYOin2jLJTaY0LaJUIAeDcS395LbeIbLiiDwO oRmep/cWVE3p7o1cm7l3+fLdzIj795TbO5i+V7HnzTKseGLkp83Rr2Bc28TZyEL54Esd pFcGGaQgnz4SJCL8trS+YUOxfg/Ala9PFmE6ngYQqcX/n4KFfsTXZ+naA2pvXMqmqzuN l5jJTQQYfMcKK11Sljb5DkqWrqONzoRoYzonJjEyAo5yMUSpUfGijkClTmagEdJ/nmp+ oVhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lN18bBEy; 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 d9-20020a170903230900b0018532e03614si20246268plh.470.2022.10.19.04.19.10; Wed, 19 Oct 2022 04:19:23 -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=lN18bBEy; 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 S234803AbiJSLGH (ORCPT + 99 others); Wed, 19 Oct 2022 07:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231633AbiJSLFT (ORCPT ); Wed, 19 Oct 2022 07:05:19 -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 EE69D193F5; Wed, 19 Oct 2022 03:34:34 -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 C3464617F7; Wed, 19 Oct 2022 09:15:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5D59C433D6; Wed, 19 Oct 2022 09:15:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170903; bh=2ZxUg/1wAsgJI7Aj9gDfm/S13ITpUsPEtiIhR3IIIoc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lN18bBEyMhZ6OsE76f1xj8U5Gib3acWiVgu9MY4cHfT5HcmqjF2OUYYhB0axoCd/i RPrtKiCDnZJZekDOrs6gV3OzmXHQhLIKyenEpGnCmkTfRgqdgThLu08EMhwtSGnKCX XMjGkWnW1jmZji6qMupbYlI7yQqvEntqviB1jqCg= 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 6.0 831/862] usb: idmouse: fix an uninit-value in idmouse_open Date: Wed, 19 Oct 2022 10:35:18 +0200 Message-Id: <20221019083326.617645049@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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 e9437a176518..ea39243efee3 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -177,10 +177,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) @@ -192,6 +188,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); -- 2.35.1