From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796253042; b=xcqrdyiRpgVtoyzKDdEVO+rSpDJl+TcO2vQiCA8EaxMN3r0yCRad4D3DfX3uh1da4OYG 6xHuinSuIRl4DKVDPhQI0ndbJp1Ul0hIG8Q6RQqZeyDOmfMdobh2ksT0PeRDi59vbhvLQ F25E9QkQPAWK1weYqbQP/FdHX9JTJTELERUp/7c3NwOBFFIpt0IlSY7XjVBZKLOoWxdCH VKk0FSI7qn0UxNuwUvqY0wU9ywQ3E/W8IjNONSvG0EPWYxhijEfL4YG8IrYzD1svPWGFa 3yRf28j/3VsfYp9WjWiHB0DMvs9TM4Ei2aYhxrJ47Rtj+ssQhEu/GP8Fqw9mnzvmj9Q== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796253042; 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=zkvBB19Zh8G/wQzEIBJzTkreOef+c8fBviZIE+otQms=; b=jB5c/YV7w2STkF20yCjMUs3R7+a8ZASE/Vft3afNMQlDRkNGzz7GCzouASu0G1INYjEH GCJUdWQo6kRb5bniirJe3rUh1cYKbnKfw+tyIUhYHzku9k6WE1FJj5ykkFloygroAdX0W 1v+WJateXW2802BmJXgFCvwN8Av7eu/RuB86tx4vuPn47bA7bhCULYEBx/6g+hXmLXlED ke2hOAAZ9pQIOwVVJ3Uu6f4tA30fvnjtWFGd6A8VWMvzoZ3U6aqgYZI/mptrFwYRQzG0S AGhnA3MhrBSvF6GT2NemOQeLwpBxqgnj9oe5RE24sBT8ktZauuK1J59UGYhvJ9sDaZQ== 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=chVSUJbk; arc=pass header.oldest-pass=0 smtp.remote-ip=185.203.200.13 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 98FBD606A330; Wed, 2 Dec 2026 23:10:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98FBD606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de 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=chVSUJbk 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 AFEC3201923; Thu, 03 Dec 2026 00:10:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253035; 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=zkvBB19Zh8G/wQzEIBJzTkreOef+c8fBviZIE+otQms=; b=chVSUJbkzuNBAlegFfFhEa5nkUkbCRc/QGaxBENjsQLKCU5JkhZIf0R+tKfB9Yxr+7/ata xssaxBOPoHdLQQF0XKtFw+AYamSmpfag4jxIqkVgJkIPaok2dNEO29+NWiWhBIos4tgUjP z8oWzxdpz+aOSZdRfl16AJ78iD7yodfwEzuckHcIYUek5L7Qysk214kOMCGwVjhEE3E2Bd 6Itys+AuPg3W52yJmD3l+F1pCLPYaA0hpNNvEZNnyTIElnB0cNQV/RzsD1QFBRI20oftbO DTt1QJRgZM3ve30ULwNoQO4tX5/5ui8Q7Ed63nA5gBSVE5cmxMl8O2H2/BYt4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=pengutronix.de; s=20260414; t=1796253035; 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=zkvBB19Zh8G/wQzEIBJzTkreOef+c8fBviZIE+otQms=; b=YJ/jblDmuxJG6eZOPslo3dCB0W9SzSdBw07S7rT+gR+OWHC/3okRjhKCNh0mt9Y63vlNwI H9p6VBT/oT6IB3PXKWMqRqLp5bqziGF2VnpIuIRRt1a7jaTqnvESP4pBoGC7nPN8PlbLnm 2rZAsEstvMOMlXRtw5o4bMpAtZYHr/Nag3lPpKFsZat80/toy33guisQ6GlsfXVDsztAP6 apFau6wP0De/yZO+TSfHq4patSmsyrNeW75YWWD5sf99NleDEaYyS9w3ORy8HXchUG5IL/ XdlaLMulIph5E8Wvl/heArXHjtVUGGYZQaqTADkoVI97ZRRzBlTEnqytqGfWHw== ARC-Seal: i=1; s=20260414; d=pengutronix.de; t=1796253035; a=rsa-sha256; cv=none; b=fHFiWaoGkZvrxP+FE/dzAY5Y8jwMM0a2XwHnYqQyf+0posL95xbqSrij3EKKYPQZsk1cWC +yOvjlvrK9l4knsKPXOm/MJAxA7f/NjFTlwDirA3Ok+JZGuhK56b7nW+mT8a/KHl+gbMX5 pwl0DW/aWqVQcaafSw3rZtSFemXLSZuWKd0tEZ92JJ+kZ84CSHDY0VkhCx+t8FEn95jeHU 0P+cgJQf+7lhxxOY3waGiHVm1CrpTIis23eZmS5SCIVQNbaQ3NVC1lIsnGyQKJSEOs6nKb a4uu7pa5VZlcZqpfDhr5Wn7HsNFuENd8xZIsoHNypEpS06l7JDfb9OfzJ8E8Xg== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=mkl@pengutronix.de smtp.mailfrom=mkl@pengutronix.de From: Marc Kleine-Budde To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, linux-can@vger.kernel.org, kernel@pengutronix.de, =?UTF-8?q?St=C3=A9phane=20Grosjean?= , stable@vger.kernel.org, Marc Kleine-Budde Subject: [PATCH net-next 22/23] can: peak_usb: don't send uninitialized stack bytes to PCAN-USB devices Date: Thu, 3 Dec 2026 00:04:47 +0100 Message-ID: <20261202230853.2665144-23-mkl@pengutronix.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202230853.2665144-1-mkl@pengutronix.de> References: <20261202230853.2665144-1-mkl@pengutronix.de> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Stéphane Grosjean pcan_usb_send_cmd() copies the PCAN_USB_CMD_ARGS_LEN (14) bytes of the args[] array of its caller into the command buffer, and sends the whole command to the device. pcan_usb_set_bittiming() only sets the first two bytes of its args[] array, and pcan_usb_set_can_channel_id() only the first one. The other 12 or 13 bytes of these uninitialized stack arrays are thus sent to the device each time the bitrate or the CAN channel ID is set. Zero-initialize both arrays, as the other setters of the driver do. Found by Sashiko AI review. Fixes: 46be265d3388 ("can: usb: PEAK-System Technik PCAN-USB specific part") Fixes: e7a7b3d22503 ("can: peak_usb: allow flashing of the CAN channel ID") Cc: stable@vger.kernel.org Signed-off-by: Stéphane Grosjean Link: https://patch.msgid.link/20261126-canfd_check_channel_idx-v9-13-abe0099b4585@peak-system.fr Signed-off-by: Marc Kleine-Budde --- drivers/net/can/usb/peak_usb/pcan_usb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c index 83cf6fe7d258..2838e4ea2b4e 100644 --- a/drivers/net/can/usb/peak_usb/pcan_usb.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb.c @@ -274,7 +274,7 @@ static int pcan_usb_set_led(struct peak_usb_device *dev, u8 onoff) static int pcan_usb_set_bittiming(struct peak_usb_device *dev, struct can_bittiming *bt) { - u8 args[PCAN_USB_CMD_ARGS_LEN]; + u8 args[PCAN_USB_CMD_ARGS_LEN] = {}; u8 btr0, btr1; btr0 = ((bt->brp - 1) & 0x3f) | (((bt->sjw - 1) & 0x3) << 6); @@ -405,7 +405,7 @@ static int pcan_usb_get_can_channel_id(struct peak_usb_device *dev, u32 *can_ch_ /* set a new CAN channel id in the flash memory of the device */ static int pcan_usb_set_can_channel_id(struct peak_usb_device *dev, u32 can_ch_id) { - u8 args[PCAN_USB_CMD_ARGS_LEN]; + u8 args[PCAN_USB_CMD_ARGS_LEN] = {}; /* this kind of device supports 8-bit values only */ if (can_ch_id > U8_MAX) -- 2.53.0