Skip to content

Commit 5ebddd7

Browse files
author
Peter Zijlstra
committed
kallsyms: Revert "Take callthunks into account"
This is a full revert of commit: f138918 ("kallsyms: Take callthunks into account") The commit assumes a number of things that are not quite right. Notably it assumes every symbol has PADDING_BYTES in front of it that are not claimed by another symbol. This is not true; even when compiled with: -fpatchable-function-entry=${PADDING_BYTES},${PADDING_BYTES} Notably things like .cold subfunctions do not need to adhere to this change in ABI. It it also not true when build with CFI_CLANG, which claims these PADDING_BYTES in the __cfi_##name symbol. Once the prefix bytes are not consistent and or otherwise claimed the approach this patch takes goes out the window and kallsym resolution will report invalid symbol names. Therefore revert this to make room for another approach. Reported-by: Reported-by: kernel test robot <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Tested-by: Yujie Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent b1f37ef commit 5ebddd7

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

kernel/kallsyms.c

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -293,38 +293,20 @@ static unsigned long get_symbol_pos(unsigned long addr,
293293
return low;
294294
}
295295

296-
#ifdef CONFIG_FUNCTION_PADDING_BYTES
297-
#define PADDING_BYTES CONFIG_FUNCTION_PADDING_BYTES
298-
#else
299-
#define PADDING_BYTES 0
300-
#endif
301-
302296
/*
303297
* Lookup an address but don't bother to find any names.
304298
*/
305299
int kallsyms_lookup_size_offset(unsigned long addr, unsigned long *symbolsize,
306300
unsigned long *offset)
307301
{
308302
char namebuf[KSYM_NAME_LEN];
309-
int ret;
310-
311-
addr += PADDING_BYTES;
312303

313304
if (is_ksym_addr(addr)) {
314305
get_symbol_pos(addr, symbolsize, offset);
315-
ret = 1;
316-
goto found;
317-
}
318-
319-
ret = !!module_address_lookup(addr, symbolsize, offset, NULL, NULL, namebuf);
320-
if (!ret) {
321-
ret = !!__bpf_address_lookup(addr, symbolsize,
322-
offset, namebuf);
306+
return 1;
323307
}
324-
found:
325-
if (ret && offset)
326-
*offset -= PADDING_BYTES;
327-
return ret;
308+
return !!module_address_lookup(addr, symbolsize, offset, NULL, NULL, namebuf) ||
309+
!!__bpf_address_lookup(addr, symbolsize, offset, namebuf);
328310
}
329311

330312
static const char *kallsyms_lookup_buildid(unsigned long addr,
@@ -337,8 +319,6 @@ static const char *kallsyms_lookup_buildid(unsigned long addr,
337319
namebuf[KSYM_NAME_LEN - 1] = 0;
338320
namebuf[0] = 0;
339321

340-
addr += PADDING_BYTES;
341-
342322
if (is_ksym_addr(addr)) {
343323
unsigned long pos;
344324

@@ -368,8 +348,6 @@ static const char *kallsyms_lookup_buildid(unsigned long addr,
368348

369349
found:
370350
cleanup_symbol_name(namebuf);
371-
if (ret && offset)
372-
*offset -= PADDING_BYTES;
373351
return ret;
374352
}
375353

@@ -396,8 +374,6 @@ int lookup_symbol_name(unsigned long addr, char *symname)
396374
symname[0] = '\0';
397375
symname[KSYM_NAME_LEN - 1] = '\0';
398376

399-
addr += PADDING_BYTES;
400-
401377
if (is_ksym_addr(addr)) {
402378
unsigned long pos;
403379

@@ -425,8 +401,6 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
425401
name[0] = '\0';
426402
name[KSYM_NAME_LEN - 1] = '\0';
427403

428-
addr += PADDING_BYTES;
429-
430404
if (is_ksym_addr(addr)) {
431405
unsigned long pos;
432406

@@ -443,8 +417,6 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size,
443417
return res;
444418

445419
found:
446-
if (offset)
447-
*offset -= PADDING_BYTES;
448420
cleanup_symbol_name(name);
449421
return 0;
450422
}
@@ -470,15 +442,8 @@ static int __sprint_symbol(char *buffer, unsigned long address,
470442
len = strlen(buffer);
471443
offset -= symbol_offset;
472444

473-
if (add_offset) {
474-
char s = '+';
475-
476-
if ((long)offset < 0) {
477-
s = '-';
478-
offset = 0UL - offset;
479-
}
480-
len += sprintf(buffer + len, "%c%#lx/%#lx", s, offset, size);
481-
}
445+
if (add_offset)
446+
len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);
482447

483448
if (modname) {
484449
len += sprintf(buffer + len, " [%s", modname);

0 commit comments

Comments
 (0)