linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Problem: CONFIG_KALLSYMS is not set + kernel/module.c
@ 2012-07-29 15:27 Mark Hinds
  2012-07-29 15:48 ` Russell King - ARM Linux
  2012-08-13 10:44 ` Veli-Pekka Peltola
  0 siblings, 2 replies; 3+ messages in thread
From: Mark Hinds @ 2012-07-29 15:27 UTC (permalink / raw)
  To: linux-arm-kernel


In linux-3.2.xx I've been getting kernel dumps when I modprobe some
modules with CONFIG_KALLSYMS diabled - nls_base.ko for example.
I traced the problem to kernel/module.c, line 2607 or there about.

Starting with:
ptr = module_alloc_update_bounds(mod->init_size);

If mod->init_size == 0 then foobar happens. I assume that there is
no init section in some modules when CONFIG_KALLSYMS is disabled.

Here is my fix:

Index: kernel/module.c
===================================================================
--- kernel/module.c	(.../linux-3.2.24/kernel/module.c)	(revision 9084)
+++ kernel/module.c	(.../linux-3.2.24-ces/kernel/module.c)	(working copy)
@@ -2604,20 +2604,24 @@
  	memset(ptr, 0, mod->core_size);
  	mod->module_core = ptr;

-	ptr = module_alloc_update_bounds(mod->init_size);
-	/*
-	 * The pointer to this block is stored in the module structure
-	 * which is inside the block. This block doesn't need to be
-	 * scanned as it contains data and code that will be freed
-	 * after the module is initialized.
-	 */
-	kmemleak_ignore(ptr);
-	if (!ptr && mod->init_size) {
-		module_free(mod, mod->module_core);
-		return -ENOMEM;
+#warning ### CES/zoro fix problem with mod->init_size == 0
+	if (mod->init_size) {
+		ptr = module_alloc_update_bounds(mod->init_size);
+		/*
+	 	* The pointer to this block is stored in the module structure
+	 	* which is inside the block. This block doesn't need to be
+	 	* scanned as it contains data and code that will be freed
+	 	* after the module is initialized.
+	 	*/
+		kmemleak_ignore(ptr);
+		if (!ptr) {
+			module_free(mod, mod->module_core);
+			return -ENOMEM;
+		}
+		memset(ptr, 0, mod->init_size);
+		mod->module_init = ptr;
  	}
-	memset(ptr, 0, mod->init_size);
-	mod->module_init = ptr;
+	else mod->module_init = NULL;

  	/* Transfer each section which specifies SHF_ALLOC */
  	DEBUGP("final section addresses:\n");

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

* Problem: CONFIG_KALLSYMS is not set + kernel/module.c
  2012-07-29 15:27 Problem: CONFIG_KALLSYMS is not set + kernel/module.c Mark Hinds
@ 2012-07-29 15:48 ` Russell King - ARM Linux
  2012-08-13 10:44 ` Veli-Pekka Peltola
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King - ARM Linux @ 2012-07-29 15:48 UTC (permalink / raw)
  To: linux-arm-kernel

This is not ARM specific, please post it more widely.  Also consider
sending it to the person responsible for the module code as listed in
MAINTAINERS.  Thanks.

On Sun, Jul 29, 2012 at 08:27:17AM -0700, Mark Hinds wrote:
>
> In linux-3.2.xx I've been getting kernel dumps when I modprobe some
> modules with CONFIG_KALLSYMS diabled - nls_base.ko for example.
> I traced the problem to kernel/module.c, line 2607 or there about.
>
> Starting with:
> ptr = module_alloc_update_bounds(mod->init_size);
>
> If mod->init_size == 0 then foobar happens. I assume that there is
> no init section in some modules when CONFIG_KALLSYMS is disabled.
>
> Here is my fix:
>
> Index: kernel/module.c
> ===================================================================
> --- kernel/module.c	(.../linux-3.2.24/kernel/module.c)	(revision 9084)
> +++ kernel/module.c	(.../linux-3.2.24-ces/kernel/module.c)	(working copy)
> @@ -2604,20 +2604,24 @@
>  	memset(ptr, 0, mod->core_size);
>  	mod->module_core = ptr;
>
> -	ptr = module_alloc_update_bounds(mod->init_size);
> -	/*
> -	 * The pointer to this block is stored in the module structure
> -	 * which is inside the block. This block doesn't need to be
> -	 * scanned as it contains data and code that will be freed
> -	 * after the module is initialized.
> -	 */
> -	kmemleak_ignore(ptr);
> -	if (!ptr && mod->init_size) {
> -		module_free(mod, mod->module_core);
> -		return -ENOMEM;
> +#warning ### CES/zoro fix problem with mod->init_size == 0
> +	if (mod->init_size) {
> +		ptr = module_alloc_update_bounds(mod->init_size);
> +		/*
> +	 	* The pointer to this block is stored in the module structure
> +	 	* which is inside the block. This block doesn't need to be
> +	 	* scanned as it contains data and code that will be freed
> +	 	* after the module is initialized.
> +	 	*/
> +		kmemleak_ignore(ptr);
> +		if (!ptr) {
> +			module_free(mod, mod->module_core);
> +			return -ENOMEM;
> +		}
> +		memset(ptr, 0, mod->init_size);
> +		mod->module_init = ptr;
>  	}
> -	memset(ptr, 0, mod->init_size);
> -	mod->module_init = ptr;
> +	else mod->module_init = NULL;
>
>  	/* Transfer each section which specifies SHF_ALLOC */
>  	DEBUGP("final section addresses:\n");
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Problem: CONFIG_KALLSYMS is not set + kernel/module.c
  2012-07-29 15:27 Problem: CONFIG_KALLSYMS is not set + kernel/module.c Mark Hinds
  2012-07-29 15:48 ` Russell King - ARM Linux
@ 2012-08-13 10:44 ` Veli-Pekka Peltola
  1 sibling, 0 replies; 3+ messages in thread
From: Veli-Pekka Peltola @ 2012-08-13 10:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Mark,

On 07/29/2012 06:27 PM, Mark Hinds wrote:
>
> In linux-3.2.xx I've been getting kernel dumps when I modprobe some
> modules with CONFIG_KALLSYMS diabled - nls_base.ko for example.
> I traced the problem to kernel/module.c, line 2607 or there about.
>
> Starting with:
> ptr = module_alloc_update_bounds(mod->init_size);
>
> If mod->init_size == 0 then foobar happens. I assume that there is
> no init section in some modules when CONFIG_KALLSYMS is disabled.

A while ago I hit the same problem I guess. Could you check out if my 
fix[1] does the job for you?

--
Veli-Pekka Peltola

[1] https://lkml.org/lkml/2012/3/7/193

> Here is my fix:
>
> Index: kernel/module.c
> ===================================================================
> --- kernel/module.c    (.../linux-3.2.24/kernel/module.c)    (revision
> 9084)
> +++ kernel/module.c    (.../linux-3.2.24-ces/kernel/module.c)
> (working copy)
> @@ -2604,20 +2604,24 @@
>       memset(ptr, 0, mod->core_size);
>       mod->module_core = ptr;
>
> -    ptr = module_alloc_update_bounds(mod->init_size);
> -    /*
> -     * The pointer to this block is stored in the module structure
> -     * which is inside the block. This block doesn't need to be
> -     * scanned as it contains data and code that will be freed
> -     * after the module is initialized.
> -     */
> -    kmemleak_ignore(ptr);
> -    if (!ptr && mod->init_size) {
> -        module_free(mod, mod->module_core);
> -        return -ENOMEM;
> +#warning ### CES/zoro fix problem with mod->init_size == 0
> +    if (mod->init_size) {
> +        ptr = module_alloc_update_bounds(mod->init_size);
> +        /*
> +         * The pointer to this block is stored in the module structure
> +         * which is inside the block. This block doesn't need to be
> +         * scanned as it contains data and code that will be freed
> +         * after the module is initialized.
> +         */
> +        kmemleak_ignore(ptr);
> +        if (!ptr) {
> +            module_free(mod, mod->module_core);
> +            return -ENOMEM;
> +        }
> +        memset(ptr, 0, mod->init_size);
> +        mod->module_init = ptr;
>       }
> -    memset(ptr, 0, mod->init_size);
> -    mod->module_init = ptr;
> +    else mod->module_init = NULL;
>
>       /* Transfer each section which specifies SHF_ALLOC */
>       DEBUGP("final section addresses:\n");
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2012-08-13 10:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-29 15:27 Problem: CONFIG_KALLSYMS is not set + kernel/module.c Mark Hinds
2012-07-29 15:48 ` Russell King - ARM Linux
2012-08-13 10:44 ` Veli-Pekka Peltola

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