Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 95974
b: refs/heads/master
c: 8dcf578
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed May 5, 2008
1 parent 90956ed commit 909ec45
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 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: b8ba5f10c5956d2b297766fda8f4f5ab8ad1e2cc
refs/heads/master: 8dcf5782848600ecfd0df3a45c521b5ad0fcb42e
6 changes: 0 additions & 6 deletions trunk/include/linux/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ static inline int sysfs_update_group(struct kobject *kobj,
return 0;
}

static inline int sysfs_update_group(struct kobject *kobj,
const struct attribute_group *grp)
{
return 0;
}

static inline void sysfs_remove_group(struct kobject *kobj,
const struct attribute_group *grp)
{
Expand Down
9 changes: 9 additions & 0 deletions trunk/init/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,15 @@ menuconfig MODULES

If unsure, say Y.

config MODULE_FORCE_LOAD
bool "Forced module loading"
depends on MODULES
default n
help
This option allows loading of modules even if that would set the
'F' (forced) taint, due to lack of version info. Which is
usually a really bad idea.

config MODULE_UNLOAD
bool "Module unloading"
depends on MODULES
Expand Down
44 changes: 29 additions & 15 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,19 @@ static struct module_attribute *modinfo_attrs[] = {

static const char vermagic[] = VERMAGIC_STRING;

static int try_to_force_load(struct module *mod, const char *symname)
{
#ifdef CONFIG_MODULE_FORCE_LOAD
if (!(tainted & TAINT_FORCED_MODULE))
printk("%s: no version for \"%s\" found: kernel tainted.\n",
mod->name, symname);
add_taint_module(mod, TAINT_FORCED_MODULE);
return 0;
#else
return -ENOEXEC;
#endif
}

#ifdef CONFIG_MODVERSIONS
static int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
Expand All @@ -914,18 +927,18 @@ static int check_version(Elf_Shdr *sechdrs,

if (versions[i].crc == *crc)
return 1;
printk("%s: disagrees about version of symbol %s\n",
mod->name, symname);
DEBUGP("Found checksum %lX vs module %lX\n",
*crc, versions[i].crc);
return 0;
goto bad_version;
}
/* Not in module's version table. OK, but that taints the kernel. */
if (!(tainted & TAINT_FORCED_MODULE))
printk("%s: no version for \"%s\" found: kernel tainted.\n",
mod->name, symname);
add_taint_module(mod, TAINT_FORCED_MODULE);
return 1;

if (!try_to_force_load(mod, symname))
return 1;

bad_version:
printk("%s: disagrees about version of symbol %s\n",
mod->name, symname);
return 0;
}

static inline int check_modstruct_version(Elf_Shdr *sechdrs,
Expand Down Expand Up @@ -1853,9 +1866,9 @@ static struct module *load_module(void __user *umod,
modmagic = get_modinfo(sechdrs, infoindex, "vermagic");
/* This is allowed: modprobe --force will invalidate it. */
if (!modmagic) {
add_taint_module(mod, TAINT_FORCED_MODULE);
printk(KERN_WARNING "%s: no version magic, tainting kernel.\n",
mod->name);
err = try_to_force_load(mod, "magic");
if (err)
goto free_hdr;
} else if (!same_magic(modmagic, vermagic)) {
printk(KERN_ERR "%s: version magic '%s' should be '%s'\n",
mod->name, modmagic, vermagic);
Expand Down Expand Up @@ -2006,9 +2019,10 @@ static struct module *load_module(void __user *umod,
(mod->num_gpl_future_syms && !gplfuturecrcindex) ||
(mod->num_unused_syms && !unusedcrcindex) ||
(mod->num_unused_gpl_syms && !unusedgplcrcindex)) {
printk(KERN_WARNING "%s: No versions for exported symbols."
" Tainting kernel.\n", mod->name);
add_taint_module(mod, TAINT_FORCED_MODULE);
printk(KERN_WARNING "%s: No versions for exported symbols.\n", mod->name);
err = try_to_force_load(mod, "nocrc");
if (err)
goto cleanup;
}
#endif
markersindex = find_sec(hdr, sechdrs, secstrings, "__markers");
Expand Down

0 comments on commit 909ec45

Please sign in to comment.