From: Tejun Heo <tj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: markus@trippelsdorf.de, linux-kernel@vger.kernel.org
Subject: [PATCH] idr: remove WARN_ON_ONCE() on negative IDs
Date: Fri, 1 Mar 2013 13:45:14 -0800 [thread overview]
Message-ID: <20130301214514.GG2481@mtj.dyndns.org> (raw)
In-Reply-To: <20130301213511.GF2481@mtj.dyndns.org>
idr_find(), idr_remove() and idr_replace() used to silently ignore the
sign bit and perform lookup with the rest of the bits. The weird
behavior has been changed such that negative IDs are treated as
invalid. As the behavior change was subtle, WARN_ON_ONCE() was added
in the hope of determining who's calling idr functions with negative
IDs so that they can be examined for problems.
Up until now, all two reported cases are ID number coming directly
from userland and getting fed into idr_find() and the warnings seem to
cause more problems than being helpful. Drop the WARN_ON_ONCE()s.
Signed-off-by: Tejun Heo <tj@kernel.org>
Reported-by: markus@trippelsdorf.de
Cc: Andrew Morton <akpm@linux-foundation.org>
---
lib/idr.c | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/lib/idr.c b/lib/idr.c
index 73f4d53..00739aa 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -569,8 +569,7 @@ void idr_remove(struct idr *idp, int id)
struct idr_layer *p;
struct idr_layer *to_free;
- /* see comment in idr_find_slowpath() */
- if (WARN_ON_ONCE(id < 0))
+ if (id < 0)
return;
sub_remove(idp, (idp->layers - 1) * IDR_BITS, id);
@@ -667,15 +666,7 @@ void *idr_find_slowpath(struct idr *idp, int id)
int n;
struct idr_layer *p;
- /*
- * If @id is negative, idr_find() used to ignore the sign bit and
- * performed lookup with the rest of bits, which is weird and can
- * lead to very obscure bugs. We're now returning NULL for all
- * negative IDs but just in case somebody was depending on the sign
- * bit being ignored, let's trigger WARN_ON_ONCE() so that they can
- * be detected and fixed. WARN_ON_ONCE() can later be removed.
- */
- if (WARN_ON_ONCE(id < 0))
+ if (id < 0)
return NULL;
p = rcu_dereference_raw(idp->top);
@@ -824,8 +815,7 @@ void *idr_replace(struct idr *idp, void *ptr, int id)
int n;
struct idr_layer *p, *old_p;
- /* see comment in idr_find_slowpath() */
- if (WARN_ON_ONCE(id < 0))
+ if (id < 0)
return ERR_PTR(-EINVAL);
p = idp->top;
next prev parent reply other threads:[~2013-03-01 21:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 9:08 WARNING: at lib/idr.c:678 idr_find_slowpath+0x97/0xc0() markus
2013-03-01 21:31 ` Andrew Morton
2013-03-01 21:35 ` Tejun Heo
2013-03-01 21:45 ` Tejun Heo [this message]
2013-03-01 21:54 ` Peter Hurley
2013-03-01 21:56 ` Tejun Heo
2013-03-01 22:10 ` Peter Hurley
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=20130301214514.GG2481@mtj.dyndns.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=markus@trippelsdorf.de \
/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
all inboxes | Powered by JetHome®