All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH can-next v2 0/4] can: bittiming: fix defects in the userspace bit rate conversion and reject invalid timing constants
@ 2026-11-30 11:13 Marc Kleine-Budde
  2026-11-30 11:13 ` [PATCH can-next v2 1/4] can: bittiming: fix divide-by-zero in can_calc_bittiming() Marc Kleine-Budde
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Marc Kleine-Budde @ 2026-11-30 11:13 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol, Oliver Hartkopp,
	Wolfgang Grandegger, David S. Miller
  Cc: kernel, linux-can, Sureshkumar S, YuanZhe Liu, stable, Bin Yu,
	Cheng Wen

This series combines all bit timing relates fixes into one series.
Patch #1 and #2 are by Sureshkumar S, they say:

can_calc_bittiming() converts a userspace supplied bit rate into hardware
timing parameters. Two defects in that conversion are fixed here, both
reachable through IFLA_CAN_BITTIMING on any CAN device that provides a
bittiming_const, and both caused by 32 bit arithmetic on a value that
userspace fully controls.

Patch #1 fixes a divide-by-zero. The 32 bit tsegall * bt->bitrate product
wraps to zero for bitrates carrying enough factors of two, and the
following division faults. A bitrate of 16777216 is already enough, which
is below the 20 Mbit/s CAN XL data bitrate ceiling.

Patch #2 fixes the candidate rating, which applies abs() to an unsigned
subtraction. A wrapped difference is read back as a small error, so a
bitrate far outside what the controller can reach passes the 5% gate and is
silently accepted instead of rejected.

Both were found with a netlink fuzzer against dummy_can and verified under
KASAN in QEMU. Testing covered the unpatched tree, patch #1 alone and the
full series: bitrates from 125 kbit/s to 10 Mbit/s produce byte-identical
bittiming at every step, patch #1 alone removes the oops, and patch #2 turns
the silently accepted out-of-range bitrates into -EINVAL.

In addition to Sureshkumar S's patches fix another abs() on an unsigned
subtraction in patch #3,

YuanZhe Liu's patch #4 rejects unusable bit timing constants.

---
Marc Kleine-Budde (1):
      can: bittiming: can_update_sample_point(): fix sample point error calculation on unsigned operands

Sureshkumar S (2):
      can: bittiming: fix divide-by-zero in can_calc_bittiming()
      can: bittiming: fix bitrate error calculation on unsigned operands

YuanZhe Liu (1):
      can: dev: reject unusable bit-timing constants

 drivers/net/can/dev/calc_bittiming.c | 12 ++++--
 drivers/net/can/dev/dev.c            | 75 ++++++++++++++++++++++++++++++++++--
 2 files changed, 79 insertions(+), 8 deletions(-)
---
base-commit: 81159a672c331993566a12ad8e07532b38355cba
base-tree: git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can-next.git master
change-id: 20261021-bittiming-fix-conversion-24a033ebf153

Best regards,
--  
Marc Kleine-Budde <mkl@pengutronix.de>


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-12-02  1:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-30 11:13 [PATCH can-next v2 0/4] can: bittiming: fix defects in the userspace bit rate conversion and reject invalid timing constants Marc Kleine-Budde
2026-11-30 11:13 ` [PATCH can-next v2 1/4] can: bittiming: fix divide-by-zero in can_calc_bittiming() Marc Kleine-Budde
2026-12-02  1:07   ` netdev-bot+sashiko
2026-11-30 11:13 ` [PATCH can-next v2 2/4] can: bittiming: fix bitrate error calculation on unsigned operands Marc Kleine-Budde
2026-11-30 11:13 ` [PATCH can-next v2 3/4] can: bittiming: can_update_sample_point(): fix sample point " Marc Kleine-Budde
2026-12-02  1:07   ` netdev-bot+sashiko
2026-11-30 11:13 ` [PATCH can-next v2 4/4] can: dev: reject unusable bit-timing constants Marc Kleine-Budde
2026-11-30 11:25   ` sashiko-bot
2026-11-30 13:07     ` Marc Kleine-Budde
2026-12-02  1:07   ` netdev-bot+sashiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.