Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp271323pxa; Wed, 26 Aug 2020 10:08:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9UB4OtfmsIifogcEUwMKNwVGrBxqFxAwUVdUcraqiJcJC0Chv/EL8rF+lMVQoGYGoETkt X-Received: by 2002:a50:cbc3:: with SMTP id l3mr16013477edi.58.1598461707401; Wed, 26 Aug 2020 10:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598461707; cv=none; d=google.com; s=arc-20160816; b=SSPA+O20pte0N3uzJkvUCK2/cNKQ9+WJOkREVI2AsXwz/rlMaw54pzqbkJE97VD9uO cOL2EA5QWdvnOPPG+n86/BtPR1adQg0xVfKaYk/JMK5omKcWbQPxzWt/BLfP1lZkxYTY jD2/mhZJkEt89cHezqWGGjm9t6/ta+ua91qtxxYJsIz+b36VSTnFtDW/jv+tHpawOssh mgrHa98IKcUxEPVG6KdzWi+MGfCPeBQUanRkpAD4fNN0aS8eS7YN/G4RcIugSxQ+wcQL wtlSOauhLpw9mDep4qC+8v33NpI+ZaaffNbnrM/LqDktpI07S15RGD8uasxksSWgYGB0 bP+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=N9hG/OthHAwbrcorewE+ctzDhj62Q60L52TyPy405J0=; b=iiOXc19y81QSg7LfCwC4SAbzPRb0DAo9WYTDM6UYbcn0TWRNMQFLLlhMmU+KQgSahS uYb9u4KBv0IDOCOv8NXILp1Om1xOQGH/VDbSD0hiKBGltVggMI/ZqKsmFyRFXQEB2CbX zEm4oqVOQj5hSVjCh53ERBHhzorNMTEibrhX6L0TVfLXsOVwzy2TD+30ZCwx0NixPQaN xmqMdPm10Y4PwJyda/MHTgAnmBJW7kJngNka7gQc+q2n3R1tyJwEhB86Q3Jh1I6kQiW0 W6uJ6exlUmy0Jq23eMPBF6fV4OATqcj1ur1uJp41XNexjHIQgFMDVggtfGsu01uAOvgc Nbwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IXsZbehf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si2038337ejg.705.2020.08.26.10.08.03; Wed, 26 Aug 2020 10:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IXsZbehf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgHZRFK (ORCPT + 99 others); Wed, 26 Aug 2020 13:05:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:33370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726853AbgHZRFH (ORCPT ); Wed, 26 Aug 2020 13:05:07 -0400 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 38E7A22BF3 for ; Wed, 26 Aug 2020 17:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598461506; bh=Fp4rNpiuId6Zd1SRZaw++Fjp3anMdRDaszmTeS7uFZQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=IXsZbehfS9rUMHIUdoa09eOQCVQ3Gh0ntq3FHoKtDEBmxNo4m64QNUZgFCYV/FBvm pA0iOF4Eb1d4wGL5f7juoUUApYPt8PaUV0XRtuZ1fvkTFHbKiaCRhCTKGYqTqFGDje m7p05GH9gD2W5ZWdl9vtHaNQM1v4gDB8YxzDl5VE= Received: by mail-wr1-f46.google.com with SMTP id y3so2565658wrl.4 for ; Wed, 26 Aug 2020 10:05:06 -0700 (PDT) X-Gm-Message-State: AOAM531fJa+ClQospIBdD+Pd8fV8FX3Oipi0APFHABP6dXAGNuF8WWrs c+SkLxWHzvnOcE0pkG9vBHsfQe0qPcQvADTAl1JDyw== X-Received: by 2002:a5d:570e:: with SMTP id a14mr1919991wrv.70.1598461504645; Wed, 26 Aug 2020 10:05:04 -0700 (PDT) MIME-Version: 1.0 References: <20200825002540.3351-1-yu-cheng.yu@intel.com> <20200825002540.3351-26-yu-cheng.yu@intel.com> <2d253891-9393-44d0-35e0-4b9a2da23cec@intel.com> <086c73d8-9b06-f074-e315-9964eb666db9@intel.com> <73c2211f-8811-2d9f-1930-1c5035e6129c@intel.com> <20200826164604.GW6642@arm.com> <87ft892vvf.fsf@oldenburg2.str.redhat.com> In-Reply-To: <87ft892vvf.fsf@oldenburg2.str.redhat.com> From: Andy Lutomirski Date: Wed, 26 Aug 2020 10:04:53 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack To: Florian Weimer Cc: Dave Martin , "Yu, Yu-cheng" , Dave Hansen , Andy Lutomirski , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Weijiang Yang Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 26, 2020 at 9:52 AM Florian Weimer wrote: > > * Dave Martin: > > > On Tue, Aug 25, 2020 at 04:34:27PM -0700, Yu, Yu-cheng wrote: > >> On 8/25/2020 4:20 PM, Dave Hansen wrote: > >> >On 8/25/20 2:04 PM, Yu, Yu-cheng wrote: > >> >>>>I think this is more arch-specific. Even if it becomes a new syscall, > >> >>>>we still need to pass the same parameters. > >> >>> > >> >>>Right, but without the copying in and out of memory. > >> >>> > >> >>Linux-api is already on the Cc list. Do we need to add more people to > >> >>get some agreements for the syscall? > >> >What kind of agreement are you looking for? I'd suggest just coding it > >> >up and posting the patches. Adding syscalls really is really pretty > >> >straightforward and isn't much code at all. > >> > > >> > >> Sure, I will do that. > > > > Alternatively, would a regular prctl() work here? > > Is this something appliation code has to call, or just the dynamic > loader? > > prctl in glibc is a variadic function, so if there's a mismatch between > the kernel/userspace syscall convention and the userspace calling > convention (for variadic functions) for specific types, it can't be made > to work in a generic way. > > The loader can use inline assembly for system calls and does not have > this issue, but applications would be implcated by it. > I would expect things like Go and various JITs to call it directly. If we wanted to be fancy and add a potentially more widely useful syscall, how about: mmap_special(void *addr, size_t length, int prot, int flags, int type); Where type is something like MMAP_SPECIAL_X86_SHSTK. Fundamentally, this is really just mmap() except that we want to map something a bit magical, and we don't want to require opening a device node to do it. --Andy