[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LSU.2.21.2202161601010.1475@pobox.suse.cz>
Date: Wed, 16 Feb 2022 16:06:24 +0100 (CET)
From: Miroslav Benes <mbenes@...e.cz>
To: Josh Poimboeuf <jpoimboe@...hat.com>
cc: Alexander Lobakin <alexandr.lobakin@...el.com>,
linux-hardening@...r.kernel.org, x86@...nel.org,
Borislav Petkov <bp@...en8.de>,
Jesse Brandeburg <jesse.brandeburg@...el.com>,
Kristen Carlson Accardi <kristen@...ux.intel.com>,
Kees Cook <keescook@...omium.org>,
Miklos Szeredi <miklos@...redi.hu>,
Ard Biesheuvel <ardb@...nel.org>,
Tony Luck <tony.luck@...el.com>,
Bruce Schlobohm <bruce.schlobohm@...el.com>,
Jessica Yu <jeyu@...nel.org>,
kernel test robot <lkp@...el.com>,
Evgenii Shatokhin <eshatokhin@...tuozzo.com>,
Jonathan Corbet <corbet@....net>,
Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
"David S. Miller" <davem@...emloft.net>,
Thomas Gleixner <tglx@...utronix.de>,
Will Deacon <will@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Christoph Hellwig <hch@....de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Arnd Bergmann <arnd@...db.de>,
Nathan Chancellor <nathan@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Marios Pomonis <pomonis@...gle.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
"H.J. Lu" <hjl.tools@...il.com>, Nicolas Pitre <nico@...xnic.net>,
linux-kernel@...r.kernel.org, linux-kbuild@...r.kernel.org,
linux-arch@...r.kernel.org, live-patching@...r.kernel.org,
llvm@...ts.linux.dev
Subject: Re: [PATCH v10 02/15] livepatch: avoid position-based search if `-z
unique-symbol` is available
> > +++ b/kernel/livepatch/core.c
> > @@ -143,11 +143,13 @@ static int klp_find_callback(void *data, const char *name,
> > args->count++;
> >
> > /*
> > - * Finish the search when the symbol is found for the desired position
> > - * or the position is not defined for a non-unique symbol.
> > + * Finish the search when unique symbol names are enabled
> > + * or the symbol is found for the desired position or the
> > + * position is not defined for a non-unique symbol.
> > */
> > - if ((args->pos && (args->count == args->pos)) ||
> > - (!args->pos && (args->count > 1)))
> > + if (IS_ENABLED(CONFIG_LD_HAS_Z_UNIQUE_SYMBOL) ||
> > + (args->pos && args->count == args->pos) ||
> > + (!args->pos && args->count > 1))
> > return 1;
>
> There's no real need to do this. The code already works as-is, even if
> there are no unique symbols.
>
> Even if there are no duplicates, there's little harm in going through
> all the symbols anyway, to check for errors just in case something
> unexpected happened with the linking (unexpected duplicate) or the patch
> creation (unexpected sympos). It's not a hot path, so performance isn't
> really a concern.
Correct.
> When the old linker versions eventually age out, we can then go strip
> out all the sympos stuff.
Yes.
> > @@ -169,6 +171,13 @@ static int klp_find_object_symbol(const char *objname, const char *name,
> > else
> > kallsyms_on_each_symbol(klp_find_callback, &args);
> >
> > + /*
> > + * If the LD's `-z unique-symbol` flag is available and enabled,
> > + * sympos checks are not relevant.
> > + */
> > + if (IS_ENABLED(CONFIG_LD_HAS_Z_UNIQUE_SYMBOL))
> > + sympos = 0;
> > +
>
> Similarly, I don't see a need for this. If the patch is legit then
> sympos should already be zero. If not, an error gets reported and the
> patch fails to load.
My concern was that if the patch is not legit (that is, sympos is > 0 for
some reason), the error would be really cryptic and would not help the
user at all. So zeroing sympos seems to be a good idea to me. There is no
harm and the change is very small and compact.
On the other hand, I do not insist on this.
Regards,
Miroslav
Powered by blists - more mailing lists