* [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures
@ 2025-09-18 13:23 Stéphane Grosjean
2025-09-19 17:18 ` Marc Kleine-Budde
0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Grosjean @ 2025-09-18 13:23 UTC (permalink / raw)
To: linux-can Mailing List; +Cc: Stéphane Grosjean
From: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
Explicitly uses a 64-bit constant when the number of bits used for its
shifting is 32 (which is the case for PC CAN FD interfaces supported by
this driver).
Signed-off-by: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
---
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 3 ++-
1 file changed, 2 insertions(+), 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 5a207c96383f..3fb9bd729959 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c
@@ -111,7 +111,8 @@ void peak_usb_update_ts_now(struct peak_time_ref *time_ref, u32 ts_now)
u64 delta_ts = time_ref->ts_dev_2 - time_ref->ts_dev_1;
if (time_ref->ts_dev_2 < time_ref->ts_dev_1)
- delta_ts &= (1UL << time_ref->adapter->ts_used_bits) - 1;
+ delta_ts &=
+ (1ULL << time_ref->adapter->ts_used_bits) - 1;
time_ref->ts_total += delta_ts;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures
2025-09-18 13:23 [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures Stéphane Grosjean
@ 2025-09-19 17:18 ` Marc Kleine-Budde
2025-09-26 7:26 ` stephane.grosjean
0 siblings, 1 reply; 3+ messages in thread
From: Marc Kleine-Budde @ 2025-09-19 17:18 UTC (permalink / raw)
To: Stéphane Grosjean; +Cc: linux-can Mailing List, Stéphane Grosjean
[-- Attachment #1: Type: text/plain, Size: 853 bytes --]
On 18.09.2025 15:23:57, Stéphane Grosjean wrote:
> From: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
>
> Explicitly uses a 64-bit constant when the number of bits used for its
> shifting is 32 (which is the case for PC CAN FD interfaces supported by
> this driver).
>
> Signed-off-by: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
This problem is not limited to 32-bit architectures, so I've removed
this from the subject.
I don't know why, but the patch didn't apply to net/main, applied
manually, but removed the line break.
Thanks,
Marc
--
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 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures
2025-09-19 17:18 ` Marc Kleine-Budde
@ 2025-09-26 7:26 ` stephane.grosjean
0 siblings, 0 replies; 3+ messages in thread
From: stephane.grosjean @ 2025-09-26 7:26 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: linux-can Mailing List, Stéphane Grosjean
Hello Marc,
The reason is that delta_ts is still declared u32.
The problem came from my patch, where it was already declared as u64.
Sorry for that. I push a v2 asap.
----- Mail original -----
De: "Marc Kleine-Budde" <mkl@pengutronix.de>
À: "Stéphane Grosjean" <stephane.grosjean@free.fr>
Cc: "linux-can Mailing List" <linux-can@vger.kernel.org>, "Stéphane Grosjean" <stephane.grosjean@hms-networks.com>
Envoyé: Vendredi 19 Septembre 2025 19:18:15
Objet: Re: [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures
On 18.09.2025 15:23:57, Stéphane Grosjean wrote:
> From: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
>
> Explicitly uses a 64-bit constant when the number of bits used for its
> shifting is 32 (which is the case for PC CAN FD interfaces supported by
> this driver).
>
> Signed-off-by: Stéphane Grosjean <stephane.grosjean@hms-networks.com>
This problem is not limited to 32-bit architectures, so I've removed
this from the subject.
I don't know why, but the patch didn't apply to net/main, applied
manually, but removed the line break.
Thanks,
Marc
--
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 |
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-26 7:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 13:23 [PATCH] can: peak_usb: fix shift-out-of-bounds issue for 32-bit architectures Stéphane Grosjean
2025-09-19 17:18 ` Marc Kleine-Budde
2025-09-26 7:26 ` stephane.grosjean
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).