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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 13 Dec 2018 14:49:58 -0600
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Joe Lawrence <joe.lawrence@...hat.com>
Cc:     Nicholas Mc Guire <der.herr@...r.at>,
        Nicholas Mc Guire <hofrat@...dl.org>,
        Jessica Yu <jeyu@...nel.org>, Jiri Kosina <jikos@...nel.org>,
        Miroslav Benes <mbenes@...e.cz>,
        Petr Mladek <pmladek@...e.com>, live-patching@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2 V2] livepatch: handle kzalloc failure properly

On Thu, Dec 13, 2018 at 03:39:20PM -0500, Joe Lawrence wrote:
> Ahh, I understand the question now.  Yeah, by making those routines local 
> static, the compiler applied optimizations that renamed the symbols:
> 
>   noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_                                          
>        5: 0000000000000000    20 FUNC    LOCAL  DEFAULT    1 dummy_check.isra.0
>        7: 0000000000000020    52 FUNC    LOCAL  DEFAULT    1 dummy_free.constprop.1
>       12: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       13: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       15: 0000000000000160   115 FUNC    LOCAL  DEFAULT    1 dummy_alloc
> 
> 
> I can avoid that optimization (and successfully load all the modules) 
> by using either:
> 
>   __attribute__((optimize("O0"))) noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_
>        6: 0000000000000000  6016 FUNC    LOCAL  DEFAULT    1 dummy_alloc
>       11: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       12: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       14: 0000000000001810    73 FUNC    LOCAL  DEFAULT    1 dummy_free
>       16: 0000000000001860   108 FUNC    LOCAL  DEFAULT    1 dummy_check
> 
> or:
> 
>   __noclone noinline static
>   % readelf --syms samples/livepatch/livepatch-shadow-mod.o | grep dummy_
>        5: 0000000000000000    22 FUNC    LOCAL  DEFAULT    1 dummy_check
>        7: 0000000000000020    51 FUNC    LOCAL  DEFAULT    1 dummy_free
>       12: 00000000000000c0    32 OBJECT  LOCAL  DEFAULT    3 dummy_list_mutex
>       13: 00000000000000e0    16 OBJECT  LOCAL  DEFAULT    3 dummy_list
>       15: 0000000000000160   115 FUNC    LOCAL  DEFAULT    1 dummy_alloc
> 
> but I'm not sure if either is the definitive way to avoid such
> optimization.  Anyone know for sure?

Yeah, for now I think "static __noclone" is the way to go.  Soon we'll
have a GCC flag which disables such optimizations for all functions.

And the dummy_list* variables can just be "static".

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ