Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758789AbZLGAUX (ORCPT ); Sun, 6 Dec 2009 19:20:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758611AbZLGATz (ORCPT ); Sun, 6 Dec 2009 19:19:55 -0500 Received: from kroah.org ([198.145.64.141]:34695 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758543AbZLGANv (ORCPT ); Sun, 6 Dec 2009 19:13:51 -0500 X-Mailbox-Line: From gregkh@mini.kroah.org Sun Dec 6 16:06:57 2009 Message-Id: <20091207000657.341233965@mini.kroah.org> User-Agent: quilt/0.48-1 Date: Sun, 06 Dec 2009 16:01:10 -0800 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: stable-review@kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Helge Deller , rusty@rustcorp.com.au, James.Bottomley@HansenPartnership.com, roland@redhat.com, dave@hiauly1.hia.nrc.ca Subject: [094/119] modules: dont export section names of empty sections via sysfs References: <20091206235936.208334321@mini.kroah.org> Content-Disposition: inline; filename=modules-don-t-export-section-names-of-empty-sections-via-sysfs.patch In-Reply-To: <20091207000938.GA24743@kroah.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2961 Lines: 70 2.6.31-stable review patch. If anyone has any objections, please let us know. ------------------ From: Helge Deller commit 35dead4235e2b67da7275b4122fed37099c2f462 upstream. 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//sections/ 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 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 Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- kernel/module.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/kernel/module.c +++ b/kernel/module.c @@ -1179,7 +1179,8 @@ static void add_sect_attrs(struct module /* 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]), @@ -1199,6 +1200,8 @@ static void add_sect_attrs(struct module 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); -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/