Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754550AbcJSWDY (ORCPT ); Wed, 19 Oct 2016 18:03:24 -0400 Received: from mail-lf0-f53.google.com ([209.85.215.53]:36830 "EHLO mail-lf0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750763AbcJSWDW (ORCPT ); Wed, 19 Oct 2016 18:03:22 -0400 MIME-Version: 1.0 In-Reply-To: References: From: Dmitry Safonov <0x7f454c46@gmail.com> Date: Thu, 20 Oct 2016 01:02:59 +0300 Message-ID: Subject: Re: x32 is broken in 4.9-rc1 due to "x86/signal: Add SA_{X32,IA32}_ABI sa_flags" To: Mikulas Patocka Cc: Dmitry Safonov , Oleg Nesterov , linux-mm@kvack.org, Cyrill Gorcunov , Pavel Emelyanov , Thomas Gleixner , open list Content-Type: multipart/mixed; boundary=047d7b604d2e204b13053f3efaa9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4270 Lines: 98 --047d7b604d2e204b13053f3efaa9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 2016-10-19 20:33 GMT+03:00 Mikulas Patocka : > > > On Wed, 19 Oct 2016, Mikulas Patocka wrote: > >> Hi >> >> In the kernel 4.9-rc1, the x32 support is seriously broken, a x32 proces= s >> 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"). >> >> example (strace of a process after receiving the SIGWINCH signal): >> >> epoll_wait(10, 0xef6890, 32, -1) =3D -1 EINTR (Interrupted system= call) >> --- SIGWINCH {si_signo=3DSIGWINCH, si_code=3DSI_USER, si_pid=3D1772, si_= uid=3D0} --- >> poll([{fd=3D4, events=3DPOLLOUT}], 1, 0) =3D 1 ([{fd=3D4, revents=3DP= OLLOUT}]) >> write(4, "\0", 1) =3D 1 >> rt_sigreturn({mask=3D[INT QUIT ILL TRAP BUS KILL SEGV USR2 PIPE ALRM STK= FLT TSTP TTOU URG XCPU XFSZ VTALRM IO PWR SYS RTMIN]}) =3D 0 >> --- SIGSEGV {si_signo=3DSIGSEGV, si_code=3DSI_KERNEL, si_addr=3DNULL} --= - >> +++ killed by SIGSEGV +++ >> Neopr=C3=A1vn=C3=ACn=C3=BD p=C3=B8=C3=ADstup do pam=C3=ACti (SIGSEGV) >> >> Mikulas > > BTW. when I take core dump of the killed x32 process, it shows: > > ELF Header: > Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 > Class: ELF32 > Data: 2's complement, little endian > Version: 1 (current) > OS/ABI: UNIX - System V > ABI Version: 0 > Type: CORE (Core file) > Machine: Intel 80386 > ^^^^^^^^^^^^^^^^^^^ > > 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". Hi Mikulas, 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. --=20 Dmitry --047d7b604d2e204b13053f3efaa9 Content-Type: text/x-patch; charset=US-ASCII; name="0001-x86-signal-set-SA_X32_ABI-flag-for-x32-programs.patch" Content-Disposition: attachment; filename="0001-x86-signal-set-SA_X32_ABI-flag-for-x32-programs.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_iuhgsn1x0 RnJvbSBhNTQ2ZjhkYTFkMTI2NzZmZTc5Yzc0NmQ4NTllYjFlMTdhYTRjMzMxIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBEbWl0cnkgU2Fmb25vdiA8MHg3ZjQ1NGM0NkBnbWFpbC5jb20+ CkRhdGU6IFRodSwgMjAgT2N0IDIwMTYgMDA6NTM6MDggKzAzMDAKU3ViamVjdDogW1BBVENIXS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