linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] module: statically initialize init section freeing data
@ 2020-10-08 17:32 Daniel Jordan
  2020-10-09  4:17 ` Eric Biggers
  2020-10-12 18:34 ` Jessica Yu
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Jordan @ 2020-10-08 17:32 UTC (permalink / raw)
  To: Jessica Yu
  Cc: Corentin Labbe, Eric Biggers, Rick Edgecombe, Robin Murphy,
	Will Deacon, linux-crypto, linux-kernel, Daniel Jordan

Corentin hit the following workqueue warning when running with
CRYPTO_MANAGER_EXTRA_TESTS:

  WARNING: CPU: 2 PID: 147 at kernel/workqueue.c:1473 __queue_work+0x3b8/0x3d0
  Modules linked in: ghash_generic
  CPU: 2 PID: 147 Comm: modprobe Not tainted
      5.6.0-rc1-next-20200214-00068-g166c9264f0b1-dirty #545
  Hardware name: Pine H64 model A (DT)
  pc : __queue_work+0x3b8/0x3d0
  Call trace:
   __queue_work+0x3b8/0x3d0
   queue_work_on+0x6c/0x90
   do_init_module+0x188/0x1f0
   load_module+0x1d00/0x22b0

I wasn't able to reproduce on x86 or rpi 3b+.

This is

  WARN_ON(!list_empty(&work->entry))

from __queue_work(), and it happens because the init_free_wq work item
isn't initialized in time for a crypto test that requests the gcm
module.  Some crypto tests were recently moved earlier in boot as
explained in commit c4741b230597 ("crypto: run initcalls for generic
implementations earlier"), which went into mainline less than two weeks
before the Fixes commit.

Avoid the warning by statically initializing init_free_wq and the
corresponding llist.

Link: https://lore.kernel.org/lkml/20200217204803.GA13479@Red/
Fixes: 1a7b7d922081 ("modules: Use vmalloc special flag")
Reported-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-on: sun50i-h6-pine-h64
Tested-on: imx8mn-ddr4-evk
Tested-on: sun50i-a64-bananapi-m64
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
---
 kernel/module.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/kernel/module.c b/kernel/module.c
index 1c5cff34d9f2..8486123ffd7a 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -91,8 +91,9 @@ EXPORT_SYMBOL_GPL(module_mutex);
 static LIST_HEAD(modules);
 
 /* Work queue for freeing init sections in success case */
-static struct work_struct init_free_wq;
-static struct llist_head init_free_list;
+static void do_free_init(struct work_struct *w);
+static DECLARE_WORK(init_free_wq, do_free_init);
+static LLIST_HEAD(init_free_list);
 
 #ifdef CONFIG_MODULES_TREE_LOOKUP
 
@@ -3579,14 +3580,6 @@ static void do_free_init(struct work_struct *w)
 	}
 }
 
-static int __init modules_wq_init(void)
-{
-	INIT_WORK(&init_free_wq, do_free_init);
-	init_llist_head(&init_free_list);
-	return 0;
-}
-module_init(modules_wq_init);
-
 /*
  * This is where the real work happens.
  *

base-commit: c85fb28b6f999db9928b841f63f1beeb3074eeca
-- 
2.28.0


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

* Re: [PATCH] module: statically initialize init section freeing data
  2020-10-08 17:32 [PATCH] module: statically initialize init section freeing data Daniel Jordan
@ 2020-10-09  4:17 ` Eric Biggers
  2020-10-12 18:34 ` Jessica Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2020-10-09  4:17 UTC (permalink / raw)
  To: Daniel Jordan
  Cc: Jessica Yu, Corentin Labbe, Rick Edgecombe, Robin Murphy,
	Will Deacon, linux-crypto, linux-kernel

On Thu, Oct 08, 2020 at 01:32:20PM -0400, Daniel Jordan wrote:
> Corentin hit the following workqueue warning when running with
> CRYPTO_MANAGER_EXTRA_TESTS:
> 
>   WARNING: CPU: 2 PID: 147 at kernel/workqueue.c:1473 __queue_work+0x3b8/0x3d0
>   Modules linked in: ghash_generic
>   CPU: 2 PID: 147 Comm: modprobe Not tainted
>       5.6.0-rc1-next-20200214-00068-g166c9264f0b1-dirty #545
>   Hardware name: Pine H64 model A (DT)
>   pc : __queue_work+0x3b8/0x3d0
>   Call trace:
>    __queue_work+0x3b8/0x3d0
>    queue_work_on+0x6c/0x90
>    do_init_module+0x188/0x1f0
>    load_module+0x1d00/0x22b0
> 
> I wasn't able to reproduce on x86 or rpi 3b+.
> 
> This is
> 
>   WARN_ON(!list_empty(&work->entry))
> 
> from __queue_work(), and it happens because the init_free_wq work item
> isn't initialized in time for a crypto test that requests the gcm
> module.  Some crypto tests were recently moved earlier in boot as
> explained in commit c4741b230597 ("crypto: run initcalls for generic
> implementations earlier"), which went into mainline less than two weeks
> before the Fixes commit.
> 
> Avoid the warning by statically initializing init_free_wq and the
> corresponding llist.
> 
> Link: https://lore.kernel.org/lkml/20200217204803.GA13479@Red/
> Fixes: 1a7b7d922081 ("modules: Use vmalloc special flag")
> Reported-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
> Tested-on: sun50i-h6-pine-h64
> Tested-on: imx8mn-ddr4-evk
> Tested-on: sun50i-a64-bananapi-m64
> Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>

Looks good,

Reviewed-by: Eric Biggers <ebiggers@google.com>

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

* Re: [PATCH] module: statically initialize init section freeing data
  2020-10-08 17:32 [PATCH] module: statically initialize init section freeing data Daniel Jordan
  2020-10-09  4:17 ` Eric Biggers
@ 2020-10-12 18:34 ` Jessica Yu
  1 sibling, 0 replies; 3+ messages in thread
From: Jessica Yu @ 2020-10-12 18:34 UTC (permalink / raw)
  To: Daniel Jordan
  Cc: Corentin Labbe, Eric Biggers, Rick Edgecombe, Robin Murphy,
	Will Deacon, linux-crypto, linux-kernel

+++ Daniel Jordan [08/10/20 13:32 -0400]:
>Corentin hit the following workqueue warning when running with
>CRYPTO_MANAGER_EXTRA_TESTS:
>
>  WARNING: CPU: 2 PID: 147 at kernel/workqueue.c:1473 __queue_work+0x3b8/0x3d0
>  Modules linked in: ghash_generic
>  CPU: 2 PID: 147 Comm: modprobe Not tainted
>      5.6.0-rc1-next-20200214-00068-g166c9264f0b1-dirty #545
>  Hardware name: Pine H64 model A (DT)
>  pc : __queue_work+0x3b8/0x3d0
>  Call trace:
>   __queue_work+0x3b8/0x3d0
>   queue_work_on+0x6c/0x90
>   do_init_module+0x188/0x1f0
>   load_module+0x1d00/0x22b0
>
>I wasn't able to reproduce on x86 or rpi 3b+.
>
>This is
>
>  WARN_ON(!list_empty(&work->entry))
>
>from __queue_work(), and it happens because the init_free_wq work item
>isn't initialized in time for a crypto test that requests the gcm
>module.  Some crypto tests were recently moved earlier in boot as
>explained in commit c4741b230597 ("crypto: run initcalls for generic
>implementations earlier"), which went into mainline less than two weeks
>before the Fixes commit.
>
>Avoid the warning by statically initializing init_free_wq and the
>corresponding llist.
>
>Link: https://lore.kernel.org/lkml/20200217204803.GA13479@Red/
>Fixes: 1a7b7d922081 ("modules: Use vmalloc special flag")
>Reported-by: Corentin Labbe <clabbe.montjoie@gmail.com>
>Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
>Tested-on: sun50i-h6-pine-h64
>Tested-on: imx8mn-ddr4-evk
>Tested-on: sun50i-a64-bananapi-m64
>Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>

Applied, thanks!

Jessica

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

end of thread, other threads:[~2020-10-12 18:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-08 17:32 [PATCH] module: statically initialize init section freeing data Daniel Jordan
2020-10-09  4:17 ` Eric Biggers
2020-10-12 18:34 ` Jessica Yu

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