[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CALCETrWqYrotMSKqvsug-fgbO1-4X6q0FQpsiTrPkWSzu56NAA@mail.gmail.com>
Date: Wed, 14 Sep 2016 18:54:59 -0700
From: Andy Lutomirski <luto@...capital.net>
To: Kyle Huey <me@...ehuey.com>
Cc: "Robert O'Callahan" <robert@...llahan.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
Shuah Khan <shuah@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Borislav Petkov <bp@...e.de>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
Len Brown <len.brown@...el.com>,
Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
Aravind Gopalakrishnan <Aravind.Gopalakrishnan@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Vladimir Zapolskiy <vladimir_zapolskiy@...tor.com>,
Andy Lutomirski <luto@...nel.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Dmitry Safonov <dsafonov@...tuozzo.com>,
Kees Cook <keescook@...omium.org>,
"Michael S. Tsirkin" <mst@...hat.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Jiri Slaby <jslaby@...e.cz>,
Paul Gortmaker <paul.gortmaker@...driver.com>,
Denys Vlasenko <dvlasenk@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@...r.kernel.org>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@...r.kernel.org>
Subject: Re: [PATCH v2 3/3] x86,arch_prctl Add ARCH_[GET|SET]_CPUID for
controlling the CPUID instruction
On Wed, Sep 14, 2016 at 6:47 PM, Kyle Huey <me@...ehuey.com> wrote:
> On Wed, Sep 14, 2016 at 6:29 PM, Andy Lutomirski <luto@...capital.net> wrote:
>> On Wed, Sep 14, 2016 at 2:01 PM, Kyle Huey <me@...ehuey.com> wrote:
>>> +
>>> +int set_cpuid_mode(struct task_struct *task, unsigned long val)
>>> +{
>>> + /* Only disable/enable_cpuid() if it is supported on this hardware. */
>>> + bool cpuid_fault_supported = static_cpu_has(X86_FEATURE_CPUID_FAULT);
>>> +
>>> + if (val == ARCH_CPUID_ENABLE && cpuid_fault_supported) {
>>> + if (task_no_new_privs(task) && test_thread_flag(TIF_NOCPUID))
>>> + return -EACCES;
>>
>> This check seems confused. If this flag were preserved on execve,
>> it's the SIGSEGV mode that would need the check.
>
> Not sure I follow this one. no_new_privs should block transitions
> from SIGSEGV to ENABLE, right? That's what this check does.
It's the other way around entirely: if you make a change to your
process context such that a subseqently execve()'d setuid program
might malfunction, you've just done something dangerous. This is only
okay, at least in newly-supported instances, if you are either
privileged or if you have no_new_privs set. Having privilege makes it
okay: unprivileged programs can't use it to subvert setuid programs.
no_new_privs makes it safe as well: if no_new_privs is set, you can't
gain privilege via execve(), so there's no attack surface. So, if you
have execve() keep ARCH_CPUID_SIGSEGV set, then setting it that way in
the first place should require privilege or no_new_privs.
I personally favor resetting to ARCH_CPUID_ENABLE on execve() and not
worrying about no_new_privs.
Does that make sense?
Powered by blists - more mailing lists