Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755159AbcJTDOP (ORCPT ); Wed, 19 Oct 2016 23:14:15 -0400 Received: from tartarus.angband.pl ([89.206.35.136]:37039 "EHLO tartarus.angband.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754886AbcJTDOO (ORCPT ); Wed, 19 Oct 2016 23:14:14 -0400 Date: Thu, 20 Oct 2016 05:13:54 +0200 From: Adam Borowski To: Dmitry Safonov <0x7f454c46@gmail.com> Cc: Mikulas Patocka , Dmitry Safonov , Oleg Nesterov , linux-mm@kvack.org, Cyrill Gorcunov , Pavel Emelyanov , Thomas Gleixner , open list Subject: Re: x32 is broken in 4.9-rc1 due to "x86/signal: Add SA_{X32,IA32}_ABI sa_flags" Message-ID: <20161020031354.GA9074@angband.pl> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Junkbait: aaron@angband.pl, zzyx@angband.pl User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: kilobyte@angband.pl X-SA-Exim-Scanned: No (on tartarus.angband.pl); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2889 Lines: 73 On Thu, Oct 20, 2016 at 01:02:59AM +0300, Dmitry Safonov wrote: > 2016-10-19 20:33 GMT+03:00 Mikulas Patocka : > > On Wed, 19 Oct 2016, Mikulas Patocka wrote: > >> In the kernel 4.9-rc1, the x32 support is seriously broken, a x32 process > >> is killed with SIGKILL after returning from any signal handler. > > > > I should have said they are killed with SIGSEGV, not SIGKILL. > > > >> I use Debian sid x64-64 distribution with x32 architecture added from > >> debian-ports. > >> > >> I bisected the bug and found out that it is caused by the patch > >> 6846351052e685c2d1428e80ead2d7ca3d7ed913 ("x86/signal: Add > >> SA_{X32,IA32}_ABI sa_flags"). > > > > So, the kernel somehow thinks that it is i386 process, not x32 process. A > > core dump of a real x32 process shows "Class: ELF32, Machine: Advanced > > Micro Devices X86-64". > > could you give attached patch a shot? > In about 10 hours I'll be at work and will have debian-x32 install, > but for now, I can't test it. > Thanks again on catching that. > > From a546f8da1d12676fe79c746d859eb1e17aa4c331 Mon Sep 17 00:00:00 2001 > From: Dmitry Safonov <0x7f454c46@gmail.com> > Date: Thu, 20 Oct 2016 00:53:08 +0300 > Subject: [PATCH] x86/signal: set SA_X32_ABI flag for x32 programs > > For x32 programs cs register is __USER_CS, so it returns here > unconditionally - remove this check completely here. > > Fixes: commit 6846351052e6 ("x86/signal: Add SA_{X32,IA32}_ABI sa_flags") > > Reported-by: Mikulas Patocka > Signed-off-by: Dmitry Safonov <0x7f454c46@gmail.com> > --- > arch/x86/kernel/signal_compat.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/arch/x86/kernel/signal_compat.c b/arch/x86/kernel/signal_compat.c > index 40df33753bae..ec1f756f9dc9 100644 > --- a/arch/x86/kernel/signal_compat.c > +++ b/arch/x86/kernel/signal_compat.c > @@ -105,9 +105,6 @@ void sigaction_compat_abi(struct k_sigaction *act, struct k_sigaction *oact) > /* Don't let flags to be set from userspace */ > act->sa.sa_flags &= ~(SA_IA32_ABI | SA_X32_ABI); > > - if (user_64bit_mode(current_pt_regs())) > - return; > - > if (in_ia32_syscall()) > act->sa.sa_flags |= SA_IA32_ABI; > if (in_x32_syscall()) > -- > 2.10.0 Works for me. Tested on general operation, a few by-hand checks and several random package builds. It'd be nice to check glibc's testsuite as well as it had recent regressions caused by kernel changes on x32 (like https://bugs.debian.org/841240) but as gcc-6 in sid is broken right now (fails to build kernel, glibc:amd64, etc), I didn't bother that much. Tested-by: Adam Borowski -- A MAP07 (Dead Simple) raspberry tincture recipe: 0.5l 95% alcohol, 1kg raspberries, 0.4kg sugar; put into a big jar for 1 month. Filter out and throw away the fruits (can dump them into a cake, etc), let the drink age at least 3-6 months.