Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6824571rwi; Mon, 24 Oct 2022 06:36:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4S1l/NXqBN8ml7VBRujt3ii5t2fvgPnETQimtktX6wk1WRZko+qEUqcWyh/GEZicl/cMQ3 X-Received: by 2002:a05:6402:33c5:b0:447:e4a3:c930 with SMTP id a5-20020a05640233c500b00447e4a3c930mr30607071edc.401.1666618569268; Mon, 24 Oct 2022 06:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618569; cv=none; d=google.com; s=arc-20160816; b=NnI1KuYYKUEM/7fmGu+9XAnBmbvpazFhCmwuqFNqCPY6NMbfS8RBR0M9BElmtugpMc 2yM5+MB7mSkchvGvSAwbU8IDse2CssqA0wOZsIWjVHZHZBN12jfEZw541wyoXAcjtAKr cn0WX8k1+sRP+52PburcQ1zj8aVSoCj2g7xUGI91adnjrHkBQ7IllQKScHAn/Tj27+x7 DboBXJlEDRXuNbIoScTjEVD//Y1aZYWVTkvBBCm+NsCYcF45tQ9Dkb/3DJ3wCcMqTK/k zrtBniAUFGC3XgszIV9nmmW6xHhhifS91sX2qb67oo+y9NjllLFJ0QjacahNjXFWg97j Bm8A== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp21-20020a170906c15500b0078df1c345dcsi34222474ejc.535.2022.10.24.06.35.27; Mon, 24 Oct 2022 06:36:09 -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 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 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); -- 2.35.1