All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Kees Cook <keescook@chromium.org>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: [PATCH v2] objtool: Report section name in elf_init_reloc_text_sym() warning
Date: Mon,  6 May 2024 08:55:54 -0700	[thread overview]
Message-ID: <20240506155537.it.760-kees@kernel.org> (raw)

While tracking down issues with LKDTM's .rodata "function", I found
the warning from elf_init_reloc_text_sym() to be unhelpful because it
wasn't clear which calling path it was coming from. Report the sec->name
and rephrase the warning a bit. Additionally check for NULL sym->name,
which may happen.

Before:

vmlinux.o: warning: objtool: bad call to elf_init_reloc_text_sym() for data symbol .rodata

After:

vmlinux.o: warning: objtool: .cfi_sites: unexpected reference to non-executable symbol '.rodata'

Signed-off-by: Kees Cook <keescook@chromium.org>
---
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
 v1: https://lore.kernel.org/lkml/20240430235106.work.680-kees@kernel.org/
---
 tools/objtool/elf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 3d27983dc908..b38cedd4fd55 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -891,8 +891,8 @@ struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec,
 	int addend = insn_off;
 
 	if (!(insn_sec->sh.sh_flags & SHF_EXECINSTR)) {
-		WARN("bad call to %s() for data symbol %s",
-		     __func__, sym->name);
+		WARN("%s: unexpected reference to non-executable symbol '%s'",
+		     sec->name, sym->name ?: "<unknown>");
 		return NULL;
 	}
 
-- 
2.34.1


             reply	other threads:[~2024-05-06 15:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 15:55 Kees Cook [this message]
2024-05-07  3:24 ` [PATCH v2] objtool: Report section name in elf_init_reloc_text_sym() warning Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240506155537.it.760-kees@kernel.org \
    --to=keescook@chromium.org \
    --cc=jpoimboe@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.