Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177226
b: refs/heads/master
c: d4703ae
h: refs/heads/master
v: v3
  • Loading branch information
Rusty Russell committed Dec 15, 2009
1 parent 1adddf8 commit 8edcfc7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 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: a8773769d1a1e08d0ca15f890515401ab3860637
refs/heads/master: d4703aefdbc8f9f347f6dcefcddd791294314eb7
5 changes: 5 additions & 0 deletions trunk/arch/powerpc/include/asm/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,10 @@ struct exception_table_entry;
void sort_ex_table(struct exception_table_entry *start,
struct exception_table_entry *finish);

#ifdef CONFIG_MODVERSIONS
#define ARCH_RELOCATES_KCRCTAB

extern const unsigned long reloc_start[];
#endif
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_MODULE_H */
3 changes: 3 additions & 0 deletions trunk/arch/powerpc/kernel/vmlinux.lds.S
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jiffies = jiffies_64 + 4;
#endif
SECTIONS
{
. = 0;
reloc_start = .;

. = KERNELBASE;

/*
Expand Down
28 changes: 21 additions & 7 deletions trunk/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,23 @@ static int try_to_force_load(struct module *mod, const char *reason)
}

#ifdef CONFIG_MODVERSIONS
/* If the arch applies (non-zero) relocations to kernel kcrctab, unapply it. */
static unsigned long maybe_relocated(unsigned long crc,
const struct module *crc_owner)
{
#ifdef ARCH_RELOCATES_KCRCTAB
if (crc_owner == NULL)
return crc - (unsigned long)reloc_start;
#endif
return crc;
}

static int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
const char *symname,
struct module *mod,
const unsigned long *crc)
const unsigned long *crc,
const struct module *crc_owner)
{
unsigned int i, num_versions;
struct modversion_info *versions;
Expand All @@ -905,10 +917,10 @@ static int check_version(Elf_Shdr *sechdrs,
if (strcmp(versions[i].name, symname) != 0)
continue;

if (versions[i].crc == *crc)
if (versions[i].crc == maybe_relocated(*crc, crc_owner))
return 1;
DEBUGP("Found checksum %lX vs module %lX\n",
*crc, versions[i].crc);
maybe_relocated(*crc, crc_owner), versions[i].crc);
goto bad_version;
}

Expand All @@ -931,7 +943,8 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs,
if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL,
&crc, true, false))
BUG();
return check_version(sechdrs, versindex, "module_layout", mod, crc);
return check_version(sechdrs, versindex, "module_layout", mod, crc,
NULL);
}

/* First part is kernel version, which we ignore if module has crcs. */
Expand All @@ -949,7 +962,8 @@ static inline int check_version(Elf_Shdr *sechdrs,
unsigned int versindex,
const char *symname,
struct module *mod,
const unsigned long *crc)
const unsigned long *crc,
const struct module *crc_owner)
{
return 1;
}
Expand Down Expand Up @@ -984,8 +998,8 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs,
/* use_module can fail due to OOM,
or module initialization or unloading */
if (sym) {
if (!check_version(sechdrs, versindex, name, mod, crc) ||
!use_module(mod, owner))
if (!check_version(sechdrs, versindex, name, mod, crc, owner)
|| !use_module(mod, owner))
sym = NULL;
}
return sym;
Expand Down

0 comments on commit 8edcfc7

Please sign in to comment.