From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Dongliang Mu <mudongliangabcd@gmail.com>,
syzbot+79832d33eb89fb3cd092@syzkaller.appspotmail.com,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Sasha Levin <sashal@kernel.org>,
linux-usb@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 17/19] usb: idmouse: fix an uninit-value in idmouse_open
Date: Wed, 12 Oct 2022 20:26:16 -0400 [thread overview]
Message-ID: <20221013002623.1895576-17-sashal@kernel.org> (raw)
In-Reply-To: <20221013002623.1895576-1-sashal@kernel.org>
From: Dongliang Mu <mudongliangabcd@gmail.com>
[ 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 <mudongliangabcd@gmail.com>
Link: https://lore.kernel.org/r/20220922134847.1101921-1-dzm91@hust.edu.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
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);
--
2.35.1
next prev parent reply other threads:[~2022-10-13 0:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-13 0:26 [PATCH AUTOSEL 4.19 01/19] media: cx88: Fix a null-ptr-deref bug in buffer_prepare() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 02/19] scsi: 3w-9xxx: Avoid disabling device if failing to enable it Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 03/19] nbd: Fix hung when signal interrupts nbd_start_device_ioctl() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 04/19] power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 05/19] staging: vt6655: fix potential memory leak Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 06/19] ata: libahci_platform: Sanity check the DT child nodes number Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 07/19] hid: topre: Add driver fixing report descriptor Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 08/19] HID: roccat: Fix use-after-free in roccat_read() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 09/19] HSI: ssi_protocol: fix potential resource leak in ssip_pn_open() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 10/19] md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 11/19] usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info() Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 12/19] usb: musb: Fix musb_gadget.c rxstate overflow bug Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 13/19] Revert "usb: storage: Add quirk for Samsung Fit flash" Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 14/19] staging: rtl8192u: Fix return type of ieee80211_xmit Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 15/19] staging: octeon: Fix return type of cvm_oct_xmit and cvm_oct_xmit_pow Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 16/19] nvme: copy firmware_rev on each init Sasha Levin
2022-10-13 0:26 ` Sasha Levin [this message]
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 18/19] fsi: master-ast-cf: Fix missing of_node_put in fsi_master_acf_probe Sasha Levin
2022-10-13 0:26 ` [PATCH AUTOSEL 4.19 19/19] clk: bcm2835: Make peripheral PLLC critical Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221013002623.1895576-17-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mudongliangabcd@gmail.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+79832d33eb89fb3cd092@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox