public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch net 0/3] idr: fix overflow cases on 32-bit CPU
@ 2019-06-28 18:03 Cong Wang
  2019-06-28 18:03 ` [Patch net 1/3] idr: fix overflow case for idr_for_each_entry_ul() Cong Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Cong Wang @ 2019-06-28 18:03 UTC (permalink / raw)
  To: netdev; +Cc: dcaratti, chrism, willy, Cong Wang

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(-)

-- 
2.21.0


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

end of thread, other threads:[~2019-07-02  3:12 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-28 18:03 [Patch net 0/3] idr: fix overflow cases on 32-bit CPU Cong Wang
2019-06-28 18:03 ` [Patch net 1/3] idr: fix overflow case for idr_for_each_entry_ul() Cong Wang
2019-06-28 18:03 ` [Patch net 2/3] idr: introduce idr_for_each_entry_continue_ul() Cong Wang
2019-06-28 21:14   ` Davide Caratti
2019-06-28 18:03 ` [Patch net 3/3] selftests: add a test case for cls_lower handle overflow Cong Wang
2019-07-02  2:16 ` [Patch net 0/3] idr: fix overflow cases on 32-bit CPU David Miller
2019-07-02  2:37   ` Matthew Wilcox
2019-07-02  2:39     ` David Miller
2019-07-02  3:12     ` Cong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox