Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754425AbbHMWaJ (ORCPT ); Thu, 13 Aug 2015 18:30:09 -0400 Received: from mail-ob0-f170.google.com ([209.85.214.170]:34098 "EHLO mail-ob0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754386AbbHMWaE convert rfc822-to-8bit (ORCPT ); Thu, 13 Aug 2015 18:30:04 -0400 MIME-Version: 1.0 In-Reply-To: <55CD1968.7070002@list.ru> References: <55CA90B4.2010205@list.ru> <55CCD921.4040301@list.ru> <20150813200823.GS2059@uranus> <55CD0F29.4070604@gmail.com> <55CD13F3.1070904@list.ru> <55CD1968.7070002@list.ru> From: Andy Lutomirski Date: Thu, 13 Aug 2015 15:29:43 -0700 Message-ID: Subject: Re: [regression] x86/signal/64: Fix SS handling for signals delivered to 64-bit programs breaks dosemu To: Stas Sergeev Cc: Linus Torvalds , Raymond Jennings , Cyrill Gorcunov , Pavel Emelyanov , Linux kernel Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1564 Lines: 37 On Thu, Aug 13, 2015 at 3:25 PM, Stas Sergeev wrote: > 14.08.2015 01:11, Andy Lutomirski пишет: > >> Now suppose you set some magic flag and jump (via sigreturn, >> trampoline, whatever) into DOS code. The DOS code loads 0x7 into FS >> and then gets #GP. You land in a signal handler. As far as the >> kernel's concerned, the FS base register is whatever the base of LDT >> entry 0 is. What else is the kernel supposed to shove in there? > > The same as what happens when you do in userspace: > --- > asm ("mov $0,%%fs\n"); > prctl(ARCH_SET_FS, my_tls_base); > --- > > This was the trick I did before gcc started to use FS in prolog, > now I have to do this in asm. > But how simpler for the kernel is to do the same? > >> I think that making this work fully in the kernel would require a >> full-blown FS equivalent of sigaltstack, and that seems like overkill. > > Setting selector and base is what you call an "equivalent of sigaltstack"? Yes. sigaltstack says "hey, kernel! here's my SP for signal handling." I think we'd need something similar to tell the kernel what my_tls_base is. Using the most recent thing passed to ARCH_SET_FS is no good because WRFSBASE systems might not use ARCH_SET_FS, and we can't break DOSEMU on Ivy Bridge and newer as soon as we enable WRFSBASE. --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/