Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77924
b: refs/heads/master
c: bb9d3d5
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell committed Jan 29, 2008
1 parent f6b7cc7 commit 1ca45df
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: efa5345e39d01deef349c120f55ac6b6eabe7457
refs/heads/master: bb9d3d56e792d2619cc0903df4ac01d86ac1261d
38 changes: 20 additions & 18 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,17 @@ static void mod_kobject_remove(struct module *mod)
kobject_put(&mod->mkobj.kobj);
}

/*
* link the module with the whole machine is stopped with interrupts off
* - this defends against kallsyms not taking locks
*/
static int __link_module(void *_mod)
{
struct module *mod = _mod;
list_add(&mod->list, &modules);
return 0;
}

/*
* unlink the module with the whole machine is stopped with interrupts off
* - this defends against kallsyms not taking locks
Expand Down Expand Up @@ -2035,6 +2046,11 @@ static struct module *load_module(void __user *umod,
printk(KERN_WARNING "%s: Ignoring obsolete parameters\n",
mod->name);

/* Now sew it into the lists so we can get lockdep and oops
* info during argument parsing. Noone should access us, since
* strong_try_module_get() will fail. */
stop_machine_run(__link_module, mod, NR_CPUS);

/* Size of section 0 is 0, so this works well if no params */
err = parse_args(mod->name, mod->args,
(struct kernel_param *)
Expand All @@ -2043,15 +2059,15 @@ static struct module *load_module(void __user *umod,
/ sizeof(struct kernel_param),
NULL);
if (err < 0)
goto arch_cleanup;
goto unlink;

err = mod_sysfs_setup(mod,
(struct kernel_param *)
sechdrs[setupindex].sh_addr,
sechdrs[setupindex].sh_size
/ sizeof(struct kernel_param));
if (err < 0)
goto arch_cleanup;
goto unlink;
add_sect_attrs(mod, hdr->e_shnum, secstrings, sechdrs);
add_notes_attrs(mod, hdr->e_shnum, secstrings, sechdrs);

Expand All @@ -2066,7 +2082,8 @@ static struct module *load_module(void __user *umod,
/* Done! */
return mod;

arch_cleanup:
unlink:
stop_machine_run(__unlink_module, mod, NR_CPUS);
module_arch_cleanup(mod);
cleanup:
kobject_del(&mod->mkobj.kobj);
Expand All @@ -2091,17 +2108,6 @@ static struct module *load_module(void __user *umod,
goto free_hdr;
}

/*
* link the module with the whole machine is stopped with interrupts off
* - this defends against kallsyms not taking locks
*/
static int __link_module(void *_mod)
{
struct module *mod = _mod;
list_add(&mod->list, &modules);
return 0;
}

/* This is where the real work happens */
asmlinkage long
sys_init_module(void __user *umod,
Expand All @@ -2126,10 +2132,6 @@ sys_init_module(void __user *umod,
return PTR_ERR(mod);
}

/* Now sew it into the lists. They won't access us, since
strong_try_module_get() will fail. */
stop_machine_run(__link_module, mod, NR_CPUS);

/* Drop lock so they can recurse */
mutex_unlock(&module_mutex);

Expand Down

0 comments on commit 1ca45df

Please sign in to comment.