From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E84B6C433E2 for ; Tue, 21 Jul 2020 12:06:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D01A22065D for ; Tue, 21 Jul 2020 12:06:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729851AbgGUMGv (ORCPT ); Tue, 21 Jul 2020 08:06:51 -0400 Received: from foss.arm.com ([217.140.110.172]:38418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726919AbgGUMGv (ORCPT ); Tue, 21 Jul 2020 08:06:51 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68636D6E; Tue, 21 Jul 2020 05:06:50 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.3.181]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9AF633F66E; Tue, 21 Jul 2020 05:06:47 -0700 (PDT) Date: Tue, 21 Jul 2020 13:06:41 +0100 From: Mark Rutland To: Andy Lutomirski Cc: Gabriel Krisman Bertazi , Thomas Gleixner , LKML , kernel@collabora.com, Matthew Wilcox , Paul Gofman , Kees Cook , "open list:KERNEL SELFTEST FRAMEWORK" , Shuah Khan , will@kernel.org, catalin.marinas@arm.com Subject: Re: [PATCH v4 1/2] kernel: Implement selective syscall userspace redirection Message-ID: <20200721120516.GA84703@C02TD0UTHF1T.local> References: <20200716193141.4068476-1-krisman@collabora.com> <20200716193141.4068476-2-krisman@collabora.com> <87wo32j394.fsf@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 16, 2020 at 09:48:50PM -0700, Andy Lutomirski wrote: > On Thu, Jul 16, 2020 at 7:15 PM Gabriel Krisman Bertazi > wrote: > > > > Andy Lutomirski writes: > > > > > On Thu, Jul 16, 2020 at 12:31 PM Gabriel Krisman Bertazi > > > wrote: > > >> > > > > > > This is quite nice. I have a few comments, though: > > > > > > You mentioned rt_sigreturn(). Should this automatically exempt the > > > kernel-provided signal restorer on architectures (e.g. x86_32) that > > > provide one? > > > > That seems reasonable. Not sure how easy it is to do it, though. > > For better or for worse, it's currently straightforward because the code is: > > __kernel_sigreturn: > .LSTART_sigreturn: > popl %eax /* XXX does this mean it needs unwind info? */ > movl $__NR_sigreturn, %eax > SYSCALL_ENTER_KERNEL > > and SYSCALL_ENTER_KERNEL is hardwired as int $0x80. (The latter is > probably my fault, for better or for worse.) So this would change to: > > __vdso32_sigreturn_syscall: > SYSCALL_ENTER_KERNEL > > and vdso2c would wire up __vdso32_sigreturn_syscall. Then there would > be something like: > > bool arch_syscall_is_vdso_sigreturn(struct pt_regs *regs); > > and that would be that. Does anyone have an opinion as to whether > this is a good idea? Modern glibc shouldn't be using this mechanism, > I think, but I won't swear to it. On arm64 sigreturn is always through the vdso, so IIUC we'd certainly need something like this. Otherwise it'd be the user's responsibility to register the vdso sigtramp range when making the prctl, and flip the selector in each signal handler, which sounds both painful and fragile. Mark.