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:   Mon, 28 May 2018 20:31:04 +0200
From:   Christian Brauner <christian@...uner.io>
To:     Al Viro <viro@...IV.linux.org.uk>
Cc:     linux-kernel@...r.kernel.org, ebiederm@...ssion.com,
        gregkh@...uxfoundation.org, mingo@...nel.org,
        james.morris@...rosoft.com, keescook@...omium.org,
        peterz@...radead.org, sds@...ho.nsa.gov, akpm@...ux-foundation.org,
        oleg@...hat.com
Subject: Re: [PATCH 2/8] signal: make kill_as_cred_perm() return bool

On Mon, May 28, 2018 at 03:07:49PM +0100, Al Viro wrote:
> On Mon, May 28, 2018 at 03:49:10PM +0200, Christian Brauner wrote:
> > kill_as_cred_perm() already behaves like a boolean function. Let's actually
> > declare it as such too.
> > 
> > Signed-off-by: Christian Brauner <christian@...uner.io>
> > ---
> >  kernel/signal.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> > 
> > diff --git a/kernel/signal.c b/kernel/signal.c
> > index c756008d589e..81be01d193f4 100644
> > --- a/kernel/signal.c
> > +++ b/kernel/signal.c
> > @@ -1349,14 +1349,15 @@ static int kill_proc_info(int sig, struct siginfo *info, pid_t pid)
> >  	return error;
> >  }
> >  
> > -static int kill_as_cred_perm(const struct cred *cred,
> > +static bool kill_as_cred_perm(const struct cred *cred,
> >  			     struct task_struct *target)
> >  {
> >  	const struct cred *pcred = __task_cred(target);
> >  	if (!uid_eq(cred->euid, pcred->suid) && !uid_eq(cred->euid, pcred->uid) &&
> >  	    !uid_eq(cred->uid,  pcred->suid) && !uid_eq(cred->uid,  pcred->uid))
> > -		return 0;
> > -	return 1;
> > +		return false;
> > +
> > +	return true;
> 
> Ugh...
> 	if (!foo && !bar && !baz && !quux)
> 		return false;
> 	return true;
> 
> is a bloody odd way to spell
> 
> 	return foo || bar || baz || quux;

Added in v1.
There's a bunch more functions that should return bool and that can
similarly simplified which I'll send out in the next round.

Thanks!
Christian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ