public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: dcaratti@redhat.com, chrism@mellanox.com, willy@infradead.org,
	Cong Wang <xiyou.wangcong@gmail.com>
Subject: [Patch net 0/3] idr: fix overflow cases on 32-bit CPU
Date: Fri, 28 Jun 2019 11:03:40 -0700	[thread overview]
Message-ID: <20190628180343.8230-1-xiyou.wangcong@gmail.com> (raw)

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


             reply	other threads:[~2019-06-28 18:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28 18:03 Cong Wang [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190628180343.8230-1-xiyou.wangcong@gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=chrism@mellanox.com \
    --cc=dcaratti@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox