Skip to content

Commit 884c405

Browse files
Dotan Barakjfvogel
authored andcommitted
net/mlx4_core: add sanity check when creating bitmap structure
If a user tries to allocate bitmap structure with invalid values, this may cause a kernel panic. Signed-off-by: Dotan Barak <[email protected]> Reviewed-by: Yishai Hadas <[email protected]> (Ported from Mellanox OFED 2.4) Signed-off-by: Mukesh Kacker <[email protected]> Orabug: 27510503 (cherry picked from commit a6f7793) cherry-pick-repo=linux-uek.git Signed-off-by: Qing Huang <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]> Orabug: 31620966 UEK5 => UEK6 (cherry picked from commit f25d20b) cherry-pick-repo=UEK/production/linux-uek.git unmodified-from-upstream: f25d20b Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Sharath Srinivasan <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Orabug: 31620969 UEK6 => LUCI (cherry picked from commit 8718b22) cherry-pick-repo=UEK/production/linux-uek.git unmodified-from-upstream: 8718b22 Signed-off-by: Sharath Srinivasan <[email protected]> Reviewed-by: Sharon Liu <[email protected]> Signed-off-by: Aron Silverton <[email protected]
1 parent 55f6829 commit 884c405

File tree

1 file changed

+6
-0
lines changed
  • drivers/net/ethernet/mellanox/mlx4

1 file changed

+6
-0
lines changed

drivers/net/ethernet/mellanox/mlx4/alloc.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt,
173173
int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
174174
u32 reserved_bot, u32 reserved_top)
175175
{
176+
#ifndef WITHOUT_ORACLE_EXTENSIONS
177+
/* sanity check */
178+
if (num <= (u64)reserved_top + reserved_bot)
179+
return -EINVAL;
180+
#endif /* !WITHOUT_ORACLE_EXTENSIONS */
181+
176182
/* num must be a power of 2 */
177183
if (num != roundup_pow_of_two(num))
178184
return -EINVAL;

0 commit comments

Comments
 (0)