Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3969431imu; Tue, 18 Dec 2018 07:07:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBOaqx0kkJTDr4zapwi+j8BvcKd5OevY68Bblsuavh5v0GZbYOqXDAyN40LF7eclXAcv9h X-Received: by 2002:a62:fc52:: with SMTP id e79mr17172442pfh.8.1545145657265; Tue, 18 Dec 2018 07:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545145657; cv=none; d=google.com; s=arc-20160816; b=m9c4czz9NGtP+R3hq5g805dNBhEbb7GebcbRqee3MN8mzy1l9Ucb/4i2F4pMkIWkHv 87FNFQME/y02+mQr+YykBD9SE8JCymycjdYMWLQPUMpJ25H9rZVKBIGi6flyPDZ2UFWV xL/SZChkwXjkaA0/Th7pXeviaBovcU/hNG5JvHjKUS6cJCcRlDk0i4j1fLahWGzwa8p3 heTgDyxn55+kuogTdoBtHEiqPiNZDciqIX9G0zGhmzc0uJhF9rIeksrxLaWkiks/qtMF U2cPtyj7bWl6heH9vJ0VF1ZAyWeKZfDjnc0F5hqN3k27Gn34YQiZlAFT0232Yu3eV6Aw ju9g== 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=Sfl3jpT+Z6dPcoWKLdIC2EG1bdaigl5ehtSeHXXAKIU=; b=nxz0BbtR6bcSphQxPbF9fJZWOP8po2zBcNW/3K3bpM1fD2d/0P3jhCdUIAAd+k/dQe tDgn4IWhNnXDdZJHoqnoPE5jBtiLDQY5UChSfk97xvA001Is6yi2IDE4TzkX5CJVTSkO 0hz4wAW7E6xbWdA4WJxVTfCZlfFfu16EdFQfwYL6RqmNfQ2QcT33deWbxEiw7kJZrpEC dq7NTv742NtbP9DTXMzbiSCKmL/ljLc8vG5l3zkVeuvvH5CyWMmdky/sEu0snM1eiMjD CCCip7URTevuD1DByjqVma4lowUdkVl6CIKjP85hCoge+A68Pyp/sM15LvVyh7xgcgZs Cx+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="tftRytD/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si13454272plg.62.2018.12.18.07.07.21; Tue, 18 Dec 2018 07:07:37 -0800 (PST) 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=@google.com header.s=20161025 header.b="tftRytD/"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726927AbeLRPDw (ORCPT + 99 others); Tue, 18 Dec 2018 10:03:52 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:35566 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726575AbeLRPDv (ORCPT ); Tue, 18 Dec 2018 10:03:51 -0500 Received: by mail-pl1-f195.google.com with SMTP id p8so7958581plo.2 for ; Tue, 18 Dec 2018 07:03:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Sfl3jpT+Z6dPcoWKLdIC2EG1bdaigl5ehtSeHXXAKIU=; b=tftRytD/Y/atZpWfzM4JEyT85SgQxakaxsQa4NkmgL4FdrpvZG3e2148E9bgtXrSeI 1LIlHdVlV5dVPXzj0HzMIBPV9O+QFsM43gb7UDC4F9b70HVYaHAx3YagrqQ6NRnX0Eoj tVkHox5MPSXBa+QSwtGB0tZhv7Ogm9PJJ1iRZlkPOzmUEcBr62sM7OEpvcPEPcUqRDoE bkTsWB0UhRZvezXm2FgW1e30O/vfLjEB0lw/OYEZFLIKaGZbPFK9sYjxAq3PkOK9IDBs N2BqU1yBw3U60WDm8iZUuKNnCQTZetBt9HnkAZ51j7N0PmIy1OBOxbu5xbhfwL7uE6+K g1dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Sfl3jpT+Z6dPcoWKLdIC2EG1bdaigl5ehtSeHXXAKIU=; b=RVnRRWl2LLfftz4+xS8Hyhk+rPgQnPR1ZgyHmK/oA3i3vBSsZvUiGLjZxPg1C1/mYf 0rJAt8kxYfpOURNUqfmbknfydA8JIU3yGap05SXp7i/ei49xBYnjkmnMeU2/u4IP8pqO ji8gQTq6hzV/D9BRbtoLQNd52QDbX5w2qjAf3CnVI7hDyuJjBSYk5J8r1qi7a6QGcFAV xOhpShzmpU9WYAJR3Zhclo1UDtKFxoo51eNljUbQA/t2MtYfXkEz1UhCn5f6++mqNWv5 qUqtR/4NEnbAiNIS6+LTLrS9VG+o3NXtw2GuqPmvrFflyEJ/PEYVkoXLJVGv7MN4F437 rzOQ== X-Gm-Message-State: AA+aEWaVfhNl/Ou2h/DDoaM//QzDS4AE0e9pCnL9RGGdW+TM4I9d1uqd jgOoYq0g5bdn22w9DfHBFJKg4pVhMOq0HKKFHCFfCw== X-Received: by 2002:a17:902:b406:: with SMTP id x6mr15943874plr.329.1545145430285; Tue, 18 Dec 2018 07:03:50 -0800 (PST) MIME-Version: 1.0 References: <20181210143044.12714-1-vincenzo.frascino@arm.com> <20181212150230.GH65138@arrakis.emea.arm.com> In-Reply-To: <20181212150230.GH65138@arrakis.emea.arm.com> From: Andrey Konovalov Date: Tue, 18 Dec 2018 16:03:38 +0100 Message-ID: Subject: Re: [RFC][PATCH 0/3] arm64 relaxed ABI To: Catalin Marinas Cc: Vincenzo Frascino , Mark Rutland , Kate Stewart , "open list:DOCUMENTATION" , Will Deacon , Kostya Serebryany , "open list:KERNEL SELFTEST FRAMEWORK" , Chintan Pandya , Shuah Khan , Ingo Molnar , linux-arch , Jacob Bramley , Dmitry Vyukov , Evgenii Stepanov , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alexander Viro , Linux ARM , Linux Memory Management List , Greg Kroah-Hartman , LKML , Luc Van Oostenryck , Lee Smith , Andrew Morton , Robin Murphy , "Kirill A. Shutemov" 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, Dec 12, 2018 at 4:02 PM Catalin Marinas wrote: > > Hi Andrey, > > On Wed, Dec 12, 2018 at 03:23:25PM +0100, Andrey Konovalov wrote: > > On Mon, Dec 10, 2018 at 3:31 PM Vincenzo Frascino > > wrote: > > > On arm64 the TCR_EL1.TBI0 bit has been set since Linux 3.x hence > > > the userspace (EL0) is allowed to set a non-zero value in the top > > > byte but the resulting pointers are not allowed at the user-kernel > > > syscall ABI boundary. > > > > > > This patchset proposes a relaxation of the ABI and a mechanism to > > > advertise it to the userspace via an AT_FLAGS. > > > > > > The rationale behind the choice of AT_FLAGS is that the Unix System V > > > ABI defines AT_FLAGS as "flags", leaving some degree of freedom in > > > interpretation. > > > There are two previous attempts of using AT_FLAGS in the Linux Kernel > > > for different reasons: the first was more generic and was used to expose > > > the support for the GNU STACK NX feature [1] and the second was done for > > > the MIPS architecture and was used to expose the support of "MIPS ABI > > > Extension for IEEE Std 754 Non-Compliant Interlinking" [2]. > > > Both the changes are currently _not_ merged in mainline. > > > The only architecture that reserves some of the bits in AT_FLAGS is > > > currently MIPS, which introduced the concept of platform specific ABI > > > (psABI) reserving the top-byte [3]. > > > > > > When ARM64_AT_FLAGS_SYSCALL_TBI is set the kernel is advertising > > > to the userspace that a relaxed ABI is supported hence this type > > > of pointers are now allowed to be passed to the syscalls when they are > > > in memory ranges obtained by anonymous mmap() or brk(). > > > > > > The userspace _must_ verify that the flag is set before passing tagged > > > pointers to the syscalls allowed by this relaxation. > > > > > > More in general, exposing the ARM64_AT_FLAGS_SYSCALL_TBI flag and mandating > > > to the software to check that the feature is present, before using the > > > associated functionality, it provides a degree of control on the decision > > > of disabling such a feature in future without consequently breaking the > > > userspace. > [...] > > Acked-by: Andrey Konovalov > > Thanks for the ack. However, if we go ahead with this ABI proposal it > means that your patches need to be reworked to allow a non-zero top byte > in all syscalls, including mmap() and friends, ioctl(). There are ABI > concerns in either case but I'd rather have this discussion in the open. > It doesn't necessarily mean that I endorse this proposal, I would like > feedback and not just from kernel developers but user space ones. > > The summary of our internal discussions (mostly between kernel > developers) is that we can't properly describe a user ABI that covers > future syscalls or syscall extensions while not all syscalls accept > tagged pointers. So we tweaked the requirements slightly to only allow > tagged pointers back into the kernel *if* the originating address is > from an anonymous mmap() or below sbrk(0). This should cover some of the > ioctls or getsockopt(TCP_ZEROCOPY_RECEIVE) where the user passes a > pointer to a buffer obtained via mmap() on the device operations. > > (sorry for not being clear on what Vincenzo's proposal implies) OK, I see. So I need to make the following changes to my patchset AFAIU. 1. Make sure that we only allow tagged user addresses that originate from an anonymous mmap() or below sbrk(0). How exactly should this check be performed? 2. Allow tagged addressed passed to memory syscalls (as long as (1) is satisfied). Do I understand correctly that this means that I need to locate all find_vma() callers outside of mm/ and fix them up as well?