[PATCH net] can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices

Jerry Wu posted 1 patch 1 month ago
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH net] can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices
Posted by Jerry Wu 1 month ago
Uninitialized Kernel memory can leak to USB devices.

Fix this by using kzalloc() instead of kmalloc().

Fixes: 7259124eac7d ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c")
Signed-off-by: Jerry Wu <w.7erry@foxmail.com>
---
Commit da2311a6385c (can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices) 
fixed a similar issue, CVE-2019-19947, in the same file. The other functions 
contain similar logic. Would it make sense to fix them in the same way?

Thank you for time reading this. My apologies if I missed anything.

 drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 1167d38344f1..b031e6e42a41 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -723,7 +723,7 @@ static int kvaser_usb_leaf_send_simple_cmd(const struct kvaser_usb *dev,
 	struct kvaser_cmd *cmd;
 	int rc;
 
-	cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
+	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
 	if (!cmd)
 		return -ENOMEM;
 
@@ -1881,7 +1881,7 @@ static int kvaser_usb_leaf_set_bittiming(const struct net_device *netdev,
 	struct kvaser_cmd *cmd;
 	int rc;
 
-	cmd = kmalloc(sizeof(*cmd), GFP_KERNEL);
+	cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
 	if (!cmd)
 		return -ENOMEM;
 
-- 
2.52.0
Re: [PATCH net] can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices
Posted by Vincent Mailhol 1 month ago
+CC: Jimmy

On 09/01/2026 at 02:36, Jerry Wu wrote:
> Uninitialized Kernel memory can leak to USB devices.

Please explain in your description which field(s) is(are) uninitialized
in cmd.

(or attach a report in which you can witness the information leak).

> Fix this by using kzalloc() instead of kmalloc().
> 
> Fixes: 7259124eac7d ("can: kvaser_usb: Split driver into kvaser_usb_core.c and kvaser_usb_leaf.c")
> Signed-off-by: Jerry Wu <w.7erry@foxmail.com>

Yours sincerely,
Vincent Mailhol
Re: [PATCH net] can: kvaser_usb: kvaser_usb_leaf: Fix some info-leaks to USB devices
Posted by Marc Kleine-Budde 1 month ago
On 09.01.2026 08:50:03, Vincent Mailhol wrote:
> +CC: Jimmy
>
> On 09/01/2026 at 02:36, Jerry Wu wrote:
> > Uninitialized Kernel memory can leak to USB devices.
>
> Please explain in your description which field(s) is(are) uninitialized
> in cmd.

Some memory at the end of struct kvaser_cmd is uninitialized, but
usb_bulk_msg() doesn't send the whole struct.

regards,
Marc

P.S.: It may be a coincidence, but Kery Qi's patch [1] had a similar
form. You take the bug class of an existing CVE and search for the same
pattern in other drivers. I like the idea. Please take a little more
time and check whether it really is a bug before sending bug fix
patches. Otherwise please label the patches accordingly.

[1] https://lore.kernel.org/all/20260108082042.1627-1-qikeyu2017@gmail.com/

-- 
Pengutronix e.K.                 | Marc Kleine-Budde          |
Embedded Linux                   | https://www.pengutronix.de |
Vertretung Nürnberg              | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-9   |