Skip to content

Commit

Permalink
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/ker…
Browse files Browse the repository at this point in the history
…nel/git/rusty/linux

Pull virtio and module fixes from Rusty Russell:
 "YA module signing build tweak, and two cc'd to stable."

* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
  virtio: Don't access index after unregister.
  modules: don't break modules_install on external modules with no key.
  module: fix out-by-one error in kallsyms
  • Loading branch information
Linus Torvalds committed Nov 9, 2012
2 parents a601e63 + 237242b commit cdfe156
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
4 changes: 3 additions & 1 deletion drivers/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ EXPORT_SYMBOL_GPL(register_virtio_device);

void unregister_virtio_device(struct virtio_device *dev)
{
int index = dev->index; /* save for after device release */

device_unregister(&dev->dev);
ida_simple_remove(&virtio_index_ida, dev->index);
ida_simple_remove(&virtio_index_ida, index);
}
EXPORT_SYMBOL_GPL(unregister_virtio_device);

Expand Down
27 changes: 16 additions & 11 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2293,12 +2293,17 @@ static void layout_symtab(struct module *mod, struct load_info *info)
src = (void *)info->hdr + symsect->sh_offset;
nsrc = symsect->sh_size / sizeof(*src);

/* strtab always starts with a nul, so offset 0 is the empty string. */
strtab_size = 1;

/* Compute total space required for the core symbols' strtab. */
for (ndst = i = strtab_size = 1; i < nsrc; ++i, ++src)
if (is_core_symbol(src, info->sechdrs, info->hdr->e_shnum)) {
strtab_size += strlen(&info->strtab[src->st_name]) + 1;
for (ndst = i = 0; i < nsrc; i++) {
if (i == 0 ||
is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
strtab_size += strlen(&info->strtab[src[i].st_name])+1;
ndst++;
}
}

/* Append room for core symbols at end of core part. */
info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
Expand Down Expand Up @@ -2332,15 +2337,15 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
mod->core_symtab = dst = mod->module_core + info->symoffs;
mod->core_strtab = s = mod->module_core + info->stroffs;
src = mod->symtab;
*dst = *src;
*s++ = 0;
for (ndst = i = 1; i < mod->num_symtab; ++i, ++src) {
if (!is_core_symbol(src, info->sechdrs, info->hdr->e_shnum))
continue;

dst[ndst] = *src;
dst[ndst++].st_name = s - mod->core_strtab;
s += strlcpy(s, &mod->strtab[src->st_name], KSYM_NAME_LEN) + 1;
for (ndst = i = 0; i < mod->num_symtab; i++) {
if (i == 0 ||
is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {
dst[ndst] = src[i];
dst[ndst++].st_name = s - mod->core_strtab;
s += strlcpy(s, &mod->strtab[src[i].st_name],
KSYM_NAME_LEN) + 1;
}
}
mod->core_num_syms = ndst;
}
Expand Down
3 changes: 2 additions & 1 deletion scripts/Makefile.modinst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ PHONY += $(modules)
__modinst: $(modules)
@:

# Don't stop modules_install if we can't sign external modules.
quiet_cmd_modules_install = INSTALL $@
cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@)
cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) ; $(mod_sign_cmd) $(2)/$(notdir $@) $(patsubst %,|| true,$(KBUILD_EXTMOD))

# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra
Expand Down

0 comments on commit cdfe156

Please sign in to comment.