Re: [syzbot] Re: [syzbot] [usb?] KMSAN: kernel-usb-infoleak in usbtmc_write

From: syzbot
Date: Thu Sep 05 2024 - 03:11:21 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [usb?] KMSAN: kernel-usb-infoleak in usbtmc_write
Author: lizhi.xu@xxxxxxxxxxxxx

Short write.
User input data maybe invalid, clear the data buf of the user data before copying from user.

#syz test

diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c
index e9ddaa9b580d..b653bed40a13 100644
--- a/drivers/usb/class/usbtmc.c
+++ b/drivers/usb/class/usbtmc.c
@@ -1586,6 +1586,7 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
aligned = (transfersize + (USBTMC_HEADER_SIZE + 3)) & ~3;
}

+ memset(&buffer[USBTMC_HEADER_SIZE], 0, transfersize);
if (copy_from_user(&buffer[USBTMC_HEADER_SIZE], buf, transfersize)) {
retval = -EFAULT;
up(&file_data->limit_write_sem);