aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorIan S. Nelson <nelsonian@comcast.net>2006-09-29 05:01:31 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:23 -0400
commit04b1db9fd7eea63c9663072feece616ea41b0a79 (patch)
tree70b92bf4040acbad744970b82432caac768c2658 /kernel
parent3b5e0cbb4fb6e2a599d72652f56a9acb6af16bcf (diff)
[PATCH] /sys/modules: allow full length section names
I've been using systemtap for some debugging and I noticed that it can't probe a lot of modules. Turns out it's kind of silly, the sections section of /sys/module is limited to 32byte filenames and many of the actual sections are a a bit longer than that. [akpm@osdl.org: rewrite to use dymanic allocation] Cc: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/kernel/module.c b/kernel/module.c
index b7fe6e840963..05625d5dc758 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -933,6 +933,15 @@ static ssize_t module_sect_show(struct module_attribute *mattr,
933 return sprintf(buf, "0x%lx\n", sattr->address); 933 return sprintf(buf, "0x%lx\n", sattr->address);
934} 934}
935 935
936static void free_sect_attrs(struct module_sect_attrs *sect_attrs)
937{
938 int section;
939
940 for (section = 0; section < sect_attrs->nsections; section++)
941 kfree(sect_attrs->attrs[section].name);
942 kfree(sect_attrs);
943}
944
936static void add_sect_attrs(struct module *mod, unsigned int nsect, 945static void add_sect_attrs(struct module *mod, unsigned int nsect,
937 char *secstrings, Elf_Shdr *sechdrs) 946 char *secstrings, Elf_Shdr *sechdrs)
938{ 947{
@@ -949,21 +958,26 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect,
949 + nloaded * sizeof(sect_attrs->attrs[0]), 958 + nloaded * sizeof(sect_attrs->attrs[0]),
950 sizeof(sect_attrs->grp.attrs[0])); 959 sizeof(sect_attrs->grp.attrs[0]));
951 size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.attrs[0]); 960 size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.attrs[0]);
952 if (! (sect_attrs = kmalloc(size[0] + size[1], GFP_KERNEL))) 961 sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL);
962 if (sect_attrs == NULL)
953 return; 963 return;
954 964
955 /* Setup section attributes. */ 965 /* Setup section attributes. */
956 sect_attrs->grp.name = "sections"; 966 sect_attrs->grp.name = "sections";
957 sect_attrs->grp.attrs = (void *)sect_attrs + size[0]; 967 sect_attrs->grp.attrs = (void *)sect_attrs + size[0];
958 968
969 sect_attrs->nsections = 0;
959 sattr = &sect_attrs->attrs[0]; 970 sattr = &sect_attrs->attrs[0];
960 gattr = &sect_attrs->grp.attrs[0]; 971 gattr = &sect_attrs->grp.attrs[0];
961 for (i = 0; i < nsect; i++) { 972 for (i = 0; i < nsect; i++) {
962 if (! (sechdrs[i].sh_flags & SHF_ALLOC)) 973 if (! (sechdrs[i].sh_flags & SHF_ALLOC))
963 continue; 974 continue;
964 sattr->address = sechdrs[i].sh_addr; 975 sattr->address = sechdrs[i].sh_addr;
965 strlcpy(sattr->name, secstrings + sechdrs[i].sh_name, 976 sattr->name = kstrdup(secstrings + sechdrs[i].sh_name,
966 MODULE_SECT_NAME_LEN); 977 GFP_KERNEL);
978 if (sattr->name == NULL)
979 goto out;
980 sect_attrs->nsections++;
967 sattr->mattr.show = module_sect_show; 981 sattr->mattr.show = module_sect_show;
968 sattr->mattr.store = NULL; 982 sattr->mattr.store = NULL;
969 sattr->mattr.attr.name = sattr->name; 983 sattr->mattr.attr.name = sattr->name;
@@ -979,7 +993,7 @@ static void add_sect_attrs(struct module *mod, unsigned int nsect,
979 mod->sect_attrs = sect_attrs; 993 mod->sect_attrs = sect_attrs;
980 return; 994 return;
981 out: 995 out:
982 kfree(sect_attrs); 996 free_sect_attrs(sect_attrs);
983} 997}
984 998
985static void remove_sect_attrs(struct module *mod) 999static void remove_sect_attrs(struct module *mod)
@@ -989,13 +1003,13 @@ static void remove_sect_attrs(struct module *mod)
989 &mod->sect_attrs->grp); 1003 &mod->sect_attrs->grp);
990 /* We are positive that no one is using any sect attrs 1004 /* We are positive that no one is using any sect attrs
991 * at this point. Deallocate immediately. */ 1005 * at this point. Deallocate immediately. */
992 kfree(mod->sect_attrs); 1006 free_sect_attrs(mod->sect_attrs);
993 mod->sect_attrs = NULL; 1007 mod->sect_attrs = NULL;
994 } 1008 }
995} 1009}
996 1010
997
998#else 1011#else
1012
999static inline void add_sect_attrs(struct module *mod, unsigned int nsect, 1013static inline void add_sect_attrs(struct module *mod, unsigned int nsect,
1000 char *sectstrings, Elf_Shdr *sechdrs) 1014 char *sectstrings, Elf_Shdr *sechdrs)
1001{ 1015{