The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net 0/2] can: bittiming: fix two defects in the userspace bitrate conversion
@ 2026-08-03  9:14 Sureshkumar S
  2026-08-03  9:14 ` [PATCH net 1/2] can: bittiming: fix divide-by-zero in can_calc_bittiming() Sureshkumar S
  2026-08-03  9:14 ` [PATCH net 2/2] can: bittiming: fix bitrate error calculation on unsigned operands Sureshkumar S
  0 siblings, 2 replies; 3+ messages in thread
From: Sureshkumar S @ 2026-08-03  9:14 UTC (permalink / raw)
  To: Marc Kleine-Budde, Vincent Mailhol
  Cc: Oliver Hartkopp, linux-can, netdev, linux-kernel, Sureshkumar S

can_calc_bittiming() converts a userspace supplied bitrate 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.

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

 drivers/net/can/dev/calc_bittiming.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)


base-commit: af39eb111ce6b5eba9c08513b62c4868eb7e7fd5
-- 
2.43.0


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

end of thread, other threads:[~2026-08-03  9:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03  9:14 [PATCH net 0/2] can: bittiming: fix two defects in the userspace bitrate conversion Sureshkumar S
2026-08-03  9:14 ` [PATCH net 1/2] can: bittiming: fix divide-by-zero in can_calc_bittiming() Sureshkumar S
2026-08-03  9:14 ` [PATCH net 2/2] can: bittiming: fix bitrate error calculation on unsigned operands Sureshkumar S

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox