lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat,  8 Aug 2020 19:38:32 -0400
From:   Sasha Levin <>
Cc:     Gregory Herrero <>,
        Steven Rostedt <>,
        Catalin Marinas <>,
        Sasha Levin <>
Subject: [PATCH AUTOSEL 5.4 28/40] recordmcount: only record relocation of type R_AARCH64_CALL26 on arm64.

From: Gregory Herrero <>

[ Upstream commit ea0eada45632f4807b2f49de951072283e2d781c ]

Currently, if a section has a relocation to '_mcount' symbol, a new
__mcount_loc entry will be added whatever the relocation type is.
This is problematic when a relocation to '_mcount' is in the middle of a
section and is not a call for ftrace use.

Such relocation could be generated with below code for example:
    bool is_mcount(unsigned long addr)
        return (target == (unsigned long) &_mcount);

With this snippet of code, ftrace will try to patch the mcount location
generated by this code on module load and fail with:

    Call trace:
    ---[ end trace d828d06b36ad9d59 ]---
    ftrace failed to modify
    [<ffffa2dbf3a3a41c>] 0xffffa2dbf3a3a41c
     actual:   66:a9:3c:90
    Initializing ftrace call sites
    ftrace record flags: 2000000
    expected tramp: ffffa2dc6cf66724

So Limit the relocation type to R_AARCH64_CALL26 as in perl version of

Fixes: af64d2aa872a ("ftrace: Add arm64 support to recordmcount")
Signed-off-by: Gregory Herrero <>
Acked-by: Steven Rostedt (VMware) <>
Signed-off-by: Catalin Marinas <>
Signed-off-by: Sasha Levin <>
 scripts/recordmcount.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 7225107a9aafe..e59022b3f1254 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -434,6 +434,11 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp)
 	return 1;
+static int arm64_is_fake_mcount(Elf64_Rel const *rp)
+	return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26;
 /* 64-bit EM_MIPS has weird ELF64_Rela.r_info.
  * We interpret Table 29 Relocation Operation (Elf64_Rel, Elf64_Rela) [p.40]
@@ -547,6 +552,7 @@ static int do_file(char const *const fname)
 		make_nop = make_nop_arm64;
 		rel_type_nop = R_AARCH64_NONE;
 		ideal_nop = ideal_nop4_arm64;
+		is_fake_mcount64 = arm64_is_fake_mcount;
 	case EM_IA_64:	reltype = R_IA64_IMM64; break;
 	case EM_MIPS:	/* reltype: e_class    */ break;

Powered by blists - more mailing lists