public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Amerigo Wang <amwang@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: jdike@addtoit.com, rusty@rustcorp.com.au, hch@infradead.org,
	Amerigo Wang <amwang@redhat.com>,
	mingo@elte.hu, akpm@linux-foundation.org
Subject: [Patch 4/5] module: trim exception table in module_free()
Date: Wed, 3 Jun 2009 21:46:37 -0400	[thread overview]
Message-ID: <20090604014849.6332.35945.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20090604014813.6332.18486.sendpatchset@localhost.localdomain>


Just as the comment said, trim the exception table entries when
module_free() mod->module_init.

Currently, this is only done for x86. Other platforms should
also fix it like this (except sparc32).

Signed-off-by: WANG Cong <amwang@redhat.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>

---
Index: linux-2.6/arch/x86/kernel/module.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/module.c
+++ linux-2.6/arch/x86/kernel/module.c
@@ -27,6 +27,7 @@
 #include <asm/system.h>
 #include <asm/page.h>
 #include <asm/pgtable.h>
+#include <asm/uaccess.h>
 
 #if 0
 #define DEBUGP printk
@@ -60,12 +61,24 @@ void *module_alloc(unsigned long size)
 }
 #endif
 
+static void trim_init_extable(struct module *m)
+{
+	/*trim the beginning*/
+	while (m->num_exentries && within_module_init(m->extable[0].insn, m)) {
+		m->extable++;
+		m->num_exentries--;
+	}
+	/*trim the end*/
+	while (m->num_exentries &&
+		within_module_init(m->extable[m->num_exentries-1].insn, m))
+		m->num_exentries--;
+}
+
 /* Free memory returned from module_alloc */
 void module_free(struct module *mod, void *module_region)
 {
 	vfree(module_region);
-	/* FIXME: If module_region == mod->init_region, trim exception
-	   table entries. */
+	trim_init_extable(mod);
 }
 
 /* We don't need anything special. */

  parent reply	other threads:[~2009-06-04  1:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-04  1:46 [Patch 0/5][V2] module: merge module_32.c and module_64.c Amerigo Wang
2009-06-04  1:46 ` [Patch 1/5] x86 module: merge the same functions in " Amerigo Wang
2009-06-04  1:46 ` [Patch 2/5] x86 module: merge the rest functions with macros Amerigo Wang
2009-06-04  1:46 ` [Patch 3/5] uml module: fix uml build process due to this merge Amerigo Wang
2009-06-04  1:46 ` Amerigo Wang [this message]
2009-06-04  8:30   ` [Patch 4/5] module: trim exception table in module_free() Rusty Russell
2009-06-04  8:57     ` Amerigo Wang
2009-06-05 15:08       ` Rusty Russell
2009-06-08  1:28         ` Amerigo Wang
2009-06-10  8:09         ` David Miller
2009-06-07 12:15     ` Ingo Molnar
2009-06-08  1:36       ` Amerigo Wang
2009-06-09  7:51         ` Rusty Russell
2009-06-04  1:46 ` [Patch 5/5] module: merge module_alloc() finally Amerigo Wang

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=20090604014849.6332.35945.sendpatchset@localhost.localdomain \
    --to=amwang@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --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