linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Kamalesh Babulal <kamalesh@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fix error handling in load_module()
Date: Mon, 21 Sep 2009 23:23:35 +0900	[thread overview]
Message-ID: <4AB78C67.4060304@kernel.org> (raw)
In-Reply-To: <200909212030.03648.rusty@rustcorp.com.au>

Hello, Rusty.

Rusty Russell wrote:
>> My reverse engineering of the secret, undocumented percpu_modfree()
>> indicates that its mad inventor intended that percpu_modfree(NULL) be a
>> valid thing to do.
> 
> Yes, percpu_modfree() should handle NULL.  If it doesn't, that's the bug.

Hmm... It seems the report was against pre-2.6.32-rcX window.  ppc is
still using the original percpu_modfree() and I don't think the it
ever supported NULL free.  In the current linus tree, the triggering
BUG() would be at line 500 which is inside percpu_modfree() which
checks @freeme matches any allocated address and if not triggers
BUG().

I think something like the following should fix it.

 kernel/module.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 05ce49c..eed1f9e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -490,6 +490,9 @@ static void percpu_modfree(void *freeme)
 	void *ptr = __per_cpu_start + block_size(pcpu_size[0]);
 	int cpu;

+	if (unlikely(!freeme))
+		return;
+
 	/* First entry is core kernel percpu data. */
 	for (i = 1; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) {
 		if (ptr == freeme) {

-- 
tejun

  reply	other threads:[~2009-09-21 14:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-07 14:15 [PATCH] fix error handling in load_module() Kamalesh Babulal
2009-09-10 21:14 ` Andrew Morton
2009-09-14  9:42   ` Kamalesh Babulal
2009-09-21 11:00   ` Rusty Russell
2009-09-21 14:23     ` Tejun Heo [this message]
2009-09-21 14:41   ` Tejun Heo
2009-09-22  5:05     ` Rusty Russell
2009-09-22 10:10       ` Kamalesh Babulal

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=4AB78C67.4060304@kernel.org \
    --to=tj@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=kamalesh@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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;
as well as URLs for NNTP newsgroup(s).