* [PATCH] modules: don't export section names of empty sections via sysfs
@ 2009-12-02 23:29 Helge Deller
2009-12-03 7:20 ` Rusty Russell
0 siblings, 1 reply; 4+ messages in thread
From: Helge Deller @ 2009-12-02 23:29 UTC (permalink / raw)
To: linux-kernel, linux-parisc, kyle, rusty, akpm, James.Bottomley,
roland, dave, torvalds
[PATCH] modules: don't export section names of empty sections via sysfs
On the parisc architecture we face for each and every loaded kernel module
this kernel "badness warning":
sysfs: cannot create duplicate filename '/module/ac97_bus/sections/.text'
Badness at fs/sysfs/dir.c:487
Reason for that is, that on parisc all kernel modules do have multiple
.text sections due to the usage of the -ffunction-sections compiler flag
which is needed to reach all jump targets on this platform.
An objdump on such a kernel module gives:
Sections:
Idx Name Size VMA LMA File off Algn
0 .note.gnu.build-id 00000024 00000000 00000000 00000034 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 00000000 00000000 00000000 00000058 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .text.ac97_bus_match 0000001c 00000000 00000000 00000058 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .text 00000000 00000000 00000000 000000d4 2**0
CONTENTS, ALLOC, LOAD, READONLY, CODE
...
Since the .text sections are empty (size of 0 bytes) and won't be
loaded by the kernel module loader anyway, I don't see a reason
why such sections need to be listed under
/sys/module/<module_name>/sections/<section_name> either.
The attached patch does solve this issue by not exporting section
names which are empty.
This fixes bugzilla http://bugzilla.kernel.org/show_bug.cgi?id=14703
Signed-off-by: Helge Deller <deller@gmx.de>
CC: rusty@rustcorp.com.au
CC: akpm@linux-foundation.org
CC: James.Bottomley@HansenPartnership.com
CC: roland@redhat.com
CC: dave@hiauly1.hia.nrc.ca
diff --git a/kernel/module.c b/kernel/module.c
index 8b7d880..5842a71 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1187,7 +1187,8 @@ 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)
+ if (sechdrs[i].sh_flags & SHF_ALLOC
+ && sechdrs[i].sh_size)
nloaded++;
size[0] = ALIGN(sizeof(*sect_attrs)
+ nloaded * sizeof(sect_attrs->attrs[0]),
@@ -1207,6 +1208,8 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect,
for (i = 0; i < nsect; i++) {
if (! (sechdrs[i].sh_flags & SHF_ALLOC))
continue;
+ if (!sechdrs[i].sh_size)
+ continue;
sattr->address = sechdrs[i].sh_addr;
sattr->name = kstrdup(secstrings + sechdrs[i].sh_name,
GFP_KERNEL);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] modules: don't export section names of empty sections via sysfs
2009-12-02 23:29 [PATCH] modules: don't export section names of empty sections via sysfs Helge Deller
@ 2009-12-03 7:20 ` Rusty Russell
2009-12-03 14:08 ` James Bottomley
2009-12-03 14:21 ` Kyle McMartin
0 siblings, 2 replies; 4+ messages in thread
From: Rusty Russell @ 2009-12-03 7:20 UTC (permalink / raw)
To: Helge Deller
Cc: linux-kernel, linux-parisc, kyle, akpm, James.Bottomley, roland,
dave, torvalds
On Thu, 3 Dec 2009 09:59:15 am Helge Deller wrote:
> [PATCH] modules: don't export section names of empty sections via sysfs
Thanks, applied.
Ah, I see Linus snuck this in before the release. Excellent.
Rusty.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] modules: don't export section names of empty sections via sysfs
2009-12-03 7:20 ` Rusty Russell
@ 2009-12-03 14:08 ` James Bottomley
2009-12-03 14:21 ` Kyle McMartin
1 sibling, 0 replies; 4+ messages in thread
From: James Bottomley @ 2009-12-03 14:08 UTC (permalink / raw)
To: Rusty Russell
Cc: Helge Deller, linux-kernel, linux-parisc, kyle, akpm, roland,
dave, torvalds
On Thu, 2009-12-03 at 17:50 +1030, Rusty Russell wrote:
> On Thu, 3 Dec 2009 09:59:15 am Helge Deller wrote:
> > [PATCH] modules: don't export section names of empty sections via sysfs
>
> Thanks, applied.
>
> Ah, I see Linus snuck this in before the release. Excellent.
That's great. The next step is probably to find out why the toolchain
is doing this ... generating zero length allocated segments seems to be
somewhat deviant behaviour ...
James
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] modules: don't export section names of empty sections via sysfs
2009-12-03 7:20 ` Rusty Russell
2009-12-03 14:08 ` James Bottomley
@ 2009-12-03 14:21 ` Kyle McMartin
1 sibling, 0 replies; 4+ messages in thread
From: Kyle McMartin @ 2009-12-03 14:21 UTC (permalink / raw)
To: Rusty Russell
Cc: Helge Deller, linux-kernel, linux-parisc, kyle, akpm,
James.Bottomley, roland, dave, torvalds
On Thu, Dec 03, 2009 at 05:50:41PM +1030, Rusty Russell wrote:
> On Thu, 3 Dec 2009 09:59:15 am Helge Deller wrote:
> > [PATCH] modules: don't export section names of empty sections via sysfs
>
> Thanks, applied.
>
> Ah, I see Linus snuck this in before the release. Excellent.
> Rusty.
>
Thanks Rusty, Helge!
cheers, Kyle
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-12-03 14:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-02 23:29 [PATCH] modules: don't export section names of empty sections via sysfs Helge Deller
2009-12-03 7:20 ` Rusty Russell
2009-12-03 14:08 ` James Bottomley
2009-12-03 14:21 ` Kyle McMartin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox