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: <20240201113612.00001d90@Huawei.com>
Date: Thu, 1 Feb 2024 11:36:12 +0000
From: Jonathan Cameron <Jonathan.Cameron@...wei.com>
To: "Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>
CC: Peter Zijlstra <peterz@...radead.org>, <dan.j.williams@...el.com>,
	<linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...nel.org>,
	<linux-cxl@...r.kernel.org>, Ira Weiny <ira.weiny@...el.com>
Subject: Re: [RFC PATCH v3] cleanup: Add cond_guard() to conditional guards

On Thu, 01 Feb 2024 09:16:59 +0100
"Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com> wrote:

> On Thursday, 1 February 2024 02:12:12 CET Dan Williams wrote:
> > Fabio M. De Francesco wrote:  
> > > I just noticed that this is not the final version. It misses a semicolon.
> > > Please discard this v3. I'm sending v4.  
> > 
> > Ok, but do please copy the aspect of scoped_conf_guard() to take a
> > "_fail" statement argument. Passing a return code collector variable by
> > reference just feels a bit too magical. I like the explicitness of
> > passing the statement directly.  
> 
> I had introduced a bug in my tests that made me see failures when there were 
> not. Now I fixed it and tests don't fail.
> 
> I'm sending a new version that passes the return variable directly, not as a 
> reference, similar but not equal to:
> 
> 	cond_guard(..., rc, -EINTR, ...);
> 
> Actually, I'm doing this:
> 
> 	cond_guard(..., rc, 0, -EINTR, ...);

Can we not works some magic to do.
	cond_guard(..., return -EINTR, ...)

and not have an rc at all if we don't want to.

Something like

#define cond_guard(_name, _fail, args...) \
	CLASS(_name, scope)(args); \
	if (!__guard_ptr(_name)(&scope)) _fail

Completely untested so I'm probably missing some subtleties.

Jonathan


> 
> I'm not passing 'rc = -EINTR' because I want to take into account the 
> possibility that rc contains values different than 0 from previous assignments. 
> I'm passing rc, so that the macro can assign either a success code or a 
> failure error to this variable. Any value from previous assignments must be 
> always overwritten: 
> 
> 	#define cond_guard(_name, _ret, _scs, _err, args...) \
>         	CLASS(_name, scope)(args); \
>         	if (!__guard_ptr(_name)(&scope)) _ret = _err; \
>         	else _ret = _scs;
> 
> I should have seen long ago that my tests were failing because of a missing 
> 'else' when passing a statement in 'cond_guard(..., rc = -EINTR, ...);'. It 
> had nothing to do with how to pass 'rc'. Sorry for that confusion.
> 
> Fabio
> 
> Fabio 
> 
> 
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ