[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250716095446.GV905792@noisy.programming.kicks-ass.net>
Date: Wed, 16 Jul 2025 11:54:46 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ard Biesheuvel <ardb+git@...gle.com>
Cc: linux-kernel@...r.kernel.org, linux-efi@...r.kernel.org, x86@...nel.org,
Ard Biesheuvel <ardb@...nel.org>, Borislav Petkov <bp@...en8.de>,
Ingo Molnar <mingo@...nel.org>,
Kevin Loughlin <kevinloughlin@...gle.com>,
Tom Lendacky <thomas.lendacky@....com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Nikunj A Dadhania <nikunj@....com>
Subject: Re: [PATCH v5 15/22] objtool: Add action to check for absence of
absolute relocations
On Wed, Jul 16, 2025 at 05:18:30AM +0200, Ard Biesheuvel wrote:
> index d967ac001498..5d1d38404892 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -4643,6 +4643,39 @@ static void disas_warned_funcs(struct objtool_file *file)
> disas_funcs(funcs);
> }
>
> +static int check_abs_references(struct objtool_file *file)
> +{
> + struct section *sec;
> + struct reloc *reloc;
> + int ret = 0;
> +
> + for_each_sec(file, sec) {
> + /* absolute references in non-loadable sections are fine */
> + if (!(sec->sh.sh_flags & SHF_ALLOC))
> + continue;
> +
> + /* section must have an associated .rela section */
> + if (!sec->rsec)
> + continue;
> +
> + /*
> + * Special case for compiler generated metadata that is not
> + * consumed until after boot.
> + */
> + if (!strcmp(sec->name, "__patchable_function_entries"))
> + continue;
> +
> + for_each_reloc(sec->rsec, reloc) {
> + if (reloc_type(reloc) == R_ABS64) {
This should probably also check R_ABS32. Yes, your current only user is
x86_64 so R_ABS64 covers things, but we're getting more and more archs
using objtool. No reason this check shouldn't also work on PPC32 for
example.
> + WARN("section %s has absolute relocation at offset 0x%lx",
> + sec->name, reloc_offset(reloc));
> + ret++;
> + }
> + }
> + }
> + return ret;
> +}
Powered by blists - more mailing lists