Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp272524pxa; Wed, 26 Aug 2020 10:10:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7E0/y5DLS05Sp6je/zECav0PxIjllM1pFdRQ4pmUl64oEbOsXnP9sLGbsxqNPyjvKHhDN X-Received: by 2002:a05:6402:b76:: with SMTP id cb22mr6585442edb.30.1598461806123; Wed, 26 Aug 2020 10:10:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598461806; cv=none; d=google.com; s=arc-20160816; b=YYAxoxWQsDxE1bmTmw++NH1M/fNj5yXKtChlnCokweCPK16A5UKjDOsZWwAsbN46xc ILuTDLgKH0om85CkCQ7KBHFPsz+fUqBxzBNSK2nnSo+EHQe+3yfZExVVBMv/krnJNwMU oZcVcFtKMK2Jp6p9dQ/9mwLG5FhbfNT1ipBES9EuAbk4kOrbMVNYqqOdIA9v48smAwS/ eytROYDwObHHcckYkh9mjSaomjKqssgyTNDENx2OyJXN9YbNT2lgHMgdyrUAXROWxyIR K1qtuXesIsxVoRs0tzI77BoedOGpSIEvMXSf2B43Llt5cXkIHLUfzvxhesJkCDgbiTY6 Nvgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dndwwrIMxkbCgpu7X9QwBzX+klpG9W5tpkN9wc0UDK8=; b=jPY8+ehLs/dJO2ViPJNddlobRYParNj4aIH5uF7WVUAw+B8T+1z7RmGQ9+FOLYym/1 ugL0FbVxci4N6+vVNWwutc5OVwyCwZUTHbbKRVvZhKhRRDz8vWD0Fk6fTaeFNW7I2cN3 oqVhdVPwUzbdhDxkZg30T8curNYKsGFJvX11AgBEjoeAMmIsD4aQqJjuk589wPJ4Eu4T ekwxaRyjHhkMrfroXlDAKqbb8M1PmcQaB4a1mkKbieY8UJTCQ0ymxBDJ1UDDRebUWbXy T/xNfXBUBK42KrJdM0O3LjIDzK3Iy1hNOrmwmGCYIkwb524heqlLYruu6XjCRaDUQF1X kWIA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si1810081edb.351.2020.08.26.10.09.41; Wed, 26 Aug 2020 10:10:06 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726948AbgHZRIv (ORCPT + 99 others); Wed, 26 Aug 2020 13:08:51 -0400 Received: from foss.arm.com ([217.140.110.172]:49226 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726854AbgHZRIu (ORCPT ); Wed, 26 Aug 2020 13:08:50 -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 C2A95101E; Wed, 26 Aug 2020 10:08:48 -0700 (PDT) Received: from arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0B85B3F68F; Wed, 26 Aug 2020 10:08:44 -0700 (PDT) Date: Wed, 26 Aug 2020 18:08:42 +0100 From: Dave Martin To: Florian Weimer Cc: "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 Subject: Re: [PATCH v11 25/25] x86/cet/shstk: Add arch_prctl functions for shadow stack Message-ID: <20200826170841.GX6642@arm.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87ft892vvf.fsf@oldenburg2.str.redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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 06:51:48PM +0200, 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. To the extent that this is a problem, libc's prctl() wrapper has to handle it already. New prctl() calls tend to demand precisely 4 arguments and require unused arguments to be 0, but this is more down to policy rather than because anything breaks otherwise. You're right that this has implications: for i386, libc probably pulls more arguments off the stack than are really there in some situations. This isn't a new problem though. There are already generic prctls with fewer than 4 args that are used on x86. Merging the actual prctl() and arch_prctl() syscalls doesn't acutally stop libc from retaining separate wrappers if they have different argument marshaling requirements in some corner cases. There might be some underlying reason by x86 has its own call and nobody else followed the same model, but I don't know what it is. Cheers ---Dave