RE: strict rejection of init -> core references causes problems

Luck, Tony
2004-07-09T18:46:18Z

[-- Attachment #1: Type: text/plain, Size: 547 bytes --]

Here's what the patch looks like if you do want to
drop the kernel prohibition on calls from module core
to module init routines.

Has anyone got a script that could look for other instances
of modules that do this? If netfilter is the only one, then
it would be nice to keep the prohibition and fix netfilter
(debugging problems with bad calls after the module init
section has been freed sounds like no fun at all ... especially
if the freed page is later re-allocated to some other module).

Signed-off-by: <tony.luck@intel.com>

[-- Attachment #2: module2.patch --]
[-- Type: application/octet-stream, Size: 1504 bytes --]

diff -ru old/arch/ia64/kernel/module.c new/arch/ia64/kernel/module.c
--- old/arch/ia64/kernel/module.c 2004-07-09 10:37:12.444130040 -0700
+++ new/arch/ia64/kernel/module.c 2004-07-09 10:35:58.744861672 -0700
@@ -656,26 +656,18 @@
case RV_PCREL:
switch (r_type) {
case R_IA64_PCREL21B:
- if (in_init(mod, val)) {
- /* Calls to init code from core are bad news */
- if (in_core(mod, (uint64_t)location)) {
- printk(KERN_ERR "%s: init symbol 0x%lx used in module code at %p\n",
- mod->name, val, location);
- return -ENOEXEC;
- }
- } else if (in_core(mod, val)) {
+ if ((in_init(mod, val) && in_core(mod, (uint64_t)location)) ||
+ (in_core(mod, val) && in_init(mod, (uint64_t)location))) {
/*
* Init section may have been allocated far away from core,
* if the branch won't reach, then allocate a plt for it.
*/
- if (in_init(mod, (uint64_t)location)) {
- uint64_t delta = ((int64_t)val - (int64_t)location) / 16;
- if (delta + (1 << 20) >= (1 << 21)) {
- val = get_fdesc(mod, val, &ok);
- val = get_plt(mod, location, val, &ok);
- }
+ uint64_t delta = ((int64_t)val - (int64_t)location) / 16;
+ if (delta + (1 << 20) >= (1 << 21)) {
+ val = get_fdesc(mod, val, &ok);
+ val = get_plt(mod, location, val, &ok);
}
- } else
+ } else if (!is_internal(mod, val))
val = get_plt(mod, location, val, &ok);
/* FALL THROUGH */