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:   Fri, 14 Dec 2018 10:32:01 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Josh Poimboeuf <jpoimboe@...hat.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,
        Jessica Yu <jeyu@...nel.org>
Subject: Re: [PATCH v14 03/11] livepatch: Consolidate klp_free functions

On Thu 2018-12-13 16:10:37, Josh Poimboeuf wrote:
> On Thu, Nov 29, 2018 at 10:44:23AM +0100, Petr Mladek wrote:
> > +static void klp_free_funcs(struct klp_object *obj)
> >  {
> >  	struct klp_func *func;
> >  
> > -	for (func = obj->funcs; func->old_name && func != limit; func++)
> > -		kobject_put(&func->kobj);
> > +	klp_for_each_func(obj, func) {
> > +		/* Might be called from klp_init_patch() error path. */
> > +		if (func->kobj_alive) {
> > +			func->kobj_alive = false;
> > +			kobject_put(&func->kobj);
> > +		}
> 
> Why does it set 'kobj_alive' to false?  The value will never be read
> again anyway, right?

You are right. I'll remove it in v15.

My intention was that it might signalize that the kobject is being
freed and eventually affect the behavior of sysfs-related callbacks.
But in reality, it should be handled by some per-patch flag instead
of a per-object one.


> Also, the name isn't quite right.  The kobject is technically still
> alive here, and may even continue to be alive after the kobject_put(),
> if there's a sysfs reference to it somewhere.
> 
> Maybe it should be called something like 'kobj_initialized' instead.
> Then it doesn't ever need to be set to false -- unless I'm missing
> something.

This might cause confusion with kobj.state_initialized. This internal
kobject flag is set when the reference counter is initialized. But
it is true even before kobject_add() is called.

We need a flag that signalizes that kobject_add() succeeded and we
can and must call kobject_put().

What about calling it 'kobj_added'?

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ