linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/rhashtable: Fix work initialization in rhashtable_init()
@ 2018-12-17 21:40 Bart Van Assche
  2018-12-19  5:32 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2018-12-17 21:40 UTC (permalink / raw)
  To: Thomas Graf; +Cc: Herbert Xu, netdev, Bart Van Assche, linux-kernel

The test_insert_dup() function from lib/test_rhashtable.c passes a
pointer to a stack object to rhltable_init(). Avoid that the following
is reported with object debugging enabled while running the selftest
from lib/test_rhashtable.c:

ODEBUG: object (ptrval) is on stack (ptrval), but NOT annotated.
WARNING: CPU: 0 PID: 1 at lib/debugobjects.c:368 __debug_object_init+0x312/0x480
Modules linked in:
EIP: __debug_object_init+0x312/0x480
Call Trace:
 ? debug_object_init+0x1a/0x20
 ? __init_work+0x16/0x30
 ? rhashtable_init+0x1e1/0x460
 ? sched_clock_cpu+0x57/0xe0
 ? rhltable_init+0xb/0x20
 ? test_insert_dup+0x32/0x20f
 ? trace_hardirqs_on+0x38/0xf0
 ? ida_dump+0x10/0x10
 ? jhash+0x130/0x130
 ? my_hashfn+0x30/0x30
 ? test_rht_init+0x6aa/0xab4
 ? ida_dump+0x10/0x10
 ? test_rhltable+0xc5c/0xc5c
 ? do_one_initcall+0x67/0x28e
 ? trace_hardirqs_off+0x22/0xe0
 ? restore_all_kernel+0xf/0x70
 ? trace_hardirqs_on_thunk+0xc/0x10
 ? restore_all_kernel+0xf/0x70
 ? kernel_init_freeable+0x142/0x213
 ? rest_init+0x230/0x230
 ? kernel_init+0x10/0x110
 ? schedule_tail_wrapper+0x9/0xc
 ? ret_from_fork+0x19/0x24

Cc: Thomas Graf <tgraf@suug.ch>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 lib/rhashtable.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index 30526afa8343..6c22534c48e4 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -19,6 +19,7 @@
 #include <linux/init.h>
 #include <linux/log2.h>
 #include <linux/sched.h>
+#include <linux/sched/task_stack.h>
 #include <linux/rculist.h>
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
@@ -1072,7 +1073,10 @@ int rhashtable_init(struct rhashtable *ht,
 
 	RCU_INIT_POINTER(ht->tbl, tbl);
 
-	INIT_WORK(&ht->run_work, rht_deferred_worker);
+	if (object_is_on_stack(ht))
+		INIT_WORK_ONSTACK(&ht->run_work, rht_deferred_worker);
+	else
+		INIT_WORK(&ht->run_work, rht_deferred_worker);
 
 	return 0;
 }
-- 
2.20.0.405.gbc1bbc6f85-goog


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

* Re: [PATCH] lib/rhashtable: Fix work initialization in rhashtable_init()
  2018-12-17 21:40 [PATCH] lib/rhashtable: Fix work initialization in rhashtable_init() Bart Van Assche
@ 2018-12-19  5:32 ` David Miller
  2018-12-20 17:51   ` Bart Van Assche
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-12-19  5:32 UTC (permalink / raw)
  To: bvanassche; +Cc: tgraf, herbert, netdev, linux-kernel

From: Bart Van Assche <bvanassche@acm.org>
Date: Mon, 17 Dec 2018 13:40:58 -0800

> The test_insert_dup() function from lib/test_rhashtable.c passes a
> pointer to a stack object to rhltable_init(). Avoid that the following
> is reported with object debugging enabled while running the selftest
> from lib/test_rhashtable.c:
 ...
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Please just fix the test to use the global object created for this purpose
instead of an unnecessary on-stack instance.

Thanks.

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

* Re: [PATCH] lib/rhashtable: Fix work initialization in rhashtable_init()
  2018-12-19  5:32 ` David Miller
@ 2018-12-20 17:51   ` Bart Van Assche
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2018-12-20 17:51 UTC (permalink / raw)
  To: David Miller; +Cc: tgraf, herbert, netdev, linux-kernel

On Tue, 2018-12-18 at 21:32 -0800, David Miller wrote:
> From: Bart Van Assche <bvanassche@acm.org>
> Date: Mon, 17 Dec 2018 13:40:58 -0800
> 
> > The test_insert_dup() function from lib/test_rhashtable.c passes a
> > pointer to a stack object to rhltable_init(). Avoid that the following
> > is reported with object debugging enabled while running the selftest
> > from lib/test_rhashtable.c:
>  ...
> > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> 
> Please just fix the test to use the global object created for this purpose
> instead of an unnecessary on-stack instance.

Hi Dave,

I will do that. Thanks for the feedback.

Bart.

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

end of thread, other threads:[~2018-12-20 17:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 21:40 [PATCH] lib/rhashtable: Fix work initialization in rhashtable_init() Bart Van Assche
2018-12-19  5:32 ` David Miller
2018-12-20 17:51   ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).