From: Padmanabha Srinivasaiah <treasure4paddy@gmail.com>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Jessica Yu <jeyu@kernel.org>, Kees Cook <keescook@chromium.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Miroslav Benes <mbenes@suse.cz>, Petr Mladek <pmladek@suse.com>,
Miguel Ojeda <ojeda@kernel.org>, Joe Perches <joe@perches.com>,
Stephen Boyd <swboyd@chromium.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>
Subject: Re: [PATCH v2] kallsyms: strip ThinLTO postfix ".cfi_jt"
Date: Thu, 29 Jul 2021 17:29:04 +0200 [thread overview]
Message-ID: <20210729152904.GA14619@pswork> (raw)
In-Reply-To: <CABCJKudYRiK0KcMHGHeBFcr+Smwa9EM+NFeBpMo_ePqK+zHz0w@mail.gmail.com>
On Wed, Jul 28, 2021 at 01:57:21PM -0700, Sami Tolvanen wrote:
> Hi,
>
> On Tue, Jul 27, 2021 at 7:07 AM Padmanabha Srinivasaiah
> <treasure4paddy@gmail.com> wrote:
> >
> > Clang ThinLTO adds a postfix ".cfi_jt" to a symbols of extern functions.
>
> These symbols are added with CONFIG_CFI_CLANG no matter which LTO mode
> is selected, so talking about ThinLTO here isn't quite correct.
>
Yes, checked irrespective of the LTO mode choosen ".cfi_jt" postfix
is added with CONFIG_CFI_CLANG flag. Thanks for correcting out,
will make neccessary changes.
> > For example this breaks syscall tracer that doesn't expect such postfix,
> > so strip out the postfix from the output.
> >
> > Signed-off-by: Padmanabha Srinivasaiah <treasure4paddy@gmail.com>
> > ---
> > Change in v2:
> > - Use existing routine in kallsyms to strip postfix ".cfi_jt" from
> > extern function name.
> > - Modified the commit message accordingly
> >
> > kernel/kallsyms.c | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> > index 0ba87982d017..e9148626ae6c 100644
> > --- a/kernel/kallsyms.c
> > +++ b/kernel/kallsyms.c
> > @@ -166,16 +166,20 @@ static unsigned long kallsyms_sym_address(int idx)
> >
> > #if defined(CONFIG_CFI_CLANG) && defined(CONFIG_LTO_CLANG_THIN)
> > /*
> > - * LLVM appends a hash to static function names when ThinLTO and CFI are
> > - * both enabled, i.e. foo() becomes foo$707af9a22804d33c81801f27dcfe489b.
> > - * This causes confusion and potentially breaks user space tools, so we
> > - * strip the suffix from expanded symbol names.
> > + * LLVM appends a hash to static function names and just ".cfi_jt" postfix
> > + * for non-static functions when both ThinLTO and CFI are enabled,
>
> Functions aren't technically speaking renamed to add a .cfi_jt
> postfix. Instead, these are separate symbols that point to the CFI
> jump table. Perhaps the comment should just say that we want to strip
> .cfi_jt from CFI jump table symbols?
>
Agree, in jest modified existing comment. Will address same.
> > + * i.e. for example foo() becomes foo$707af9a22804d33c81801f27dcfe489b.
> > + * This causes confusion and potentially breaks user space tools and
> > + * built-in components, so we strip the suffix from expanded symbol names.
> > */
> > static inline bool cleanup_symbol_name(char *s)
> > {
> > char *res;
> >
> > res = strrchr(s, '$');
> > + if (!res)
> > + res = strstr(s, ".cfi_jt");
> > +
> > if (res)
> > *res = '\0';
>
> This looks otherwise fine to me, but it's going to conflict with
> Nick's earlier patch:
>
> https://lore.kernel.org/lkml/20210707181814.365496-1-ndesaulniers@google.com/
>
> Could you please rebase this on top of that, and take into account
> that we should do this when CONFIG_LTO_CLANG is enabled, not only with
> LTO_CLANG_THIN?
>
Thanks Sami for pointing out the link, will rebase and refactor the change.
> Sami
next prev parent reply other threads:[~2021-07-29 15:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210727131853.GA18032@pswork>
2021-07-27 14:06 ` [PATCH v2] kallsyms: strip ThinLTO postfix ".cfi_jt" Padmanabha Srinivasaiah
2021-07-28 20:57 ` Sami Tolvanen
2021-07-29 15:29 ` Padmanabha Srinivasaiah [this message]
2021-07-29 20:53 ` [PATCH v3] kallsyms: strip CLANG CFI " Padmanabha Srinivasaiah
2021-08-03 16:28 ` Sami Tolvanen
2021-08-04 17:17 ` Padmanabha Srinivasaiah
2021-08-05 23:27 ` [PATCH v4] " Padmanabha Srinivasaiah
2021-08-12 23:05 ` Sami Tolvanen
2021-08-14 12:15 ` Padmanabha Srinivasaiah
2021-08-14 12:42 ` [PATCH v5] " Padmanabha Srinivasaiah
2021-10-01 18:29 ` Nick Desaulniers
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=20210729152904.GA14619@pswork \
--to=treasure4paddy@gmail.com \
--cc=clang-built-linux@googlegroups.com \
--cc=gustavoars@kernel.org \
--cc=jeyu@kernel.org \
--cc=joe@perches.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=ojeda@kernel.org \
--cc=pmladek@suse.com \
--cc=samitolvanen@google.com \
--cc=swboyd@chromium.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.