[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180922143127.GJ24124@hirez.programming.kicks-ass.net>
Date: Sat, 22 Sep 2018 16:31:27 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: Jiri Kosina <jikos@...nel.org>,
"Schaufler, Casey" <casey.schaufler@...el.com>,
Ingo Molnar <mingo@...hat.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
"Woodhouse, David" <dwmw@...zon.co.uk>,
Andi Kleen <ak@...ux.intel.com>,
Tim Chen <tim.c.chen@...ux.intel.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>
Subject: Re: [PATCH v6 0/3] Harden spectrev2 userspace-userspace protection
On Sat, Sep 22, 2018 at 03:30:07PM +0200, Thomas Gleixner wrote:
> On Sat, 22 Sep 2018, Thomas Gleixner wrote:
> > On Sat, 22 Sep 2018, Peter Zijlstra wrote:
> > > This has some unfortunate duplication.
> > >
> > > Lets go with it for now, but I'll see if I can do something about that
> > > later.
> >
> > Yes, I know. I tried to make the duplication smaller, but all attempts
> > ended up being a convoluted mess. I'll try again after applying more
> > coffee.
>
> Lunch and coffee indeed made brain work better. The simple solution was way
> too obvious.
> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -261,6 +261,9 @@ static int ptrace_check_attach(struct ta
>
> static int ptrace_has_cap(struct user_namespace *ns, unsigned int mode)
> {
> + if (mode & PTRACE_MODE_SCHED)
> + return false;
> +
> if (mode & PTRACE_MODE_NOAUDIT)
> return has_ns_capability_noaudit(current, ns, CAP_SYS_PTRACE);
> else
> @@ -328,9 +331,16 @@ static int __ptrace_may_access(struct ta
> !ptrace_has_cap(mm->user_ns, mode)))
> return -EPERM;
>
> + if (mode & PTRACE_MODE_SCHED)
> + return 0;
> return security_ptrace_access_check(task, mode);
> }
>
> +bool ptrace_may_access_sched(struct task_struct *task, unsigned int mode)
> +{
> + return __ptrace_may_access(task, mode | PTRACE_MODE_SCHED);
> +}
Ha!, much nicer. Thanks!
Powered by blists - more mailing lists