Skip to content

idr: fix overflow cases on 32-bit CPU

Cong Wang netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3idr: fix overflow case for idr_for_each_entry_ul()include/linux/idr.h net/sched/act_api.c+11 -50 replies
2/3idr: introduce idr_for_each_entry_continue_ul()drivers/net/ethernet/mellanox/mlx5/core/fs_counters.c include/linux/idr.h net/sched/cls_flower.c+27 -241 reply
3/3selftests: add a test case for cls_lower handle overflowtools/testing/selftests/tc-testing/tc-tests/filters/tests.json+19 -00 replies

Reviews trailers per patch

None of the 3 patches has a Reviewed-by or Acked-by.

PatchDavide Caratti
1/3T-b
2/3T-b
3/3

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [Patch net 0/3] idr: fix overflow cases on 32-bit CPU

idr_get_next_ul() is problematic by design, it can't handle the following overflow case well on 32-bit CPU:

u32 id = UINT_MAX;
idr_alloc_u32(&id);
while (idr_get_next_ul(&id) != NULL)
id++;

when 'id' overflows and becomes 0 after UINT_MAX, the loop goes infinite.

Fix this by eliminating external users of idr_get_next_ul() and migrating them to idr_for_each_entry_continue_ul(). And add an additional parameter for these iteration macros to detect overflow properly.

Please merge this through networking tree, as all the users are in networking subsystem.

Cong Wang (2):
idr: fix overflow case for idr_for_each_entry_ul()
idr: introduce idr_for_each_entry_continue_ul()

Davide Caratti (1):
selftests: add a test case for cls_lower handle overflow

---
 .../ethernet/mellanox/mlx5/core/fs_counters.c | 10 ++++---
 include/linux/idr.h                           | 21 +++++++++++++--
 net/sched/act_api.c                           |  9 ++++---
 net/sched/cls_flower.c                        | 27 +++++--------------
 .../tc-testing/tc-tests/filters/tests.json    | 19 +++++++++++++
 5 files changed, 57 insertions(+), 29 deletions(-)
Signature · 1 line
2.21.0