From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796177279; b=QWl1q+BJTB/gP85LGoXtYX4R2TLD3FFPWUOphJjt26LvJ7SC6IRKq01RtePTolL1d5zH rujfieiTP//zL9UHvv3Lcz3ZSSvdi0vnNwTCGzbEDPz5VKf+Uc7fqKXPhL3Th0k+YGQ+3 s76QePrClwB+L/E9hMzW1b07cZt7JUM7Y3IfcrwC5X0llFAVpy/69TKetbpm8iTFiz84O uujRUwqnDFZl3MIbjsmPw5A3IKI/QkXA4/Di4fJDo9Iwm+bEs15WCt5yxji/YKMzyk8k0 JcssUOUlxiVDixS3pupG6/X7ed4aBQtmqBa+jKJ6IiNI00otajWSFZqjem7NPTOUF3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796177279; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=XFdF8y/advec6x3k3ww2UoWRBpdo38B4+xWmJVSbT3I=; b=0klBLLOvbKvCR+CLLuGLb11gXJC570i02q2nkN+jhE8W2LTCf6LpI3+3yg9v7FasrzhP EJMJR3gh6EpfvzZbiqFKF901iI2GbesVl0JpByqTk7evnLyqopqs81xiQ0irxyyr5UX1b cd/UjbB+UL8QyY15nw8VNFUd+7I5vEbM2y3GIB3qhTxD1wn0DyeoGAWq+U0pMG2O9DpC2 nZs+tUBu1K9IiqwdU6sgHm4iVh8CcYAFLCiaydKB9jqySeMbPSI5qhJO61sA3qTRnIzY9 MzAnxlp1pYM9lf5wnrkRdHqgJjjjlIUlCTjTuP0D6R0xn6+CEVTEUikHk1kJB6LmKiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DmaYRLWH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (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 44DDB606A32A; Wed, 2 Dec 2026 02:07:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DmaYRLWH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 566021F000C1; Wed, 2 Dec 2026 02:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796177278; bh=XFdF8y/advec6x3k3ww2UoWRBpdo38B4+xWmJVSbT3I=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=DmaYRLWHxj43g9ytxe9GpnESwL1oAXVPFDea103/GGhQiRNxCUU7/oDwRt0Mojeri hhMoU8RCzoNx/yhJb59KIrksl9MAJq7EzqDJxIpuz/a5Yj+5lR4q3hJLa0UGmz6gtE /Uqt9HmKIIhKZ4y8YXZ+0L5eHA3tYDBA11ODZGD6Ym3jqBGPhLEF7MivbWp53pI1yj wiGBr6qTWCB14y6BzVi9SrHaEOlL0zx3pbqgAPdnigmnIDCIcGt4yj0fGBIJXGXfuz 4pc8uRzMsEwpbLqTZ1fPZEEO3lCRISpVvi10JHhhIGR0awg85rizd1QxbhuvMnlbNm aKy8XiHdu/jAw== Subject: Re: [PATCH can-next v3 5/6] can: bittiming: can_bittiming_const_valid(): reject unusable BRP bit timing constant From: netdev-bot+sashiko@kernel.org To: mkl@pengutronix.de Cc: mailhol@kernel.org, socketcan@hartkopp.net, wg@grandegger.com, davem@davemloft.net, kernel@pengutronix.de, linux-can@vger.kernel.org, 25031212351@stu.xidian.edu.cn, stable@vger.kernel.org, byu@xidian.edu.cn, wencheng@xidian.edu.cn, kuba@kernel.org Date: Wed, 02 Dec 2026 02:07:57 +0000 Message-ID: <179617727792.3142.16790870159500847336@kernel.org> In-Reply-To: <20261130-bittiming-fix-conversion-v3-5-e61f92dc76d0@pengutronix.de> References: <20261130-bittiming-fix-conversion-v3-5-e61f92dc76d0@pengutronix.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-can@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The commit message understates the bug and lacks Fixes: and Cc: stable tags. -- can: bittiming: can_bittiming_const_valid(): reject unusable BRP bit timing constant This commit caps brp_max at 65536 in can_bittiming_const_valid(). Drivers that read their bit timing constants from a USB device can then no longer register a brp_max large enough to overflow brp * can_bit_time() in can_fixup_bittiming() and can_calc_bittiming(). > Controllers may read their bit timing constants via USB, limit `brp_max` to > a sensible value to avoid overflows in `can_fixup_bittiming()` and > `can_calc_bittiming()`. [Severity: Medium] Should the commit message say that this overflow ends in a divide by zero? Should it also carry Fixes: and Cc: stable tags? Before this patch, the only limit on brp_max was brp_min <= brp_max. gs_usb and ucan take both brp_max and clock.freq from the device. The previous patch limits the bit time to 1024 tq, but the u32 products used as divisors can still wrap to 0. In can_fixup_bittiming(), take clock.freq = 80 MHz, a user supplied tq of 52428800, brp_inc = 1 and a device reported brp_max >= 2^22. brp then ends up as 2^22: drivers/net/can/dev/bittiming.c:can_fixup_bittiming() { ... bt->bitrate = priv->clock.freq / (bt->brp * can_bit_time(bt)); ... } With a bit time of 1024, the divisor is 2^32, which wraps to 0. In can_calc_bittiming(), take clock.freq = 0xFFFFFFFF, tseg1_max + tseg2_max = 1023 and a requested bitrate of 1. On the first iteration tsegall = 1024 and div = 1024, so brp = 0xFFFFFFFF / 1024 + 1 = 2^22: drivers/net/can/dev/calc_bittiming.c:can_calc_bittiming() { ... bitrate = priv->clock.freq / (brp * tsegall); ... } Here brp * tsegall also wraps to 0. A CAP_NET_ADMIN user can reach both paths by sending IFLA_CAN_BITTIMING, which goes through can_changelink() under RTNL. The new check limits the product to 2^16 * 2^10, so the code change itself looks complete. The previous patch in the series, "can: bittiming: register_candev(): reject unusable bit-timing constants", carries Fixes: d58ac89d0d38 and Cc: stable. It also says such devices should "fail to probe instead of taking the kernel down later". If stable trees pick up only that patch, wouldn't this divide by zero still be reachable there? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-bittiming-fix-conversion-v3-0-e61f92dc76d0%40pengutronix.de