Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031129AbbDWW3x (ORCPT ); Thu, 23 Apr 2015 18:29:53 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:32985 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758338AbbDWW3t (ORCPT ); Thu, 23 Apr 2015 18:29:49 -0400 MIME-Version: 1.0 In-Reply-To: <55396617.4020303@zytor.com> References: <1429792491-5978-1-git-send-email-dvlasenk@redhat.com> <20150423211015.GS28327@pd.tnic> <55396617.4020303@zytor.com> From: Andy Lutomirski Date: Thu, 23 Apr 2015 15:29:27 -0700 Message-ID: Subject: Re: [PATCH] x86/asm/entry/32: Restore %ss before SYSRETL if necessary To: "H. Peter Anvin" Cc: Borislav Petkov , Denys Vlasenko , Linus Torvalds , Brian Gerst , Denys Vlasenko , Ingo Molnar , Steven Rostedt , 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 Content-Length: 1430 Lines: 33 On Thu, Apr 23, 2015 at 2:37 PM, H. Peter Anvin wrote: > On 04/23/2015 02:10 PM, Borislav Petkov wrote: >> On Thu, Apr 23, 2015 at 10:01:16PM +0200, Denys Vlasenko wrote: >>> Naturally, CS can't be NULL, and up until today >>> I thought SS also can't. But the bit is probably implemented >>> for all eight cached descriptors. >> >> There's this section about NULL selector in APM v2. It says that NULL >> selectors are used to invalidate segment registers and software can load >> a NULL selector in SS in CPL0. >> >> So, if an interrupt happens and as you quoted earlier that SS gets set >> to NULL as a result of an interrupt, there's that SS leak causing the SS >> exception. >> > > Yes, the NULL SS is a special thing in 64-bit mode. I agree that > context-switching it is probably the way to go; it should be cheap > enough. We might even be able to conditionalize it on an X86_BUG_ flag. I still don't see why context switches are a better place than just before sysret, but I could be convinced. I updated my test at https://git.kernel.org/cgit/linux/kernel/git/luto/misc-tests.git/. I want to figure out whether this is a problem for sysretq, too. --Andy -- 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/