Received: by 10.192.165.156 with SMTP id m28csp259664imm; Tue, 10 Apr 2018 21:12:51 -0700 (PDT) X-Google-Smtp-Source: AIpwx48BSODCU570oEW11WnFdTuyEsxLSQPM/x2o4UopKek6aGLCpxrYlKQ76bkiLGIEsCotvwF9 X-Received: by 2002:a17:902:7291:: with SMTP id d17-v6mr3326369pll.218.1523419971068; Tue, 10 Apr 2018 21:12:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523419971; cv=none; d=google.com; s=arc-20160816; b=RDtgu/JcMW9RPE0zkY9i/AFV5uQvsBCHUXIVqMivnuu74+lbD/mXtnFf+ARpNTQ9z6 XklBvdYVVxTW8flKGui4X4NJ1Riyc0750HozwsS9BTRKcEBDYTNBrEoWwNWtHlG8n/Ie dKcfTtTJ0i7QqWHWxlgMG2fzyr4mZfmvuGVowXVgGV7mDT9w5mfjuiwbwDqTfpHVKNaJ UWqFadFc4aFkAN6hRRNp0K0zz26lCpvlRy9Lexp/ijS02nqUsshs8/+xefHlYehZukQ0 B0kpgph/nCleyl4dm3OE+FAfW1MEPNGuNXP8mXhWlbemb7EeeafA6hotuQglAFrtLnOW 6hug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=+d3nXDfmOSYxJ5Ro67/htNinJV9fkNH+mThEKcOSXPs=; b=0uNRCIVPmGVyoj6Q3IpcUdjAYToXZU/+T65OZJyyAiY3biP+Sgya9FKTPlLQimP62l wFpq/K70sVO3dClfdXnXYL9awD4UJ8i2fbtTe0/qfHT+GHXSA+P3sp/iOy80H3dIhhFb GegP1Z+peE3vg5uOyDDpFunuN58QQBgxu1x4CCllAADdBjFhTzuCecDtAIhrFRNu09nl 1LzhhNG/+Pip1pEwNMtvch5Tb19sJfZzg4Ltvd6vHA5sifIfeOWHHtvTow2qxTJSLeS3 GjB9f4s2G00zg3PhaVuOaHCOcpc0UqeiXh4CVAYCZtVo2wCMJ17kS4C6R7xY4dOxVQQs PQfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=u0PhZilO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si128125pgs.153.2018.04.10.21.12.13; Tue, 10 Apr 2018 21:12:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=u0PhZilO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751680AbeDKEJe (ORCPT + 99 others); Wed, 11 Apr 2018 00:09:34 -0400 Received: from mail-it0-f42.google.com ([209.85.214.42]:40160 "EHLO mail-it0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750730AbeDKEJc (ORCPT ); Wed, 11 Apr 2018 00:09:32 -0400 Received: by mail-it0-f42.google.com with SMTP id u62-v6so994249ita.5 for ; Tue, 10 Apr 2018 21:09:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=+d3nXDfmOSYxJ5Ro67/htNinJV9fkNH+mThEKcOSXPs=; b=u0PhZilOOE4iwswJKLp9p9+63Y34246ymDdysYYShUUiGiLHib80WIRLn/Ir/amyQ/ lYxdF/axwqed5SoDr/bNr6HSFe2//Torf+YyxpV7ixmUZms910JDN3FwiRwcBOp6bagm A+jOsdsz81YFdFssN3z4+hL9eXC2XCHDL98q6lHhyUThYIAHzkltwTbRd/5Gdz6Xlf5l zXO/nbJfz7nyVreB8SnTu/mLMqHYbTUc84QWZqY9fbGBF98uNyDQzAv/Sg5MfXjkMFlg xTB6gjTmHXOCjahbdxaDb2PgbDus/6neqb0qssaPdvAflYKZmkCQsOxNsdAwTD+JG5Ko /7Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=+d3nXDfmOSYxJ5Ro67/htNinJV9fkNH+mThEKcOSXPs=; b=BwuQXe5lociY4EbsVpUezGh+1CVdVEwThcfWtaX5PsNuwfarETHCDYMyZHv104VvtC W48nzyHatIajR8KwHXWOgNMWZ+7iSa41iUQiBDoIK9d/waGYqW907UuabJsL+rSDJQxj O/UgXw8liaWgNVUyyrHONLSXaqqfQWna/zlty3Wm5Ag3z1a47J/Gioxg+mfuwsdXxy3s F03bnJKZOrbSVj6Nu12YfEyb6XViIB2vQmahg6UgvalNzxzLrJs/1UsFCwrbBOpILbCI spBUmuugb3PHNkERZ9eiy0PHs5QTzqzx6kAkG2UZOHoeUlaxvzguTVeLZJNL1K7qf6Um LzSg== X-Gm-Message-State: ALQs6tAIiqhkDROzBjeCYPan9A13ap5iWJfQ+eFcG5wAexGYaMvdAgI1 RpTcgoQBR2C0vRnZefRZJQ9KFXkviGQ+a1BajAFP8Q== X-Received: by 2002:a24:4922:: with SMTP id z34-v6mr2390147ita.150.1523419771945; Tue, 10 Apr 2018 21:09:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.137.70 with HTTP; Tue, 10 Apr 2018 21:09:11 -0700 (PDT) In-Reply-To: <87d0z6ttxe.fsf@xmission.com> References: <87d0z6ttxe.fsf@xmission.com> From: Andy Lutomirski Date: Tue, 10 Apr 2018 21:09:11 -0700 Message-ID: Subject: Re: Q: Can we get rid of __copy_siginfo_to_user32? To: "Eric W. Biederman" Cc: Andy Lutomirski , X86 ML , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 10, 2018, at 6:26 PM, Eric W. Biederman wr= ote: > > > Andy, > > I am looking at copy_siginfo_to_user32 and find it very unfortunate > that x86 with _sigchld_x32 needs to be the odd man out. I am looking > at ways to simplify the special case. > > The core of the special case comes from: > exit_to_usermode_loop > do_signal > handle_signal > setup_rt_frame > > > In setup_rt_frame the code looks at ksig to see which kind of signal > frame should be written for the signal. > > This leads to the one case in the kernel where copy_siginfo_to_user32 > does not use is_ia32_syscall() or is_x32_syscall() to see which kind of > signal frame it needs to create. > > Andy, since you have been all over the entry point code in recent years > do you know if we allow tasks that can do both ia32 and x86_64 system > calls? That seems to be what we the testing of ksig to see which kind > of signal frame to setup is all about. We do :( > If we don't allow mixed abi's on x86_64 then can I see if I have a ia32 > task in setup_rt_frame by just calling is_ia32_syscall()? > > If we do allow mixed abi's do you know if it would be safe to > temporarily play with orig_ax or current_thread_info()->status? Maybe, but it=E2=80=99s a real minefield. I think the right fix is to use sa_flags's SA_X32_ABI bit instead for the sigchld bit. In general, the is_..._syscall() helpers can't be expected to return anything valid in any context other than a syscall, and handle_signal() is not a syscall. > > My goal is to write two wrappers: copy_siginfo_to_user32_ia32, and > copy_siginfo_to_user32_x32 around the ordinary copy_siginfo_to_user32. > With only a runtime test to see which ABI we need to implement. > > Aka change: >> case SIL_CHLD: >> to->si_pid =3D from->si_pid; >> to->si_uid =3D from->si_uid; >> to->si_status =3D from->si_status; >> #ifdef CONFIG_X86_X32_ABI >> if (x32_ABI) { >> to->_sifields._sigchld_x32._utime =3D from->si_utime; >> to->_sifields._sigchld_x32._stime =3D from->si_stime; >> } else >> #endif >> { >> to->si_utime =3D from->si_utime; >> to->si_stime =3D from->si_stime; >> } >> break; > to something like: >> case SIL_CHLD: >> to->si_pid =3D from->si_pid; >> to->si_uid =3D from->si_uid; >> to->si_status =3D from->si_status; >> #ifdef CONFIG_X86_X32_ABI >> if (!is_ia32_syscall()) { >> to->_sifields._sigchld_x32._utime =3D from->si_utime; >> to->_sifields._sigchld_x32._stime =3D from->si_stime; >> } else >> #endif >> { >> to->si_utime =3D from->si_utime; >> to->si_stime =3D from->si_stime; >> } >> break; > Makes sense, but can you get to sa_flags in there instead? FWIW, I have a branch here: https://git.kernel.org/pub/scm/linux/kernel/git/luto/linux.git/log/?h=3Dexe= cve that contains a *massive* cleanup of some other x86 signal stuff. I need to dust it off and test it better.