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]
Message-ID: <20181018125824.ms5zovmsnikv3bgt@treble>
Date:   Thu, 18 Oct 2018 07:58:24 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Petr Mladek <pmladek@...e.com>
Cc:     Jiri Kosina <jikos@...nel.org>, Miroslav Benes <mbenes@...e.cz>,
        Jason Baron <jbaron@...mai.com>,
        Joe Lawrence <joe.lawrence@...hat.com>,
        Evgenii Shatokhin <eshatokhin@...tuozzo.com>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v13 02/12] livepatch: Helper macros to define livepatch
 structures

On Thu, Oct 18, 2018 at 01:11:53PM +0200, Petr Mladek wrote:
> On Wed 2018-10-17 13:17:56, Josh Poimboeuf wrote:
> > On Mon, Oct 15, 2018 at 02:37:03PM +0200, Petr Mladek wrote:
> > > The definition of struct klp_func might be a bit confusing.
> > > The original function is defined by name as a string.
> > > The new function is defined by name as a function pointer
> > > casted to unsigned long.
> > > 
> > > This patch adds helper macros that hide the different types.
> > > The functions are defined just by the name. For example:
> > 
> > On one hand, these macros are kind of nice, because they do the function
> > pointer casting for the user.
> > 
> > On the other hand, they hide the field names, which hurts readability a
> > bit.  For example, it would be easy to accidentally assign the wrong
> > callback function.
> 
> I am not a big fan of the macros either.
> 
> 
> > Also, it's unfortunate that these macros are needed in the first place.
> > 
> > What if we just change new_addr (and old_addr) to be 'void *'?  Then the
> > macros wouldn't be as useful, and we could just get rid of them.
> 
> Hmm, I wonder if any change make sense then. The above proposal might
> just exchange one confusion with another one:
> 
>    + I would expect that a variable called addr is of the type
>      unsigned long
> 
>    + we would need casting when calling ftrace API
> 
>    + .new_addr = function_xxx looks a bit weird and it will
>      be used many times in all livepatch sources.

Fair points.  Instead of changing new_func to new_addr, how about we
leave it alone, and instead change 'unsigned long old_addr' to 'void
*old_func'?

That would give us consistent naming internally, while making the
external interface more sensible and cast-free.

We'd still have to cast when passing to the ftrace API, but IMO it would
be worth it.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ