From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752808AbcBLN5E (ORCPT ); Fri, 12 Feb 2016 08:57:04 -0500 Received: from mail.skyhub.de ([78.46.96.112]:36120 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbcBLN5A (ORCPT ); Fri, 12 Feb 2016 08:57:00 -0500 Date: Fri, 12 Feb 2016 14:56:57 +0100 From: Borislav Petkov To: Andy Lutomirski Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , Brian Gerst , Denys Vlasenko , Stas Sergeev , Cyrill Gorcunov , Pavel Emelyanov , Linus Torvalds Subject: Re: [PATCH v3 3/4] x86/signal/64: Re-add support for SS in the 64-bit signal context Message-ID: <20160212135657.GC4099@pd.tnic> References: <40665bc51802a9976345f2a41dc6abb97dd944a5.1453754484.git.luto@kernel.org> <20160211194943.GH5565@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 11, 2016 at 05:01:39PM -0800, Andy Lutomirski wrote: > On Thu, Feb 11, 2016 at 11:49 AM, Borislav Petkov wrote: > > On Mon, Jan 25, 2016 at 01:34:14PM -0800, Andy Lutomirski wrote: > > > >> + * with a flat 32-bit selector. > > How about: > > Sigreturn restores SS as follows: > > if (saved SS is valid || UC_STRICT_RESTORE_SS is set || saved CS is not 64-bit) > new SS = saved SS > else > new SS = a flat 32-bit data segment Much better! > How about: > > --- cut here --- > > This behavior serves three purposes: > > - Legacy programs that construct a 64-bit sigcontext from scratch > with zero or garbage in the SS slot (e.g. old CRIU) and call sigreturn > will still work. > > - Old DOSEMU versions sometimes catch a signal from a segmented > context, delete the old SS segment (with modify_ldt), and change the > saved CS to a 64-bit segment. These DOSEMU versions expect sigreturn > to send them back to 64-bit mode without killing them, despite the > fact that the SS selector when the signal was raised is no longer > valid. With UC_STRICT_RESTORE_SS clear, the kernel will fix up SS for > these DOSEMU versions. ... and with UC_STRICT_RESTORE_SS set, they'll get __USER_DS. > - Old and new programs that catch a signal and return without > modifying the saved context will end up in exactly the state they > started in. Old kernels would lose track of the previous SS value. > > --- cut here --- Yap, definitely better. > FWIW, I have a DOSEMU patch that makes it use UC_STRICT_RESTORE_SS to > get the behavior it actually wants on new kernels. It should make it > faster and more reliable than was possible before. Cool. Thanks. -- Regards/Gruss, Boris. ECO tip #101: Trim your mails when you reply.