linux-brain/scripts
Alex Sverdlin bb4768b058 ARM: 8950/1: ftrace/recordmcount: filter relocation types
commit 927d780ee371d7e121cea4fc7812f6ef2cea461c upstream.

Scenario 1, ARMv7
=================

If code in arch/arm/kernel/ftrace.c would operate on mcount() pointer
the following may be generated:

00000230 <prealloc_fixed_plts>:
 230:   b5f8            push    {r3, r4, r5, r6, r7, lr}
 232:   b500            push    {lr}
 234:   f7ff fffe       bl      0 <__gnu_mcount_nc>
                        234: R_ARM_THM_CALL     __gnu_mcount_nc
 238:   f240 0600       movw    r6, #0
                        238: R_ARM_THM_MOVW_ABS_NC      __gnu_mcount_nc
 23c:   f8d0 1180       ldr.w   r1, [r0, #384]  ; 0x180

FTRACE currently is not able to deal with it:

WARNING: CPU: 0 PID: 0 at .../kernel/trace/ftrace.c:1979 ftrace_bug+0x1ad/0x230()
...
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.4.116-... #1
...
[<c0314e3d>] (unwind_backtrace) from [<c03115e9>] (show_stack+0x11/0x14)
[<c03115e9>] (show_stack) from [<c051a7f1>] (dump_stack+0x81/0xa8)
[<c051a7f1>] (dump_stack) from [<c0321c5d>] (warn_slowpath_common+0x69/0x90)
[<c0321c5d>] (warn_slowpath_common) from [<c0321cf3>] (warn_slowpath_null+0x17/0x1c)
[<c0321cf3>] (warn_slowpath_null) from [<c038ee9d>] (ftrace_bug+0x1ad/0x230)
[<c038ee9d>] (ftrace_bug) from [<c038f1f9>] (ftrace_process_locs+0x27d/0x444)
[<c038f1f9>] (ftrace_process_locs) from [<c08915bd>] (ftrace_init+0x91/0xe8)
[<c08915bd>] (ftrace_init) from [<c0885a67>] (start_kernel+0x34b/0x358)
[<c0885a67>] (start_kernel) from [<00308095>] (0x308095)
---[ end trace cb88537fdc8fa200 ]---
ftrace failed to modify [<c031266c>] prealloc_fixed_plts+0x8/0x60
 actual: 44:f2:e1:36
ftrace record flags: 0
 (0)   expected tramp: c03143e9

Scenario 2, ARMv4T
==================

ftrace: allocating 14435 entries in 43 pages
------------[ cut here ]------------
WARNING: CPU: 0 PID: 0 at kernel/trace/ftrace.c:2029 ftrace_bug+0x204/0x310
CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.5 #1
Hardware name: Cirrus Logic EDB9302 Evaluation Board
[<c0010a24>] (unwind_backtrace) from [<c000ecb0>] (show_stack+0x20/0x2c)
[<c000ecb0>] (show_stack) from [<c03c72e8>] (dump_stack+0x20/0x30)
[<c03c72e8>] (dump_stack) from [<c0021c18>] (__warn+0xdc/0x104)
[<c0021c18>] (__warn) from [<c0021d7c>] (warn_slowpath_null+0x4c/0x5c)
[<c0021d7c>] (warn_slowpath_null) from [<c0095360>] (ftrace_bug+0x204/0x310)
[<c0095360>] (ftrace_bug) from [<c04dabac>] (ftrace_init+0x3b4/0x4d4)
[<c04dabac>] (ftrace_init) from [<c04cef4c>] (start_kernel+0x20c/0x410)
[<c04cef4c>] (start_kernel) from [<00000000>] (  (null))
---[ end trace 0506a2f5dae6b341 ]---
ftrace failed to modify
[<c000c350>] perf_trace_sys_exit+0x5c/0xe8
 actual:   1e:ff:2f:e1
Initializing ftrace call sites
ftrace record flags: 0
 (0)
 expected tramp: c000fb24

The analysis for this problem has been already performed previously,
refer to the link below.

Fix the above problems by allowing only selected reloc types in
__mcount_loc. The list itself comes from the legacy recordmcount.pl
script.

Link: https://lore.kernel.org/lkml/56961010.6000806@pengutronix.de/
Cc: stable@vger.kernel.org
Fixes: ed60453fa8 ("ARM: 6511/1: ftrace: add ARM support for C version of recordmcount")
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-01-29 15:02:37 +01:00
..
basic
coccinelle fs: stream_open - opener for stream-like files so that read and write can run simultaneously without deadlock 2019-06-11 12:21:51 +02:00
dtc
gcc-plugins randstruct: Check member structs in is_pure_ops_struct() 2019-10-05 12:48:05 +02:00
gdb scripts/gdb: fix debugging modules compiled with hot/cold partitioning 2019-12-05 15:37:04 +01:00
genksyms
kconfig kconfig: don't crash on NULL expressions in expr_eq() 2020-01-12 12:11:58 +01:00
ksymoops
mod modpost: skip ELF local symbols during section mismatch check 2019-12-17 20:38:30 +01:00
package builddeb: Fix header package regarding dtc source links 2018-05-30 07:52:21 +02:00
selinux selinux: use kernel linux/socket.h for genheaders and mdp 2019-05-04 09:15:17 +02:00
tracing
.gitignore
Kbuild.include kbuild: simplify ld-option implementation 2019-05-02 09:40:27 +02:00
Lindent
Makefile
Makefile.asm-generic
Makefile.build ftrace: Build with CPPFLAGS to get -Qunused-arguments 2019-01-13 10:01:03 +01:00
Makefile.clean
Makefile.dtbinst
Makefile.extrawarn Kbuild: suppress packed-not-aligned warning for default setting only 2018-12-08 13:03:34 +01:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.help
Makefile.host
Makefile.kasan
Makefile.lib
Makefile.modbuiltin
Makefile.modinst
Makefile.modpost kbuild: modpost: handle KBUILD_EXTRA_SYMBOLS only for external modules 2019-08-25 10:50:14 +02:00
Makefile.modsign
Makefile.ubsan
adjust_autoksyms.sh
asn1_compiler.c
bloat-o-meter
bootgraph.pl
check_00index.sh
check_extable.sh
checkincludes.pl
checkkconfigsymbols.py
checkpatch.pl
checkstack.pl scripts/checkstack.pl: Fix arm64 wrong or unknown architecture 2019-06-25 11:36:53 +08:00
checksyscalls.sh
checkversion.pl
cleanfile
cleanpatch
coccicheck
config
conmakehash.c
const_structs.checkpatch
decode_stacktrace.sh scripts/decode_stacktrace: match basepath using shell prefix operator, not regex 2019-09-16 08:20:46 +02:00
decodecode
depmod.sh kbuild: make missing $DEPMOD a Warning instead of an Error 2018-09-15 09:45:36 +02:00
diffconfig
export_report.pl
extract-cert.c
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
extract_xc3028.pl
faddr2line
gcc-goto.sh
gcc-ld
gcc-plugin.sh
gcc-version.sh
gcc-x86_32-has-stack-protector.sh
gcc-x86_64-has-stack-protector.sh
gen_initramfs_list.sh
get_dvb_firmware
get_maintainer.pl
gfp-translate
headerdep.pl
headers.sh
headers_check.pl
headers_install.sh
insert-sys-cert.c
kallsyms.c scripts/kallsyms: fix definitely-lost memory leak 2020-01-04 13:59:51 +01:00
kernel-doc
ld-version.sh
leaking_addresses.pl
link-vmlinux.sh
makelst
markup_oops.pl
mkcompile_h
mkmakefile
mksysmap
mkuboot.sh
module-common.lds
namespace.pl namespace: fix namespace.pl script to support relative paths 2019-10-29 09:16:59 +01:00
objdiff
parse-maintainers.pl
patch-kernel
pnmtologo.c
profile2linkerlist.pl
prune-kernel
recordmcount.c ARM: 8950/1: ftrace/recordmcount: filter relocation types 2020-01-29 15:02:37 +01:00
recordmcount.h recordmcount: Fix spurious mcount entries on powerpc 2019-07-31 07:28:53 +02:00
recordmcount.pl
setlocalversion scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks 2019-11-06 12:42:55 +01:00
show_delta
sign-file.c
sortextable.c
sortextable.h
spelling.txt
sphinx-pre-install scripts/sphinx-pre-install: fix script for RHEL/CentOS 2019-08-16 10:13:51 +02:00
stackdelta
stackusage
tags.sh
unifdef.c unifdef: use memcpy instead of strncpy 2018-12-08 13:03:35 +01:00
ver_linux
xen-hypercalls.sh
xz_wrap.sh