lists.openwall.net   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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210215164446.530f6311@gandalf.local.home>
Date:   Mon, 15 Feb 2021 16:44:46 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     Ingo Molnar <mingo@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: [PATCH] ftrace: Do not reference symbols in sections without size

From: "Steven Rostedt (VMware)" <rostedt@...dmis.org>

Starting with binutils 2.36, sections were being removed if they had weak
functions that were optimized out. Unfortunately, these weak functions would
leave references to mcount/fentry calls, that would make recordmcount fail
to find the symbol that matched the call to fentry.

Before returning the symbol of the section to create the mcount location,
check if that section size is greater than zero. If it has no size, skip
referencing that mcount call location.

Link: https://lore.kernel.org/lkml/YCafKVSTX9MxDBMd@kroah.com/

Cc: stable@...r.kernel.org
[ Backport as far as it can go ]
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Reported-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
 scripts/recordmcount.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index f9b19524da11..1a29f290092d 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -562,7 +562,8 @@ static char const * __has_rel_mcount(Elf_Shdr const *const relhdr, /* reltype */
 	if (w(txthdr->sh_type) != SHT_PROGBITS ||
 	    !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
 		return NULL;
-	return txtname;
+	/* If the section has no size, then it wont be available for reference */
+	return shdr0->sh_size ? txtname : NULL;
 }
 
 static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
-- 
2.25.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ