Netdev List
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org,
	kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>,
	stable@vger.kernel.org
Subject: [PATCH net 11/12] can: gs_usb: gs_can_start_xmit(): don't leak uninitialized memory over USB
Date: Tue, 24 Nov 2026 09:51:38 +0100	[thread overview]
Message-ID: <20261124085757.1093632-12-mkl@pengutronix.de> (raw)
In-Reply-To: <20261124085757.1093632-1-mkl@pengutronix.de>

The driver allocates the transmission buffer using kmalloc(), which means
the memory remains uninitialized. Then various headers are filled and, but
only the actual CAN frame data payload (of length cfd->len or cf->len) is
copied into the buffer, leaving the remaining buffer uninitialized.

Fix this information leak, allocate the buffer with kzalloc().

Closes: https://sashiko.dev/#/bug/linux-0a8c0e8a-c623-426a-8db3-f55111f6cd84
Fixes: d08e973a77d1 ("can: gs_usb: Added support for the GS_USB CAN devices")
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/usb/gs_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 3b9b2f104d86..15f28833f2de 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -861,7 +861,7 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
 	if (!urb)
 		goto nomem_urb;
 
-	hf = kmalloc(dev->hf_size_tx, GFP_ATOMIC);
+	hf = kzalloc(dev->hf_size_tx, GFP_ATOMIC);
 	if (!hf)
 		goto nomem_hf;
 
-- 
2.53.0


  parent reply	other threads:[~2026-11-24  8:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  8:51 [PATCH net 0/12] pull-request: can 2026-11-24 Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 01/12] can: bcm: copy the CAN frames outside of lock_sock() Marc Kleine-Budde
2026-11-24  9:04   ` netdev-bot+sinfo
2026-11-24  8:51 ` [PATCH net 02/12] can: bcm: do not remove the procfs entry in bcm_notify() Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 03/12] can: raw: use a private mutex instead of lock_sock() Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 04/12] can: isotp: " Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 05/12] can: bcm: " Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 06/12] can: isotp: always start the rx timeout in ISOTP_WAIT_DATA state Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 07/12] can: isotp: reject socket options while a transfer is active Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 08/12] can: netlink: fix static FD-NON-ISO mode validation Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 09/12] can: netlink: fix IFLA_CAN_BITRATE_MAX attribute sizing Marc Kleine-Budde
2026-11-24  8:51 ` [PATCH net 10/12] can: netlink: fix CAN XL PWM " Marc Kleine-Budde
2026-11-24  8:51 ` Marc Kleine-Budde [this message]
2026-11-24  8:51 ` [PATCH net 12/12] can: flexcan: Fix probing for m68k/coldfire Marc Kleine-Budde

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=20261124085757.1093632-12-mkl@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=kernel@pengutronix.de \
    --cc=kuba@kernel.org \
    --cc=linux-can@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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