Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift
@ 2024-08-19  7:54 Nikolay Kuratov
  2024-08-20 21:41 ` Jacob Keller
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Kuratov @ 2024-08-19  7:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: netdev, stable, lvc-project, Kumar Sanghvi, Potnuri Bharat Teja,
	Rahul Lakkireddy, Ganesh Goudar, David S. Miller, Simon Horman,
	Nikolay Kuratov

It is done everywhere in cxgb4 code, e.g. in is_filter_exact_match()
There is no reason it should not be done here

Found by Linux Verification Center (linuxtesting.org) with SVACE

Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
Cc: stable@vger.kernel.org
Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters")
Reviewed-by: Simon Horman <horms@kernel.org>
---
v2: Wrap line to 80 characters

 drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
index 786ceae34488..dd9e68465e69 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
@@ -1244,7 +1244,8 @@ static u64 hash_filter_ntuple(struct ch_filter_specification *fs,
 	 * in the Compressed Filter Tuple.
 	 */
 	if (tp->vlan_shift >= 0 && fs->mask.ivlan)
-		ntuple |= (FT_VLAN_VLD_F | fs->val.ivlan) << tp->vlan_shift;
+		ntuple |= (u64)(FT_VLAN_VLD_F |
+				fs->val.ivlan) << tp->vlan_shift;
 
 	if (tp->port_shift >= 0 && fs->mask.iport)
 		ntuple |= (u64)fs->val.iport << tp->port_shift;
-- 
2.34.1


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

* Re: [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift
  2024-08-19  7:54 [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift Nikolay Kuratov
@ 2024-08-20 21:41 ` Jacob Keller
  2024-08-20 22:44 ` Jakub Kicinski
  2024-08-20 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jacob Keller @ 2024-08-20 21:41 UTC (permalink / raw)
  To: Nikolay Kuratov, linux-kernel
  Cc: netdev, stable, lvc-project, Kumar Sanghvi, Potnuri Bharat Teja,
	Rahul Lakkireddy, Ganesh Goudar, David S. Miller, Simon Horman



On 8/19/2024 12:54 AM, Nikolay Kuratov wrote:
> It is done everywhere in cxgb4 code, e.g. in is_filter_exact_match()
> There is no reason it should not be done here
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE
> 

Without casting to u64, the value would be smaller and the shift might
not behave as expected?

Slightly annoying that the extra cause causes us to break 80 columns.

I checked and the FT_VLAN_VLD_F doesn't appear to already be a ULL value
either.

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

> Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
> Cc: stable@vger.kernel.org
> Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters")
> Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> v2: Wrap line to 80 characters
> 
>  drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> index 786ceae34488..dd9e68465e69 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c
> @@ -1244,7 +1244,8 @@ static u64 hash_filter_ntuple(struct ch_filter_specification *fs,
>  	 * in the Compressed Filter Tuple.
>  	 */
>  	if (tp->vlan_shift >= 0 && fs->mask.ivlan)
> -		ntuple |= (FT_VLAN_VLD_F | fs->val.ivlan) << tp->vlan_shift;
> +		ntuple |= (u64)(FT_VLAN_VLD_F |
> +				fs->val.ivlan) << tp->vlan_shift;
>  
>  	if (tp->port_shift >= 0 && fs->mask.iport)
>  		ntuple |= (u64)fs->val.iport << tp->port_shift;

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

* Re: [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift
  2024-08-19  7:54 [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift Nikolay Kuratov
  2024-08-20 21:41 ` Jacob Keller
@ 2024-08-20 22:44 ` Jakub Kicinski
  2024-08-20 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-08-20 22:44 UTC (permalink / raw)
  To: Nikolay Kuratov
  Cc: linux-kernel, netdev, stable, lvc-project, Kumar Sanghvi,
	Potnuri Bharat Teja, Rahul Lakkireddy, Ganesh Goudar,
	David S. Miller, Simon Horman

On Mon, 19 Aug 2024 10:54:08 +0300 Nikolay Kuratov wrote:
> It is done everywhere in cxgb4 code, e.g. in is_filter_exact_match()
> There is no reason it should not be done here

The max value of the shift is 21. I wish you spent more than 5 min
looking at this code.

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

* Re: [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift
  2024-08-19  7:54 [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift Nikolay Kuratov
  2024-08-20 21:41 ` Jacob Keller
  2024-08-20 22:44 ` Jakub Kicinski
@ 2024-08-20 22:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-20 22:50 UTC (permalink / raw)
  To: Nikolay Kuratov
  Cc: linux-kernel, netdev, stable, lvc-project, kumaras, bharat,
	rahul.lakkireddy, ganeshgr, davem, horms

Hello:

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

On Mon, 19 Aug 2024 10:54:08 +0300 you wrote:
> It is done everywhere in cxgb4 code, e.g. in is_filter_exact_match()
> There is no reason it should not be done here
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE
> 
> Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
> Cc: stable@vger.kernel.org
> Fixes: 12b276fbf6e0 ("cxgb4: add support to create hash filters")
> Reviewed-by: Simon Horman <horms@kernel.org>
> 
> [...]

Here is the summary with links:
  - [v2] cxgb4: add forgotten u64 ivlan cast before shift
    https://git.kernel.org/netdev/net/c/80a1e7b83bb1

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] 4+ messages in thread

end of thread, other threads:[~2024-08-20 22:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-19  7:54 [PATCH v2] cxgb4: add forgotten u64 ivlan cast before shift Nikolay Kuratov
2024-08-20 21:41 ` Jacob Keller
2024-08-20 22:44 ` Jakub Kicinski
2024-08-20 22: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