From 25acb9d736102308c39622322a2d00038e2b7e2c Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sat, 2 Jan 2010 20:29:59 +0000 Subject: [PATCH] modules: Skip empty sections when exporting section notes (Closes: #563036) svn path=/dists/trunk/linux-2.6/; revision=14842 --- debian/changelog | 2 + .../modules-Skip-empty-section-notes.patch | 81 +++++++++++++++++++ debian/patches/series/4 | 1 + 3 files changed, 84 insertions(+) create mode 100644 debian/patches/bugfix/all/modules-Skip-empty-section-notes.patch create mode 100644 debian/patches/series/4 diff --git a/debian/changelog b/debian/changelog index e226057c5..1363a254b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ linux-2.6 (2.6.32-4) UNRELEASED; urgency=low [ Ben Hutchings ] * Correct comments referring to dpkg --print-installation-architecture in maintainer scripts (Closes: #558077) + * modules: Skip empty sections when exporting section notes + (Closes: #563036) [ maximilian attems ] * topconfig set CAN_EMS_USB, BT_MRVL, BT_MRVL_SDIO, BE2ISCSI, SCSI_PMCRAID, diff --git a/debian/patches/bugfix/all/modules-Skip-empty-section-notes.patch b/debian/patches/bugfix/all/modules-Skip-empty-section-notes.patch new file mode 100644 index 000000000..da1301cde --- /dev/null +++ b/debian/patches/bugfix/all/modules-Skip-empty-section-notes.patch @@ -0,0 +1,81 @@ +From 34c7e88db240e008758b97368d6f07631b017c92 Mon Sep 17 00:00:00 2001 +From: Ben Hutchings +Date: Fri, 18 Dec 2009 23:03:03 +0000 +Subject: [PATCH] modules: Skip empty sections when exporting section notes + +Commit 35dead4 "modules: don't export section names of empty sections +via sysfs" changed the set of sections that have attributes, but did +not change the iteration over these attributes in add_notes_attrs(). +This can lead to add_notes_attrs() creating attributes with the wrong +names or with null name pointers. + +Introduce a sect_empty() function and use it in both add_sect_attrs() +and add_notes_attrs(). + +Reported-by: Martin Michlmayr +Signed-off-by: Ben Hutchings +Tested-by: Martin Michlmayr +Cc: stable@kernel.org +--- + kernel/module.c | 17 ++++++++++------- + 1 files changed, 10 insertions(+), 7 deletions(-) + +diff --git a/kernel/module.c b/kernel/module.c +index e96b8ed..f82386b 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -1010,6 +1010,12 @@ static const struct kernel_symbol *resolve_symbol(Elf_Shdr *sechdrs, + * J. Corbet + */ + #if defined(CONFIG_KALLSYMS) && defined(CONFIG_SYSFS) ++ ++static inline bool sect_empty(const Elf_Shdr *sect) ++{ ++ return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0; ++} ++ + struct module_sect_attr + { + struct module_attribute mattr; +@@ -1051,8 +1057,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, + + /* Count loaded sections and allocate structures */ + for (i = 0; i < nsect; i++) +- if (sechdrs[i].sh_flags & SHF_ALLOC +- && sechdrs[i].sh_size) ++ if (!sect_empty(&sechdrs[i])) + nloaded++; + size[0] = ALIGN(sizeof(*sect_attrs) + + nloaded * sizeof(sect_attrs->attrs[0]), +@@ -1070,9 +1075,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect, + sattr = §_attrs->attrs[0]; + gattr = §_attrs->grp.attrs[0]; + for (i = 0; i < nsect; i++) { +- if (! (sechdrs[i].sh_flags & SHF_ALLOC)) +- continue; +- if (!sechdrs[i].sh_size) ++ if (sect_empty(&sechdrs[i])) + continue; + sattr->address = sechdrs[i].sh_addr; + sattr->name = kstrdup(secstrings + sechdrs[i].sh_name, +@@ -1156,7 +1159,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, + /* Count notes sections and allocate structures. */ + notes = 0; + for (i = 0; i < nsect; i++) +- if ((sechdrs[i].sh_flags & SHF_ALLOC) && ++ if (!sect_empty(&sechdrs[i]) && + (sechdrs[i].sh_type == SHT_NOTE)) + ++notes; + +@@ -1172,7 +1175,7 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect, + notes_attrs->notes = notes; + nattr = ¬es_attrs->attrs[0]; + for (loaded = i = 0; i < nsect; ++i) { +- if (!(sechdrs[i].sh_flags & SHF_ALLOC)) ++ if (sect_empty(&sechdrs[i])) + continue; + if (sechdrs[i].sh_type == SHT_NOTE) { + nattr->attr.name = mod->sect_attrs->attrs[loaded].name; +-- +1.6.5.7 + diff --git a/debian/patches/series/4 b/debian/patches/series/4 new file mode 100644 index 000000000..0d23e2cb8 --- /dev/null +++ b/debian/patches/series/4 @@ -0,0 +1 @@ ++ bugfix/all/modules-Skip-empty-section-notes.patch