From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753521AbbCITw0 (ORCPT ); Mon, 9 Mar 2015 15:52:26 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:43291 "EHLO mail-la0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753453AbbCITwX (ORCPT ); Mon, 9 Mar 2015 15:52:23 -0400 MIME-Version: 1.0 In-Reply-To: <54FDF3F9.50203@zytor.com> References: <1425909943-14687-1-git-send-email-dvlasenk@redhat.com> <54FDDBF7.9080207@zytor.com> <54FDF3F9.50203@zytor.com> From: Andy Lutomirski Date: Mon, 9 Mar 2015 12:51:56 -0700 Message-ID: Subject: Re: [PATCH] x86: entry_32.S: change ESPFIX test to not touch PT_OLDSS(%esp) To: "H. Peter Anvin" Cc: Linus Torvalds , Denys Vlasenko , Denys Vlasenko , Steven Rostedt , Ingo Molnar , Borislav Petkov , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 9, 2015 at 12:26 PM, H. Peter Anvin wrote: > On 03/09/2015 12:13 PM, Andy Lutomirski wrote: >> On Mon, Mar 9, 2015 at 10:44 AM, H. Peter Anvin wrote: >>> On 03/09/2015 09:44 AM, Linus Torvalds wrote: >>>> >>>> And remember: those zero-cost out-of-order branches turn quite >>>> expensive if they *ever* mispredict. Even a 5% mispredict rate is >>>> likely to mean "it's better to have a data dependency chain". >>>> >>>> So it could easily go either way. I'm not convinced the old code is bad at all. >>>> >>> >>> I'm inclined to side with Linus here. I'm hesitant to change this based >>> on pure speculation. >>> >>> To answer Andy's question: I do believe we need espfix for V86 mode as well. >>> >> >> I think we don't. Did I screw up my test? >> > > I don't see how your test executes V86 mode code at all, since there > seems to be nothing mapped at the bottom of memory? It executes the implicit #PF at the bottom of memory :) Seriously, though, I think that IRET doesn't check whether the instruction we're returning to can be fetched, so IRET will complete successfully and then we'll get #PF. The resulting SIGSEGV kicks us out of vm86 mode, and, assuming that the kernel isn't buggy (hah!) the v86 state will get saved back to the vm86plus_struct and we can see if esp got corrupted. --Andy