lkml.org 
[lkml]   [2012]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRe: [ 11/83] module: fix out-by-one error in kallsyms
Date
satoru takeuchi <satoru.takeuchi@gmail.com> writes:
> Hi,

Hi!

>> --- a/kernel/module.c
>> +++ b/kernel/module.c
>> @@ -2273,12 +2273,17 @@ static void layout_symtab(struct module
>> 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;
>> +
>
> I suspect above code sniped is not needed since the size of src[0](always 1) is
> counted at the following code("strtab_size += strlen(..) + 1;").

You are correct, on both counts. This was a remnant of the previous
1-based looping.

Here's the fix I have pending.

Thanks!
Rusty.

module: fix one byte kallsyms overallocation.

Since we fixed our kallsyms strtab expansion code in
59ef28b1f14899b10d6b2682c7057ca00a9a3f47 (module: fix out-by-one error
in kallsyms) we now loop from zero, so we don't need to add an extra
byte for the first empty string.

Reported-by: satoru takeuchi <satoru.takeuchi@gmail.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

diff --git a/kernel/module.c b/kernel/module.c
index a1d2ed8..79a526d 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2285,7 +2285,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
Elf_Shdr *symsect = info->sechdrs + info->index.sym;
Elf_Shdr *strsect = info->sechdrs + info->index.str;
const Elf_Sym *src;
- unsigned int i, nsrc, ndst, strtab_size;
+ unsigned int i, nsrc, ndst, strtab_size = 0;

/* Put symbol section at end of init part of module. */
symsect->sh_flags |= SHF_ALLOC;
@@ -2296,9 +2296,6 @@ 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 = 0; i < nsrc; i++) {
if (i == 0 ||
@@ -2340,7 +2337,6 @@ 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;
- *s++ = 0;
for (ndst = i = 0; i < mod->num_symtab; i++) {
if (i == 0 ||
is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum)) {

\
 
 \ /
  Last update: 2012-12-03 04:21    [W:0.418 / U:1.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site