Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7033630ybi; Thu, 13 Jun 2019 08:27:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvMVCdS68KO+VontEnJyyICqC9hJ6UuewwWMRCUnlw4JZa44kVkg5BwoBjYeU2u1/1NP3Y X-Received: by 2002:a17:902:7618:: with SMTP id k24mr25822055pll.208.1560439677280; Thu, 13 Jun 2019 08:27:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560439677; cv=none; d=google.com; s=arc-20160816; b=y+xAWp1QEP3T+Sj5RQPzXPXCQvdAtgv37yQyL/W9WaQtIsHIwndbGhVhMTlseftceB JVRIco3W8Y1QIHlxhnedRKOwxoUN17fRUbPgwsDgGDXTOi4l/QAA8et5XWYkkFy+q2Vw wt3N/PGK892FBy1RvlFO5qXgMKn75WZhVzwqiHXd11vD3QjG+gXJz6pcSBj87bffJN+c 1tsH5T2v+tRMnYRxwHZopbx8uwr2riSE89q9UmzthWlFE7sXtvHKz4GZXC66HiE/QT+i sIcuMau40PJGI1RpxLRmDWdwCwRaboY4Edg5ZumLsp0bldHNaFYTh2yhaK6HAcen0yho Tv8Q== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yBq9Q6KJYj9l9Pr0SLvpOdK5uu3Uc/hn4lESOkilCvA=; b=gHZ8kKcEU7/qLktXRUGqLXLoMoz38qPARfdPMnMGrMkHeebKWQ7QnczVre1xwsWHbY cdfevQyXDjtVl7K3SK47ywAV2P8w9H5geFWZPIcMJk3jOWsfAQ1XMBMomCba1kPnoEAT k6jLnMvAa7vHMOq9o3md3U4KH6wQSB3/sThSllE9KhUfzevUQLfeaamwE3qWc4jiitEu MnnE0QgtCSacQXUUjUzirRY2ouO+njuOzt8DK79Q/JnEeF6fE84A3swVEBEEODW7tqBr +TIJoBB+eH4r7KhvA17nvyBqzv9x4e/cLB28VAGc2jDfEz5TxA83+63dgy/Y3glLVQo/ p6SQ== ARC-Authentication-Results: i=1; mx.google.com; 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 n75si9109pjc.27.2019.06.13.08.27.41; Thu, 13 Jun 2019 08:27:57 -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; 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 S1727923AbfFMP0y (ORCPT + 99 others); Thu, 13 Jun 2019 11:26:54 -0400 Received: from foss.arm.com ([217.140.110.172]:42552 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbfFMP0u (ORCPT ); Thu, 13 Jun 2019 11:26: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 A46BD3EF; Thu, 13 Jun 2019 08:26:49 -0700 (PDT) Received: from C02TF0J2HF1T.local (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3FA233F718; Thu, 13 Jun 2019 08:26:36 -0700 (PDT) Date: Thu, 13 Jun 2019 16:26:32 +0100 From: Catalin Marinas To: Dave Martin Cc: Andrey Konovalov , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Mark Rutland , Szabolcs Nagy , Will Deacon , Kostya Serebryany , Khalid Aziz , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , Christoph Hellwig , Jason Gunthorpe , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Dmitry Vyukov , Greg Kroah-Hartman , Yishai Hadas , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Subject: Re: [PATCH v17 03/15] arm64: Introduce prctl() options to control the tagged user addresses ABI Message-ID: <20190613152632.GT28951@C02TF0J2HF1T.local> References: <20190613110235.GW28398@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190613110235.GW28398@e103592.cambridge.arm.com> User-Agent: Mutt/1.11.2 (2019-01-07) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dave, On Thu, Jun 13, 2019 at 12:02:35PM +0100, Dave P Martin wrote: > On Wed, Jun 12, 2019 at 01:43:20PM +0200, Andrey Konovalov wrote: > > +/* > > + * Global sysctl to disable the tagged user addresses support. This control > > + * only prevents the tagged address ABI enabling via prctl() and does not > > + * disable it for tasks that already opted in to the relaxed ABI. > > + */ > > +static int zero; > > +static int one = 1; > > !!! > > And these can't even be const without a cast. Yuk. > > (Not your fault though, but it would be nice to have a proc_dobool() to > avoid this.) I had the same reaction. Maybe for another patch sanitising this pattern across the kernel. > > --- a/include/uapi/linux/prctl.h > > +++ b/include/uapi/linux/prctl.h > > @@ -229,4 +229,9 @@ struct prctl_mm_map { > > # define PR_PAC_APDBKEY (1UL << 3) > > # define PR_PAC_APGAKEY (1UL << 4) > > > > +/* Tagged user address controls for arm64 */ > > +#define PR_SET_TAGGED_ADDR_CTRL 55 > > +#define PR_GET_TAGGED_ADDR_CTRL 56 > > +# define PR_TAGGED_ADDR_ENABLE (1UL << 0) > > + > > Do we expect this prctl to be applicable to other arches, or is it > strictly arm64-specific? I kept it generic, at least the tagged address part. The MTE bits later on would be arm64-specific. > > @@ -2492,6 +2498,16 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3, > > return -EINVAL; > > error = PAC_RESET_KEYS(me, arg2); > > break; > > + case PR_SET_TAGGED_ADDR_CTRL: > > + if (arg3 || arg4 || arg5) > > > > How do you anticipate these arguments being used in the future? I don't expect them to be used at all. But since I'm not sure, I'd force them as zero for now rather than ignored. The GET is supposed to return the SET arg2, hence I'd rather not used the other arguments. > For the SVE prctls I took the view that "get" could only ever mean one > thing, and "put" already had a flags argument with spare bits for future > expansion anyway, so forcing the extra arguments to zero would be > unnecessary. > > Opinions seem to differ on whether requiring surplus arguments to be 0 > is beneficial for hygiene, but the glibc prototype for prctl() is > > int prctl (int __option, ...); > > so it seemed annoying to have to pass extra arguments to it just for the > sake of it. IMHO this also makes the code at the call site less > readable, since it's not immediately apparent that all those 0s are > meaningless. It's fine by me to ignore the other arguments. I just followed the pattern of some existing prctl options. I don't have a strong opinion either way. > > + return -EINVAL; > > + error = SET_TAGGED_ADDR_CTRL(arg2); > > + break; > > + case PR_GET_TAGGED_ADDR_CTRL: > > + if (arg2 || arg3 || arg4 || arg5) > > + return -EINVAL; > > + error = GET_TAGGED_ADDR_CTRL(); > > Having a "get" prctl is probably a good idea, but is there a clear > usecase for it? Not sure, maybe some other library (e.g. a JIT compiler) would like to check whether tagged addresses have been enabled during application start and decide to generate tagged pointers for itself. It seemed pretty harmless, unless we add more complex things to the prctl() that cannot be returned in one request). -- Catalin