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:   Thu, 22 Aug 2019 01:03:20 +0200
From:   Frederic Weisbecker <frederic@...nel.org>
To:     Thomas Gleixner <tglx@...utronix.de>
Cc:     LKML <linux-kernel@...r.kernel.org>,
        Oleg Nesterov <oleg@...hat.com>,
        Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        John Stultz <john.stultz@...aro.org>,
        Anna-Maria Behnsen <anna-maria@...utronix.de>,
        Christoph Hellwig <hch@....de>
Subject: Re: [patch V2 01/38] posix-cpu-timers: Provide task validation
 functions

On Thu, Aug 22, 2019 at 12:33:56AM +0200, Frederic Weisbecker wrote:
> On Wed, Aug 21, 2019 at 09:08:48PM +0200, Thomas Gleixner wrote:
> > The code contains three slightly different copies of validating whether a
> > given clock resolves to a valid task and whether the current caller has
> > permissions to access it.
> > 
> > Create central functions. Replace check_clock() as a first step and rename
> > it to something sensible.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> > ---
> >  kernel/time/posix-cpu-timers.c |   65 +++++++++++++++++++++++++++--------------
> >  1 file changed, 44 insertions(+), 21 deletions(-)
> > 
> > --- a/kernel/time/posix-cpu-timers.c
> > +++ b/kernel/time/posix-cpu-timers.c
> > @@ -35,27 +35,52 @@ void update_rlimit_cpu(struct task_struc
> >  	spin_unlock_irq(&task->sighand->siglock);
> >  }
> >  
> > -static int check_clock(const clockid_t which_clock)
> > +/*
> > + * Functions for validating access to tasks.
> > + */
> > +static struct task_struct *lookup_task(const pid_t pid, bool thread)
> >  {
> > -	int error = 0;
> >  	struct task_struct *p;
> > -	const pid_t pid = CPUCLOCK_PID(which_clock);
> >  
> > -	if (CPUCLOCK_WHICH(which_clock) >= CPUCLOCK_MAX)
> > -		return -EINVAL;
> > +	if (!pid)
> > +		return thread ? current : current->group_leader;
> >  
> > -	if (pid == 0)
> > -		return 0;
> > +	p = find_task_by_vpid(pid);
> > +	if (!p || p == current)
> > +		return p;
> 
> What if (p == current && !thread && !has_group_leader_pid(p)) ?

Ah looking at the next patch, posix_cpu_clock_get_task() and posix_cpu_clock_getres()
had different ad-hoc checks for this specific case.

clock_getres() used to return -EINVAL while clock_get() doesn't care. They certainly should
agree in their behaviour. I'm not sure which one is correct. It probably doesn't matter much.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ