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=-8.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 24986C31E46 for ; Wed, 12 Jun 2019 11:14:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC671208CA for ; Wed, 12 Jun 2019 11:14:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QkhZMvI8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438254AbfFLLOn (ORCPT ); Wed, 12 Jun 2019 07:14:43 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:33920 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726605AbfFLLOm (ORCPT ); Wed, 12 Jun 2019 07:14:42 -0400 Received: by mail-pl1-f194.google.com with SMTP id i2so6508496plt.1 for ; Wed, 12 Jun 2019 04:14:42 -0700 (PDT) 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=ICAcqmNM80YqXGU9u0yKcUq/onm/SsQo2SDs/l3f+hY=; b=QkhZMvI8xgho9eMFZ7w6J/3duhWcdGLEkVVUAU2qSaxNfXU+GXLc+PdiUdCpUn61iY 0xCUxQ9wiA1Jj7ZnvEwSzmljdVe71a10tK0t/VIk6vJ6KuoIESh9plrNP00oJ9EUV9CE 7ZXKJL/NmCDrLh5D1fRV3U/5XcSqnaFIYrJ7IhnmnWDC1y2ZQhZMwMFDrVZ4wkPjj2PR KjnNxVxOeNHsZ1yb6hgnM2H6TbZTzWPz9Cffq6e0f9rEpBuiI2bynmdfsgpQFhae4y5r LLRsk0MnIrY8OwbkGOOGkhYBEu+P7mFEBBswTcH9Mhn9r0qq9AEF/SsRyiNTxER5NtY3 eTUQ== 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=ICAcqmNM80YqXGU9u0yKcUq/onm/SsQo2SDs/l3f+hY=; b=E1NkBVg8+EYEhNKKyGFSKCqRXy0Szy91PWpKsRqUfLFCkuY5B6blX2bY0UaxAIb85p LozaHON/gRpWCTAZrm51QTJpmToEtgGw4p4shTDeSCLF1CEbuRSHvZx7q804XiIG9Ewh BcY1F18UOhdZam78TaamQa6c9nmSAvhSJ0wBU3jcF3IBdajC3B6VBzEWd7chCItSKb7Q gNZqlM9TX8OceM1yMcq/RBdEce3U90X4FbnfXwosQ5rfrTlbnnhstmi+/fpgkeY3NEhR I6mseL6Nbt3pD2Fwf8v/mskbkbA8IhZ4HSYw0qwcfLIabBHMjpqqFhUO1HIXiYQ55J+N fdvw== X-Gm-Message-State: APjAAAV4/i/X2ZJQ3xFOISGehoryyGkZm6gev/dulDv+rW78qRoWq4Ke Kgu8CC4ZbkjXpOK24Vw9HYc+pYzF3amDXch04zC0WA== X-Google-Smtp-Source: APXvYqygEZ27HGfNqszCpdSgojAf7S6ru14/DaT8Or0Syv3FL9sWDfZ+9LXBU0/5Hxbzx8tkSmaHaZjTcL+f/jghf7s= X-Received: by 2002:a17:902:8609:: with SMTP id f9mr75570344plo.252.1560338081704; Wed, 12 Jun 2019 04:14:41 -0700 (PDT) MIME-Version: 1.0 References: <9e1b5998a28f82b16076fc85ab4f88af5381cf74.1559580831.git.andreyknvl@google.com> <20190611150122.GB63588@arrakis.emea.arm.com> <20190611175037.pflr6q6ob67zjj25@mbp> In-Reply-To: <20190611175037.pflr6q6ob67zjj25@mbp> From: Andrey Konovalov Date: Wed, 12 Jun 2019 13:14:30 +0200 Message-ID: Subject: Re: [PATCH v16 16/16] selftests, arm64: add a selftest for passing tagged pointers to kernel To: Catalin Marinas Cc: Linux ARM , Linux Memory Management List , LKML , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, "open list:KERNEL SELFTEST FRAMEWORK" , Vincenzo Frascino , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy Content-Type: text/plain; charset="UTF-8" Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, Jun 11, 2019 at 7:50 PM Catalin Marinas wrote: > > On Tue, Jun 11, 2019 at 07:18:04PM +0200, Andrey Konovalov wrote: > > On Tue, Jun 11, 2019 at 5:01 PM Catalin Marinas wrote: > > > static void *tag_ptr(void *ptr) > > > { > > > static int tagged_addr_err = 1; > > > unsigned long tag = 0; > > > > > > if (tagged_addr_err == 1) > > > tagged_addr_err = prctl(PR_SET_TAGGED_ADDR_CTRL, > > > PR_TAGGED_ADDR_ENABLE, 0, 0, 0); > > > > I think this requires atomics. malloc() can be called from multiple threads. > > It's slightly racy but I assume in a real libc it can be initialised > earlier than the hook calls while still in single-threaded mode (I had > a quick attempt with __attribute__((constructor)) but didn't get far). > > Even with the race, under normal circumstances calling the prctl() twice > is not a problem. I think the risk here is that someone disables the ABI > via sysctl and the ABI is enabled for some of the threads only. OK, I'll keep the code racy, but add a comment pointing it out. Thanks! > > -- > Catalin