Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932147AbbELGkj (ORCPT ); Tue, 12 May 2015 02:40:39 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:34777 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428AbbELGkh (ORCPT ); Tue, 12 May 2015 02:40:37 -0400 Date: Tue, 12 May 2015 08:40:32 +0200 From: Ingo Molnar To: Alex Henrie Cc: One Thousand Gnomes , Kees Cook , "H . Peter Anvin" , Doug Johnson , Thomas Gleixner , Ingo Molnar , Tyler Hicks , Al Viro , linux-kernel@vger.kernel.org, Andy Lutomirski , Linus Torvalds , Andrew Morton , Borislav Petkov , Peter Zijlstra , Arjan van de Ven , Denys Vlasenko , Brian Gerst Subject: Re: [PATCH v2] x86: Preserve iopl on fork and execve Message-ID: <20150512064032.GA25097@gmail.com> References: <1431387505-13410-1-git-send-email-alexhenrie24@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431387505-13410-1-git-send-email-alexhenrie24@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3482 Lines: 89 * Alex Henrie wrote: > Signed-off-by: Alex Henrie > Suggested-by: Doug Johnson > --- > arch/x86/kernel/process_32.c | 2 +- > arch/x86/kernel/process_64.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c > index 8ed2106..0ef7078 100644 > --- a/arch/x86/kernel/process_32.c > +++ b/arch/x86/kernel/process_32.c > @@ -205,7 +205,7 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp) > regs->cs = __USER_CS; > regs->ip = new_ip; > regs->sp = new_sp; > - regs->flags = X86_EFLAGS_IF; > + regs->flags = X86_EFLAGS_IF | (X86_EFLAGS_IOPL & regs->flags); > force_iret(); > } > EXPORT_SYMBOL_GPL(start_thread); > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c > index ddfdbf7..e21eda2 100644 > --- a/arch/x86/kernel/process_64.c > +++ b/arch/x86/kernel/process_64.c > @@ -238,7 +238,7 @@ start_thread_common(struct pt_regs *regs, unsigned long new_ip, > regs->sp = new_sp; > regs->cs = _cs; > regs->ss = _ss; > - regs->flags = X86_EFLAGS_IF; > + regs->flags = X86_EFLAGS_IF | (X86_EFLAGS_IOPL & regs->flags); > force_iret(); > } Yeah, NAK. So this patch could be an instant roothole on some setups: assume old 64-bit apps relying on fork/clone/execve effectively flushing these capabilities and we'll now leak powerful hardware access permissions into child contexts that never had it before ... I realize that this is a 2.5+ years old regression on 32-bit x86, and that the prior inheritance of iopl/ioperm was broken accidentally on 32-bit kernels by: 6783eaa2e125 ("x86, um/x86: switch to generic sys_execve and kernel_execve") My arguments in favor of doing nothing are: - Nothing actually broke that people cared about in the last 2.5 years, thus this might be one of the (very very rare) cases where preserving a breakage is the right thing to do. - There's no reason to export this behavior to 64-bit x86 which apparently never had the iopl/ioperm capabilities propagation. - Furthermore, even new 32-bit apps might have (accidentally) learned the new ABI, and we'd now break _them_, possibly in subtle ways. - Plus iopl() and ioperm() are one of the most dangerous kernel APIs we have and the accidental limiting of them, which we got away with for 2.5+ years without being reportd, might just be what we want to stick with. An aspect of an API is only an ABI if it's actually used by applications. - These syscalls are rarely used, and we could as well insist that every new context should have the permissions to (re-)acquire them and should actively seek them - instead of inheriting it to shells via system(), etc. The best strategy with dangerous APIs is to make it really, really explicit when they are used. Permission propagation breakages like this are a rare situation and there's really no good way to fix them: damned if you do, damned if you don't. So without far more analysis and far more care (a zero-length changelog won't cut it!) I doubt we can - or event want to - do anything like this... Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/