Skip to contentSkip to conversation

idr: Don't WARN in idr_find

PATCH In review Peter Hurley 2 participants 5 messages Feb 26, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 idr: Don't WARN in idr_find

Since idr is used for syscall apis (to associate 'handles' with internal structures), don't WARN with invalid input.

For example, POSIX timers are identified by timer_t id. These ids are idr values. If userspace passes a representable timer_t id value (eg, id < 0) but which was not previous allocated (since the current idr api does not return negative idr values), then the syscall properly returns an error; a WARN is unnecessary and undesirable.

[  188.957053] WARNING: at /home/peter/src/kernels/next/lib/idr.c:669 idr_find_slowpath+0x151/0x170()
[  188.957055] Hardware name: Bochs
[  188.957105] Modules linked in: nfnetlink scsi_transport_iscsi can_raw ipt_ULOG
<...snip...>
[  188.957109] Pid: 2682, comm: trinity-child2 Not tainted 3.9.0-next-20130220+ldsem-xeon+lockdep #20130220+ldsem
[  188.957112] Call Trace:
[  188.957124]  [<ffffffff8105ecdf>] warn_slowpath_common+0x7f/0xc0
[  188.957126]  [<ffffffff8105ed3a>] warn_slowpath_null+0x1a/0x20
[  188.957129]  [<ffffffff813a8691>] idr_find_slowpath+0x151/0x170
[  188.957139]  [<ffffffff8108d787>] __lock_timer+0x97/0x2b0
[  188.957142]  [<ffffffff8108d6f5>] ? __lock_timer+0x5/0x2b0
[  188.957145]  [<ffffffff8108e0b7>] sys_timer_getoverrun+0x17/0x50
[  188.957152]  [<ffffffff817aeb99>] system_call_fastpath+0x16/0x1b
[  188.957156] ---[ end trace 25fe46b21eb9d42d ]---
---
 lib/idr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/idr.c +1 -1
index 1a30272..8e9b1ac 100644
@@ -666,7 +666,7 @@ void *idr_find_slowpath(struct idr *idp, int id)
 	int n;
 	struct idr_layer *p;
 
-	if (WARN_ON_ONCE(id < 0))
+	if (id < 0)
 		return NULL;
 
 	p = rcu_dereference_raw(idp->top);
Signature · 1 line
1.8.1.2
#1 lore raw
Quoted 9 lines · Peter Hurley

Since idr is used for syscall apis (to associate 'handles' with internal structures), don't WARN with invalid input.

For example, POSIX timers are identified by timer_t id. These ids are idr values. If userspace passes a representable timer_t id value (eg, id < 0) but which was not previous allocated (since the current idr api does not return negative idr values), then the syscall properly returns an error; a WARN is unnecessary and undesirable.

WARN_ON() on negative was intentional. Because the previous implmentation silently dropped the msb, we at least wanna know who has been passing in negative indices. Patch for the lock_timer is already in -mm.

Thanks.

Signature · 1 line
tejun
#2 lore raw
Quoted 11 lines · Tejun Heo
Quoted 9 lines · Peter Hurley

Since idr is used for syscall apis (to associate 'handles' with internal structures), don't WARN with invalid input.

For example, POSIX timers are identified by timer_t id. These ids are idr values. If userspace passes a representable timer_t id value (eg, id < 0) but which was not previous allocated (since the current idr api does not return negative idr values), then the syscall properly returns an error; a WARN is unnecessary and undesirable.

Quoted 4 lines

WARN_ON() on negative was intentional. Because the previous implmentation silently dropped the msb, we at least wanna know who has been passing in negative indices. Patch for the lock_timer is already in -mm.

Thanks. Can you share the patch title? It's not in next-20130225.

Peter

#3 lore raw
Quoted 12 lines · Peter Hurley
Quoted 11 lines · Tejun Heo
Quoted 9 lines · Peter Hurley

Since idr is used for syscall apis (to associate 'handles' with internal structures), don't WARN with invalid input.

For example, POSIX timers are identified by timer_t id. These ids are idr values. If userspace passes a representable timer_t id value (eg, id < 0) but which was not previous allocated (since the current idr api does not return negative idr values), then the syscall properly returns an error; a WARN is unnecessary and undesirable.

Quoted 6 lines
Quoted 4 lines

WARN_ON() on negative was intentional. Because the previous implmentation silently dropped the msb, we at least wanna know who has been passing in negative indices. Patch for the lock_timer is already in -mm.

Thanks. Can you share the patch title? It's not in next-20130225.

It's this one.

http://thread.gmane.org/gmane.linux.kernel/1444883/focus=1445094

Thanks.

Signature · 1 line
tejun
#4 lore raw
Quoted 18 lines · Tejun Heo
Quoted 17 lines · Peter Hurley
Quoted 15 lines · Tejun Heo
Quoted 9 lines · Peter Hurley

Since idr is used for syscall apis (to associate 'handles' with internal structures), don't WARN with invalid input.

For example, POSIX timers are identified by timer_t id. These ids are idr values. If userspace passes a representable timer_t id value (eg, id < 0) but which was not previous allocated (since the current idr api does not return negative idr values), then the syscall properly returns an error; a WARN is unnecessary and undesirable.

WARN_ON() on negative was intentional. Because the previous implmentation silently dropped the msb, we at least wanna know who has been passing in negative indices. Patch for the lock_timer is already in -mm.

Quoted 5 lines
Quoted 1 line

Thanks. Can you share the patch title? It's not in next-20130225.

It's this one.

http://thread.gmane.org/gmane.linux.kernel/1444883/focus=1445094

Thanks and sorry; not sure how I missed that thread.