Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7316493rwi; Mon, 24 Oct 2022 12:51:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4iDTYBZBPWSfIaCRQCpZ8y+3U8Rf9eCfG2QL8rI8mg2QZv68OCwlwZLOheLijGN4aiOuIK X-Received: by 2002:a05:6402:90a:b0:458:ca4d:a2f8 with SMTP id g10-20020a056402090a00b00458ca4da2f8mr32389829edz.230.1666641089325; Mon, 24 Oct 2022 12:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666641089; cv=none; d=google.com; s=arc-20160816; b=OdRStNhumUzLqX7U6ua345G68rr7bO1w6AnXz+CgvA+bnPeJYdY7aGVSABxllVHI0y H3jcV8mpmggywKowIP+bxJ5DVQKsjp0q6HRqm69G0ARMM85QFd4/sG2kjtouf+FH8dhl tsIWUclRjbv5/45BubSUQFr9bKGRJwx7GL6TkhL1ZFmv/Z2xO6EHIy6tO92LVXF2eicR qlNF5R/XAdEj2mnV6Q4le05+dEzoiKKE3satw5CbFnN/wp9XzVDSZjqkvLQYuBQVyfEC 02mC9MQOHeB3u3B5psSR/Gk9RgvM20s7Cu5mDr2QcubUL+rY65ErbUQ1PcwPFhV+wPkI OdCg== 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=BgfPyLw0rwt3niYBWySnfEzNF0mBkxpFXerjbmNSzX8=; b=dSA/pQQDhn5Vu26oioL/7/+zl2WcE7gSow+PHkQUbq7Z/BlHc6yAOB01Ih/CvNzg+3 twdUnl38Rc6+iAo0qojvxuee7zpMJyLa6/ikdQjlm2kVEiJCr2Vn7ix+W4uHSDB+yM5o pc5m8Q29/G+87WsyACpMIeEujOLcJ+IE3wTOAhm8NE6fsyOpx2NR4Y9/pd5e+XZaZHPB BcGJEFr97FBtc7Th3Wz+OQ+riFXEYPbXQEvERBSJCb+JoqLYUYNTZzXWizPelGpDbaWi hoQT+qpjpSqSyRrNzkefLn2n5p9qrdxOOvStXfhE7U2coNDksEe68QpVSwBEBZQ6Oo9x 4Mhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Eaz/YkH8"; 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 dm5-20020a170907948500b00791a5f0b140si502995ejc.993.2022.10.24.12.51.03; Mon, 24 Oct 2022 12:51:29 -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="Eaz/YkH8"; 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 S232156AbiJXTot (ORCPT + 99 others); Mon, 24 Oct 2022 15:44:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbiJXTmO (ORCPT ); Mon, 24 Oct 2022 15:42:14 -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 50CFE22BEF; Mon, 24 Oct 2022 11:11:48 -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 08CF3B811C6; Mon, 24 Oct 2022 11:54:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 670BDC433C1; Mon, 24 Oct 2022 11:54:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612475; bh=GlxaIfTe2cbL0wzvJCYu/yb+Dzwdt/fPXLrbYdgTPUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Eaz/YkH8iKBdC8/i4WLn91OxuJENa3snRYbqMoYEgI/6NLd83/YZzwYRUsAJvJhBN VnqlJ5/UR8zbadSydS1yyhKqjAvIMtuzWpk/qHsFcETkKe1NE78ScXZB7Y0h3/RTp3 QxJLs+qa6xLqN/bMVwtLPbETg3Be020ot6vGHu9g= 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.14 202/210] usb: idmouse: fix an uninit-value in idmouse_open Date: Mon, 24 Oct 2022 13:31:59 +0200 Message-Id: <20221024113003.534804391@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@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.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 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 01ef2551be46..974b8d0621bd 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -182,10 +182,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) @@ -197,6 +193,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