Skip to content

Commit

Permalink
Merge pull request torvalds#589 from ojeda/kallsyms
Browse files Browse the repository at this point in the history
kernel: kallsyms: fix advance through markers
  • Loading branch information
ojeda authored Dec 5, 2021
2 parents 3be16cd + 3399bcb commit 24ed7ed
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions kernel/kallsyms.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static char kallsyms_get_symbol_type(unsigned int off)
static unsigned int get_symbol_offset(unsigned long pos)
{
const u8 *name;
int i;
int i, len;

/*
* Use the closest marker we have. We have markers every 256 positions,
Expand All @@ -149,8 +149,18 @@ static unsigned int get_symbol_offset(unsigned long pos)
* so we just need to add the len to the current pointer for every
* symbol we wish to skip.
*/
for (i = 0; i < (pos & 0xFF); i++)
name = name + (*name) + 1;
for (i = 0; i < (pos & 0xFF); i++) {
len = *name;

/*
* If MSB is 1, it is a "big" symbol, so we need to look into
* the next byte (and skip it, too).
*/
if ((len & 0x80) != 0)
len = ((len & 0x7F) | (name[1] << 7)) + 1;

name = name + len + 1;
}

return name - kallsyms_names;
}
Expand Down

0 comments on commit 24ed7ed

Please sign in to comment.