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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180410113319.wgopcxznq7pqpxi7@pathway.suse.cz>
Date:   Tue, 10 Apr 2018 13:33:19 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Josh Poimboeuf <jpoimboe@...hat.com>
Cc:     Jiri Kosina <jikos@...nel.org>, Miroslav Benes <mbenes@...e.cz>,
        Joe Lawrence <joe.lawrence@...hat.com>,
        Jessica Yu <jeyu@...nel.org>, Nicolai Stange <nstange@...e.de>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 1/2] livepatch: Initialize shadow variables safely by
 a custom callback

On Fri 2018-04-06 17:34:20, Josh Poimboeuf wrote:
> On Thu, Apr 05, 2018 at 02:23:14PM +0200, Petr Mladek wrote:
> > @@ -150,6 +149,23 @@ static void *__klp_shadow_get_or_alloc(void *obj, unsigned long id, void *data,
> >  		goto exists;
> >  	}
> >  
> > +	new_shadow->obj = obj;
> > +	new_shadow->id = id;
> > +
> > +	if (ctor) {
> > +		int err;
> > +
> > +		err = ctor(obj, new_shadow->data, ctor_data);
> > +		if (err) {
> > +			spin_unlock_irqrestore(&klp_shadow_lock, flags);
> > +			kfree(new_shadow);
> > +			WARN(1,
> > +			     "Failed to construct shadow variable <%p, %lx>\n",
> > +			     obj, id);
> > +			return NULL;
> > +		}
> > +	}
> > +
> 
> I'm not sure why a constructor would return an error, though I guess it
> doesn't hurt to allow it.

It is true that constructors usually do not return an error code,
namely C++ or Java. But it is not true that they could not fail.
These languages use exceptions instead.

IMHO, the return value makes sense here.


> The WARN seems excessive though, IMO.  The constructor itself can warn
> (or printk or whatever else) if it thinks its warranted.

I am just fascinated by WARN(). But you are right. I am going to
replace it with

	pr_err("Failed to construct shadow variable <%p, %lx> (%d)\n",
	       obj, id, err);

> Also I think the 'err' variable isn't really needed.

Yup. Well, it will be needed by the pr_err() ;-)

Best Regard,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ