Skip to contentSkip to conversation

net/mlx5: DR, Move STEv0 setters and getters

bug report Dan Carpenter 2 participants 2 messages Jan 8, 2021 – Jan 20, 2021 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello Yevgeny Kliteynik,

The patch 6b93b400aa88: "net/mlx5: DR, Move STEv0 setters and getters" from Nov 19, 2020, leads to the following static checker warning:

	drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c:252 dr_ste_v0_get_miss_addr()
	warn: potential shift truncation.  '0xff (0-255) << 26'

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c
248 static u64 dr_ste_v0_get_miss_addr(u8 *hw_ste_p) 249 {
250 u64 index 251 (MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_31_6) |

   252                   MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_39_32) << 26);
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is shifting a u32 value in the 0-255 range by << 26 which could result in shift wrapping. "index" is a u64 but ORing two u32 values will result in a u32.

253
254 return index << 6;
255 }

regards,
dan carpenter

#1 lore raw
Quoted 9 lines · Dan Carpenter

The patch 6b93b400aa88: "net/mlx5: DR, Move STEv0 setters and getters" from Nov 19, 2020, leads to the following static checker warning:

         drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c:252 dr_ste_v0_get_miss_addr()
         warn: potential shift truncation.  '0xff (0-255) << 26'

drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v0.c

Quoted 8 lines
    248  static u64 dr_ste_v0_get_miss_addr(u8 *hw_ste_p)
    249  {
    250          u64 index >     251                  (MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_31_6) |
    252                   MLX5_GET(ste_rx_steering_mult, hw_ste_p, miss_address_39_32) << 26);
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is shifting a u32 value in the 0-255 range by << 26 which could result in shift wrapping. "index" is a u64 but ORing two u32 values will result in a u32.

Thanks Dan, will send a fix shortly.

-- YK