Article View: linux.kernel.netdev
Article #26027[PATCH net-next 23/23] can: peak_usb: don't send uninitialized heap bytes in restart commands
From: Marc Kleine-Budde
Date: Wed, 02 Dec 2026 23:04
Date: Wed, 02 Dec 2026 23:04
49 lines
12043 bytes
12043 bytes
From: Stéphane Grosjean <s.grosjean@peak-system.fr>
peak_usb_restart() allocates the buffer of the asynchronous restart
command with kmalloc(), and lets the dev_restart_async() callback of
the adapter build the command in it. None of these callbacks fills the
whole part of the buffer that it sends to the device:
- pcan_usb_restart_async() sets 3 of the PCAN_USB_CMD_LEN (16) bytes
that it sends;
- pcan_usb_pro_restart_async() builds an 8-byte message, but sends the
whole PCAN_USB_MAX_CMD_LEN (32) bytes buffer;
- pcan_usb_fd_build_restart_cmd() leaves the unused field of
struct pucan_wr_err_cnt and the args of the final struct
pucan_command unset.
Uninitialized heap bytes are thus sent to the device each time a
channel is restarted after bus off.
Allocate the buffer with kzalloc(), so that the unset bytes are zero,
as for the other command buffers of the driver.
Found while checking the other adapters for the uninitialized command
bytes reported by Sashiko AI review.
Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core")
Cc: stable@vger.kernel.org
Signed-off-by: Stéphane Grosjean <s.grosjean@peak-system.fr>
Link: https://patch.msgid.link/20261126-canfd_check_channel_idx-v9-14-abe0099b4585@peak-system.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_core.c b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
index 1d306160fa35..95c1454b4116 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -702,7 +702,7 @@ static int peak_usb_restart(struct peak_usb_device *dev)
return -ENOMEM;
/* also allocate enough space for the commands to send */
- buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC);
+ buf = kzalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC);
if (!buf) {
usb_free_urb(urb);
return -ENOMEM;
--
2.53.0
Technical Details
Message-ID:
<20261202230853.2665144-24-mkl@pengutronix.de>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376123-linux-kernel-netdev=dewy.ruReferences:
<20261202230853.2665144-1-mkl@pengutronix.de>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376123-linux-kernel-netdev=dewy.ru From: mkl@pengutronix.de (Marc Kleine-Budde) Newsgroups: linux.kernel.netdev Subject: [PATCH net-next 23/23] can: peak_usb: don't send uninitialized heap bytes in restart commands Date: Thu, 3 Dec 2026 00:04:48 +0100 Organization: Usenet Network Message-ID: <20261202230853.2665144-24-mkl@pengutronix.de> References: <20261202230853.2665144-1-mkl@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2085296"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:HwvgxZ1sToLLoKk07gf7A5G5Kmc= sha256:9S5ISDjIOqMG/yTf3bqgMcBbjFpRwWqlo9LSvyPVBMU= sha1:IPguoD0sGy+vq7ZMYNjOPCKD5v0= sha256:eg4C8JA+MVJenoFJ178oI019rgzzUw1vgw3VgcWoDvI= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id B952B117792; Thu, 3 Dec 2026 02:11:12 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.05 X-Spam-Status: No, score=-3.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=pengutronix.de X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M38uguro-oW2; Thu, 3 Dec 2026 02:11:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376123-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 04D4E117779; Thu, 3 Dec 2026 02:11:01 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 19C322A869; Wed, 2 Dec 2026 23:10:58 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796253058; b=L8vYzNvKs5WyXjLagK+ScZUPybQYKmbJL59YJk4IqPL0WMywY6LRuKG+CrwKrIJhyNPb MJbE6TREGLZ4tMA2cL379oRV/84lHZ3mc247QhK2iWiF8vVYnXOXmw0uBEjxep98iAXvh Uk4QdGoy+1n7eY1yRgmMkZU6Xz7u4ucodsVVdej5L0STlQu9ndBwabJV51nhrMB8eY7Sz C1joOinFhwlb+ahI6adI7cdFp/VrVfrZV7sqxtwUlnOw+/t+uhg7ecbvnok2PQ9DG1chM YIMjvsSZb6l2AmGSEo+/X1HwM2S3LeAkXvgbsDdeES6wERVgrPJkJxjkUJMxT3YaBfQ== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253058; h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:From:To: Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=futgvh6u2+uKJAs0p8onSuhy5+8wSEjMriXQ7BSyJ70=; b=afRtueFRth760XSvFKk5WsMxzaGbe8xyVlOc6ppRZAAhP9qKv1bCalyUm83ZO59DBO4F 57Sx1JkrCHyrdjsfSK7uBLXHvCy3T3BlstOeYmDn3uPiaLOmGKc8cIadSJ5L9s7IGjgqO dXkl3IdJnFTo6e7nOJIKNp1adiUwgfEeIKYtQd2JrlkA+SF4c3xgd85pBXziV+D0POIpr NRuxlYrQPkr4I080nTB8SvgRh2NQXH+5nvNSY1xiMobJFUXuZVaH0w1DdjUbkFU3p4HER Mxnj5st/AayjdiodbubtZim2x6ckqa8QqUYfKmnfxI8nnyYSKxoxnrTo8VAQQHUBwOw== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=gRBGx7Sy; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E5976606A335; Wed, 2 Dec 2026 23:10:57 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=gRBGx7Sy X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796253047; b=EHQPisvuWD89XvGJxUJ4rdS2QaZA3P2y1qitBOk9mH6PdIBh063JspCDz9XG330MwUK0 Ua5b3ulAa2z8ubWesO9FFhTtSj3BkOq9pvBu5tHjg6pfr7jnamTYoX6YF0MsJmpZuJ0K3 PdQ0ruHQ6Eh4cRLi+QWUc9aPzJNJsQhlLsmx5OsFv6uzxfObtYZC2+h799w5L0AxBMkBo aJ09iYeF8dUGTCXwhfMxj9lWaZVzHR/nMOGT1HoILYb5wJ+0cG79z1dsVpJCH/rV8a37z QSnj7ODFBd36U4vcz4/0zmZ537gYDOjGf1FFfk19o82ujcdytSg/Lv5+8PWc3UiFPng== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253047; h=DMARC-Filter:Received:DKIM-Signature:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=futgvh6u2+uKJAs0p8onSuhy5+8wSEjMriXQ7BSyJ70=; b=1PNVKqNL5qxQixFH8ZK8ayZhXCSUn1COAzw2ms2s8860993Tup37TkWKQK6OcZn8qBM0 Dn3g1BjKsGviS2+69kSIy722fUSVQc7m0Pmj4SfGFld4LvAE7UNuFkXLT52a52putakU9 AkdTutmWdNblox2bX+d+XXMsJj8F8MdTLISZKM8i7hHeu1qAcVwNycCDmsFj0RbhV4mBN DXhbkUKJ50hgjfu0f9Rs/tbgHvrrCAzhtaoHOL4+WzgR2bNOLCova3dmHBVER4u86WWmT UWZ/qrmGziiwtcQ715Wjz8OdmUUL1bl1EJWMUIggxT4eVtrsmq0AxroNm3MmKOeIgRA== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; dkim=pass header.d=pengutronix.de header.i=@pengutronix.de header.a=rsa-sha256 header.s=20260414 header.b=gRBGx7Sy; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 X-Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D86D8606A32C; Wed, 2 Dec 2026 23:10:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D86D8606A32C X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de X-Received: from pengutronix.de (unknown [IPv6:2a0e:1580:1000::2dff:fe0e:e982]) (Authenticated sender: mkl@pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id 11DC3205BCC; Thu, 03 Dec 2026 00:10:40 +0100 (CET) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=futgvh6u2+uKJAs0p8onSuhy5+8wSEjMriXQ7BSyJ70=; b=gRBGx7SyYHwOs4AmWAZ62vYHo0j6o5VOccn23nhF9bDYUM3LMyAer8VVEJShSVtGX5bS+L PxZcIAEOJhB7MJQ4Gy9aImtv25e8L9uVZVTyTNN143G9ESQK4hmSqx5dLWOdlHklCp7qrb lrDHKrdJJbftGh41uhD/Y55A5+uuDT7rFH1iS2RzH6gRjYb3322htyUqlRiY/v6noj47sY YCB8N28HOyqY0omAiVQsHid+GGg02uyC665y5hHFo4L2ld2esGiBFdtH2AwEWPHXp495Dv NTJCP2dOlTtJe/GOqAMgHiBhPVvOA0S6OOhFvo9ePyK9Sv7YbvpfNC4cLHHXGQ== X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253040; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=futgvh6u2+uKJAs0p8onSuhy5+8wSEjMriXQ7BSyJ70=; b=VgWYsMRugUfr0+ewfPQapvOR9npCZX3GO+4596/+/MH38I7NpbI8jPzD7w5mS4jY1CrcXw DwLwWgFPyfrvxqodrwAfsOQVSrB++fdrq6wsOTEvVwgVdL6NN9ZK+MdEXY8Mtbl81Bmuj0 +bHmGP7F/qUQkkPq0QCs9YMnimwCltGUm2P/baryMjeKTsl/wHMDd2QMuhVVGx3mJuDCfg Mr9dhZBd+Zzy0+3GS5SxWvJ0J2Rbf/6/stCxh/AZ9RpIB1Yk35wNLnfAtQ0bX+yLAsntN6 1M/rhm51P75HvLjoataZeoQxJPP+Pjjzv5tB1B/tunRCUKBXj1070HpMZgTGRg== X-ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796253040; a=rsa-sha256; cv=none; b=BIMqYDw8L0CxC4l33/1kK5H5VaetSD9cepq9mN7RRZvQ4p5DnSLIOeqPv2OqthVcygNWw9 kTc5Cia4tARkgHYPLKnp1PqrhnBBzQ96XFi8qi3sOL7XuihaGihmvkQ4F33JB5NcHmmxUM pk6Rxb/QOBEx0Um/GhI6T2YRDzJ8xdY9CgX+Xm1v/1aN0UVjZiqcQ0TukcZFbu4At4jnNj VyEnhOUtO9rsCewsLFqcOZ+wryNHpVbE1ZaBsErc+w5zM3TOfDFJXgmuC5sdAhbQWHsaLw LYsrw7m/mkaM+0prRbGwqprLM+kOaHok8ikDQK15LQuMCIGUanWnY/emEM5PZw== X-ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=mkl@pengutronix.de smtp.mailfrom=mkl@pengutronix.de X-Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, Stéphane Grosjean <s.grosjean@peak-system.fr>, stable@vger.kernel.org, Marc Kleine-Budde <mkl@pengutronix.de> X-Mailer: git-send-email 2.53.0 X-In-Reply-To: <20261202230853.2665144-1-mkl@pengutronix.de> X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list