[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090604014849.6332.35945.sendpatchset@localhost.localdomain>
Date: Wed, 3 Jun 2009 21:46:37 -0400
From: Amerigo Wang <amwang@...hat.com>
To: linux-kernel@...r.kernel.org
Cc: jdike@...toit.com, rusty@...tcorp.com.au, hch@...radead.org,
Amerigo Wang <amwang@...hat.com>, mingo@...e.hu,
akpm@...ux-foundation.org
Subject: [Patch 4/5] module: trim exception table in module_free()
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@...hat.com>
Cc: Rusty Russell <rusty@...tcorp.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. */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists