scripts/sorttable: ftrace: Fix some bugs with sorttable and ARM 64
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | ftrace: Test mcount_loc addr before calling ftrace_call_addr()kernel/ | +5 | 0 replies | |
| 2/4 | ftrace: Check against is_kernel_text() instead of kaslr_offset()kernel/ | +12 | 0 replies | |
| 3/4 | scripts/sorttable: Use normal sort if theres no relocs in the mcount sectionscripts/ | +7 | 0 replies | |
| 4/4 | scripts/sorttable: Allow matches to functions before function entryscripts/ | +6 | 0 replies |
Reviews trailers per patch
None of the 4 patches has a Reviewed-by or Acked-by.
| Patch | Nathan Chancellor |
|---|---|
| 1/4 | T-b |
| 2/4 | T-b |
| 3/4 | T-b |
| 4/4 | T-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH 0/4] scripts/sorttable: ftrace: Fix some bugs with sorttable and ARM 64
A few bugs with ARM 64 has been reported with the removal of the unused weak functions code.
One was that kaslr_offset() may not be defined by all architectures and it's reference would cause the build to fail. This was fixed by removing the kaslr_offset() to check valid mcount_loc addresses and use the is_kernel_text() instead.
Another was that clang doesn't do the trick of storing the mcount_loc addresses in the Elf_Rela sections like gcc does. Clang does it like other achitectures do. To handle this, the Elf_Rela is first used but no functions were found there, it then falls back to the same code that all the other architectures use.
When reading the mcount_loc and creating the ftrace descriptors, the architecture specific function ftrace_call_addr() is called on the address from the mcount_loc. But because the unused weak functions were zeroed out, but KASLR can still modify them, it can make the address invalid. The ftrace_call_addr() from ARM 64 will crash if the address passed in is invalid. Have the valid tests done before calling that function.
On bug that was found while debugging this but was not reported was that the test against the nm output to determine if a function is an unused weak function or not was triggering false postives for all functions. That's because the address in mcount_loc for ARM 64 is just before the function entry. The check against nm would see if the address was within the function text, but 8 bytes before is not in the function text and this would cause all the functions to be considered unused weak functions and there would be no function left to trace.
Steven Rostedt (4):
ftrace: Test mcount_loc addr before calling ftrace_call_addr()
ftrace: Check against is_kernel_text() instead of kaslr_offset() scripts/sorttable: Use normal sort if there's no relocs in the mcount section scripts/sorttable: Allow matches to functions before function entry
----
kernel/trace/ftrace.c | 23 +++++++++++++++++------ scripts/sorttable.c | 16 +++++++++++++--- 2 files changed, 30 insertions(+), 9 deletions(-)