netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: macb: Validate the value of base_time properly
@ 2025-09-01 16:29 Chandra Mohan Sundar
  2025-09-02  8:51 ` Karumanchi, Vineeth
  2025-09-02 23:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Chandra Mohan Sundar @ 2025-09-01 16:29 UTC (permalink / raw)
  To: nicolas.ferre, claudiu.beznea, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, shuah
  Cc: Chandra Mohan Sundar, linux-kernel-mentees

In macb_taprio_setup_replace(), the value of start_time is being
compared against zero which would never be true since start_time
is an unsigned value. Due to this there is a chance that an
incorrect config base time value can be used for computation.

Fix by checking the value of conf->base_time directly.
This issue was reported by static coverity analyzer.

Fixes: 89934dbf169e3 ("net: macb: Add TAPRIO traffic scheduling support")
Signed-off-by: Chandra Mohan Sundar <chandramohan.explore@gmail.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 290d67da704d..e9b262a0223f 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -4104,7 +4104,7 @@ static int macb_taprio_setup_replace(struct net_device *ndev,
 		return -EINVAL;
 	}
 
-	if (start_time < 0) {
+	if (conf->base_time < 0) {
 		netdev_err(ndev, "Invalid base_time: must be 0 or positive, got %lld\n",
 			   conf->base_time);
 		return -ERANGE;
-- 
2.43.0


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

* Re: [PATCH net-next] net: macb: Validate the value of base_time properly
  2025-09-01 16:29 [PATCH net-next] net: macb: Validate the value of base_time properly Chandra Mohan Sundar
@ 2025-09-02  8:51 ` Karumanchi, Vineeth
  2025-09-02 23:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Karumanchi, Vineeth @ 2025-09-02  8:51 UTC (permalink / raw)
  To: Chandra Mohan Sundar, nicolas.ferre, claudiu.beznea,
	andrew+netdev, davem, edumazet, kuba, pabeni, netdev, shuah
  Cc: linux-kernel-mentees



On 9/1/2025 9:59 PM, Chandra Mohan Sundar wrote:
> In macb_taprio_setup_replace(), the value of start_time is being
> compared against zero which would never be true since start_time
> is an unsigned value. Due to this there is a chance that an
> incorrect config base time value can be used for computation.
> 
> Fix by checking the value of conf->base_time directly.
> This issue was reported by static coverity analyzer.
> 
> Fixes: 89934dbf169e3 ("net: macb: Add TAPRIO traffic scheduling support")
> Signed-off-by: Chandra Mohan Sundar <chandramohan.explore@gmail.com>

Reviewed-by: Vineeth Karumanchi <vineeth.karumanchi@amd.com>

> ---
>   drivers/net/ethernet/cadence/macb_main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 290d67da704d..e9b262a0223f 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -4104,7 +4104,7 @@ static int macb_taprio_setup_replace(struct net_device *ndev,
>   		return -EINVAL;
>   	}
>   
> -	if (start_time < 0) {
> +	if (conf->base_time < 0) {
>   		netdev_err(ndev, "Invalid base_time: must be 0 or positive, got %lld\n",
>   			   conf->base_time);
>   		return -ERANGE;

-- 
🙏 Vineeth


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

* Re: [PATCH net-next] net: macb: Validate the value of base_time properly
  2025-09-01 16:29 [PATCH net-next] net: macb: Validate the value of base_time properly Chandra Mohan Sundar
  2025-09-02  8:51 ` Karumanchi, Vineeth
@ 2025-09-02 23:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-02 23:50 UTC (permalink / raw)
  To: Chandra Mohan Sundar
  Cc: nicolas.ferre, claudiu.beznea, andrew+netdev, davem, edumazet,
	kuba, pabeni, netdev, shuah, linux-kernel-mentees

Hello:

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

On Mon,  1 Sep 2025 21:59:19 +0530 you wrote:
> In macb_taprio_setup_replace(), the value of start_time is being
> compared against zero which would never be true since start_time
> is an unsigned value. Due to this there is a chance that an
> incorrect config base time value can be used for computation.
> 
> Fix by checking the value of conf->base_time directly.
> This issue was reported by static coverity analyzer.
> 
> [...]

Here is the summary with links:
  - [net-next] net: macb: Validate the value of base_time properly
    https://git.kernel.org/netdev/net-next/c/3586018d5c3d

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:[~2025-09-02 23:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-01 16:29 [PATCH net-next] net: macb: Validate the value of base_time properly Chandra Mohan Sundar
2025-09-02  8:51 ` Karumanchi, Vineeth
2025-09-02 23: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;
as well as URLs for NNTP newsgroup(s).