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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <08657a8071475e802dd63e3392338a8f950b61bb.1725334260.git.jpoimboe@kernel.org>
Date: Mon,  2 Sep 2024 20:59:56 -0700
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: live-patching@...r.kernel.org
Cc: linux-kernel@...r.kernel.org,
	x86@...nel.org,
	Miroslav Benes <mbenes@...e.cz>,
	Petr Mladek <pmladek@...e.com>,
	Joe Lawrence <joe.lawrence@...hat.com>,
	Jiri Kosina <jikos@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Marcos Paulo de Souza <mpdesouza@...e.com>,
	Song Liu <song@...nel.org>
Subject: [RFC 13/31] objtool: Support references to all symbol types in special sections

Make the code simpler and more flexible.

Signed-off-by: Josh Poimboeuf <jpoimboe@...nel.org>
---
 tools/objtool/check.c | 74 +++++++++----------------------------------
 1 file changed, 15 insertions(+), 59 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 92171ce458ec..9212b5edffc8 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -595,15 +595,7 @@ static int add_dead_ends(struct objtool_file *file)
 		goto reachable;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type == STT_SECTION) {
-			offset = reloc_addend(reloc);
-		} else if (reloc->sym->local_label) {
-			offset = reloc->sym->offset;
-		} else {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
-
+		offset = reloc->sym->offset + reloc_addend(reloc);
 		insn = find_insn(file, reloc->sym->sec, offset);
 		if (insn)
 			insn = prev_insn_same_sec(file, insn);
@@ -635,15 +627,7 @@ static int add_dead_ends(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type == STT_SECTION) {
-			offset = reloc_addend(reloc);
-		} else if (reloc->sym->local_label) {
-			offset = reloc->sym->offset;
-		} else {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
-
+		offset = reloc->sym->offset + reloc_addend(reloc);
 		insn = find_insn(file, reloc->sym->sec, offset);
 		if (insn)
 			insn = prev_insn_same_sec(file, insn);
@@ -1274,12 +1258,9 @@ static int add_ignore_alternatives(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type != STT_SECTION) {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.ignore_alts entry");
 			return -1;
@@ -2255,15 +2236,7 @@ static int read_unwind_hints(struct objtool_file *file)
 			return -1;
 		}
 
-		if (reloc->sym->type == STT_SECTION) {
-			offset = reloc_addend(reloc);
-		} else if (reloc->sym->local_label) {
-			offset = reloc->sym->offset;
-		} else {
-			WARN("unexpected relocation symbol type in %s", sec->rsec->name);
-			return -1;
-		}
-
+		offset = reloc->sym->offset + reloc_addend(reloc);
 		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("can't find insn for unwind_hints[%d]", i);
@@ -2356,12 +2329,9 @@ static int read_retpoline_hints(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type != STT_SECTION) {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.retpoline_safe entry");
 			return -1;
@@ -2392,12 +2362,9 @@ static int read_instr_hints(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type != STT_SECTION) {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.instr_end entry");
 			return -1;
@@ -2411,12 +2378,9 @@ static int read_instr_hints(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type != STT_SECTION) {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.instr_begin entry");
 			return -1;
@@ -2439,12 +2403,9 @@ static int read_validate_unret_hints(struct objtool_file *file)
 		return 0;
 
 	for_each_reloc(rsec, reloc) {
-		if (reloc->sym->type != STT_SECTION) {
-			WARN("unexpected relocation symbol type in %s", rsec->name);
-			return -1;
-		}
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.instr_end entry");
 			return -1;
@@ -2468,14 +2429,9 @@ static int read_intra_function_calls(struct objtool_file *file)
 
 	for_each_reloc(rsec, reloc) {
 		unsigned long dest_off;
+		unsigned long offset = reloc->sym->offset + reloc_addend(reloc);
 
-		if (!is_section_symbol(reloc->sym)) {
-			WARN("unexpected relocation symbol type in %s",
-			     rsec->name);
-			return -1;
-		}
-
-		insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
+		insn = find_insn(file, reloc->sym->sec, offset);
 		if (!insn) {
 			WARN("bad .discard.intra_function_call entry");
 			return -1;
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ