public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow
@ 2023-04-06  9:59 Radu Pirea (OSS)
  2023-04-07 14:24 ` Andrew Lunn
  2023-04-08  2:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Radu Pirea (OSS) @ 2023-04-06  9:59 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Radu Pirea (OSS), stable

Any multiplication between GENMASK(31, 0) and a number bigger than 1
will be truncated because of the overflow, if the size of unsigned long
is 32 bits.

Replaced GENMASK with GENMASK_ULL to make sure that multiplication will
be between 64 bits values.

Cc: <stable@vger.kernel.org> # 5.15+
Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
---
 drivers/net/phy/nxp-c45-tja11xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
index 27738d1ae9ea..029875a59ff8 100644
--- a/drivers/net/phy/nxp-c45-tja11xx.c
+++ b/drivers/net/phy/nxp-c45-tja11xx.c
@@ -191,7 +191,7 @@
 #define MAX_ID_PS			2260U
 #define DEFAULT_ID_PS			2000U
 
-#define PPM_TO_SUBNS_INC(ppb)	div_u64(GENMASK(31, 0) * (ppb) * \
+#define PPM_TO_SUBNS_INC(ppb)	div_u64(GENMASK_ULL(31, 0) * (ppb) * \
 					PTP_CLK_PERIOD_100BT1, NSEC_PER_SEC)
 
 #define NXP_C45_SKB_CB(skb)	((struct nxp_c45_skb_cb *)(skb)->cb)
-- 
2.34.1


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

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow
  2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow Radu Pirea (OSS)
@ 2023-04-07 14:24 ` Andrew Lunn
  2023-04-08  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2023-04-07 14:24 UTC (permalink / raw)
  To: Radu Pirea (OSS)
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

On Thu, Apr 06, 2023 at 12:59:53PM +0300, Radu Pirea (OSS) wrote:
> Any multiplication between GENMASK(31, 0) and a number bigger than 1
> will be truncated because of the overflow, if the size of unsigned long
> is 32 bits.
> 
> Replaced GENMASK with GENMASK_ULL to make sure that multiplication will
> be between 64 bits values.
> 
> Cc: <stable@vger.kernel.org> # 5.15+
> Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
> Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow
  2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow Radu Pirea (OSS)
  2023-04-07 14:24 ` Andrew Lunn
@ 2023-04-08  2:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-08  2:50 UTC (permalink / raw)
  To: Radu Pirea
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  6 Apr 2023 12:59:53 +0300 you wrote:
> Any multiplication between GENMASK(31, 0) and a number bigger than 1
> will be truncated because of the overflow, if the size of unsigned long
> is 32 bits.
> 
> Replaced GENMASK with GENMASK_ULL to make sure that multiplication will
> be between 64 bits values.
> 
> [...]

Here is the summary with links:
  - [net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow
    https://git.kernel.org/netdev/net/c/bdaaecc127d4

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2023-04-08  2:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-06  9:59 [PATCH net] net: phy: nxp-c45-tja11xx: fix unsigned long multiplication overflow Radu Pirea (OSS)
2023-04-07 14:24 ` Andrew Lunn
2023-04-08  2:50 ` patchwork-bot+netdevbpf

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