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]
Date:   Sat, 14 Aug 2021 14:15:19 +0200
From:   Padmanabha Srinivasaiah <treasure4paddy@...il.com>
To:     Sami Tolvanen <samitolvanen@...gle.com>
Cc:     Nick Desaulniers <ndesaulniers@...gle.com>,
        Jessica Yu <jeyu@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Nathan Chancellor <nathan@...nel.org>,
        Miroslav Benes <mbenes@...e.cz>,
        Stephen Boyd <swboyd@...omium.org>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        Joe Perches <joe@...ches.com>,
        LKML <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH v4] kallsyms: strip CLANG CFI postfix ".cfi_jt"

On Thu, Aug 12, 2021 at 04:05:25PM -0700, Sami Tolvanen wrote:
> On Thu, Aug 5, 2021 at 4:28 PM Padmanabha Srinivasaiah
> <treasure4paddy@...il.com> wrote:
> >
> > Clang CFI adds a postfix ".cfi_jt" to a symbols of extern functions.
> > For e.g. this breaks syscall tracer that doesn't expect such postfix,
> > so strip out the postfix from the expanded symbol.
> >
> > Signed-off-by: Padmanabha Srinivasaiah <treasure4paddy@...il.com>
> > ---
> > Change in v4:
> >   - Remove redundant check; irrespective of LTO type (THIN/FULL),
> >     LTO_CLANG will be always enabled. Hence will be used as entry flag
> >     to check various postfix patterns.
> >   - And prior to stripping postfix ".cfi_jt", added a comment to
> >     justify why we are doing so.
> >
> > Change in v3:
> >   - Modified commit message to indicate fix is for Clang CFI postfix
> >   - Rebased on recent patch from ndesaulniers@...gle.com.
> >     https://lore.kernel.org/lkml/
> >         20210707181814.365496-1-ndesaulniers@...gle.com/#t
> >   - Fix is enabled even for CONFIG_LTO_CLANG
> >
> > 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 | 23 ++++++++++++++++++-----
> >  1 file changed, 18 insertions(+), 5 deletions(-)
> >
> > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> > index 5cabe4dd3ff4..1b40bcf20fe6 100644
> > --- a/kernel/kallsyms.c
> > +++ b/kernel/kallsyms.c
> > @@ -174,13 +174,15 @@ static bool cleanup_symbol_name(char *s)
> >          * foo.llvm.974640843467629774. This can break hooking of static
> >          * functions with kprobes.
> >          */
> > -       if (!IS_ENABLED(CONFIG_LTO_CLANG_THIN))
> > +       if (!IS_ENABLED(CONFIG_LTO_CLANG))
> >                 return false;
> >
> > -       res = strstr(s, ".llvm.");
> > -       if (res) {
> > -               *res = '\0';
> > -               return true;
> > +       if (IS_ENABLED(CONFIG_LTO_CLANG_THIN)) {
> > +               res = strstr(s, ".llvm.");
> > +               if (res) {
> > +                       *res = '\0';
> > +                       return true;
> > +               }
> >         }
> 
> I confirmed that LLVM renames these also with full LTO, so the config
> check can be dropped here.
>
Thank you sami for the input I missread your earlier review commit, will
re-genrate the patch

> >
> >         /*
> > @@ -194,6 +196,17 @@ static bool cleanup_symbol_name(char *s)
> >                 return false;
> >
> >         res = strrchr(s, '$');
> > +       if (!res) {
> > +               /*
> > +                * In case of non static function symbol <funcsym>,
> > +                * the local jump table will have entry as <funcsym>.cfi_jt.
> > +                *
> > +                * Such expansion breaks some built-in components,
> > +                * e.g. syscall tracer. Hence remove postfix ".cfi_jt".
> > +                */
> > +               res = strstr(s, ".cfi_jt");
> > +       }
> > +
> >         if (res) {
> >                 *res = '\0';
> >                 return true;
> 
> Otherwise, the logic looks pretty good to me. Nick, are you planning
> to resend your earlier patch? Should this be just folded into the next
> version?
> 
> Sami

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ