Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp551407img; Fri, 22 Mar 2019 03:49:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvqzQLRkN0rGeEYNsmCqfZbSCWR1gYkqkQr/zKBZu2z8Ban5g/A6Kc2wZ8Xfv/Itn5yZ9M X-Received: by 2002:a17:902:9688:: with SMTP id n8mr8866107plp.133.1553251792267; Fri, 22 Mar 2019 03:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553251792; cv=none; d=google.com; s=arc-20160816; b=Stldzmpr3IpQ7BwEeM/1LKUV0dRDlmNy74bJHvMnYpnYRj2dqmddCpTQBx0pNVinMn jjW7mMUKhARK0syQZ0DpiYO3cpGALT/u9ATqM3NIXD4XOsp/+G4/qmv1w6R7kkE5ZrxZ a4gGhDSczbMOfJ9uTsrHtdyIibPSa3mWoA+cC2NdQqEXTa3DeXL/3+mlGy3BDzpKtfZt kSl6FVj665I3gRDLry3CHyb/onAPyAidXZu0F8hWv9+uv5w6H/1iSgK21gHvkGmQmGKb z03ZsfMKR4KA1Bka1E4dM/1KDh0Scd6XJsUHfEbTS/dxAr5zi9/D03LrMqEzZEPyVQYF ID+w== 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=+0wnXzeAJwW6uvDrnRfuljM8QnBbXgPjVPYb690Xkzg=; b=AZPrVZDOF0jGXXK/7h7q0yx9k/WpoCQUi8EkE5E4AMLMLzkgFh1EhE/xqy4ppwMCDw P2yg5m7+6xh9+SW+vYUH6w9aIu48XA/8ijio2Ro3YURGMke8arVSgJHnRH61/YL6+/Px OJg69c9Yb4bNsKbdGxOihjddpJQG96QXxzeXL1+6Wn4b8AcarhZh9v8ZeMQoL/O572gh NIEC2C0zshbyhhpdV8JZahkdYFGHhXEOgT7oMArImKjrTUghA7ndqI7rzaIxh15h4NXb JSA46O7UwUld6Nm/xBeWDFNUlR80VGqsCacEz/oPx13xGL5CCfbJ5e6H2TLmU7bFXE3t AOLA== 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 14si2984003pgv.248.2019.03.22.03.49.36; Fri, 22 Mar 2019 03:49:52 -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 S1728071AbfCVKsu (ORCPT + 99 others); Fri, 22 Mar 2019 06:48:50 -0400 Received: from foss.arm.com ([217.140.101.70]:41654 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727867AbfCVKsu (ORCPT ); Fri, 22 Mar 2019 06:48:50 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 35A5C374; Fri, 22 Mar 2019 03:48:49 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E58943F575; Fri, 22 Mar 2019 03:48:42 -0700 (PDT) Date: Fri, 22 Mar 2019 10:48:40 +0000 From: Catalin Marinas To: Amit Daniel Kachhap Cc: Vincenzo Frascino , LAK , linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Kate Stewart , Mark Rutland , Peter Zijlstra , Will Deacon , Alexei Starovoitov , Kostya Serebryany , Eric Dumazet , Chintan Pandya , Shuah Khan , Ingo Molnar , Jacob Bramley , Daniel Borkmann , Szabolcs Nagy , Steven Rostedt , Dave Martin , Evgeniy Stepanov , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Kevin Brodsky , Arnaldo Carvalho de Melo , Graeme Barnes , Alexander Viro , Dmitry Vyukov , Branislav Rankov , Ramana Radhakrishnan , Greg Kroah-Hartman , Luc Van Oostenryck , Lee Smith , Andrew Morton , Robin Murphy , "David S. Miller" , "Kirill A . Shutemov" Subject: Re: [PATCH v2 2/4] arm64: Define Documentation/arm64/elf_at_flags.txt Message-ID: <20190322104839.GA13384@arrakis.emea.arm.com> References: <20190318163533.26838-1-vincenzo.frascino@arm.com> <20190318163533.26838-3-vincenzo.frascino@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 11:52:37AM +0530, Amit Daniel Kachhap wrote: > On Mon, Mar 18, 2019 at 10:06 PM Vincenzo Frascino > wrote: > > +Example of correct usage (pseudo-code) for a userspace application: > > + > > +bool arm64_syscall_tbi_is_present(void) > > +{ > > + unsigned long at_flags = getauxval(AT_FLAGS); > > + if (at_flags & ARM64_AT_FLAGS_SYSCALL_TBI) > > + return true; > > + > > + return false; > > +} > > + > > +void main(void) > > +{ > > + char *addr = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, > > + MAP_ANONYMOUS, -1, 0); > > + > > + int fd = open("test.txt", O_WRONLY); > > + > > + /* Check if the relaxed ABI is supported */ > > + if (arm64_syscall_tbi_is_present()) { > > + /* Add a tag to the pointer */ > > + addr = tag_pointer(addr); > > + } > > + > > + strcpy("Hello World\n", addr); > > Nit: s/strcpy("Hello World\n", addr)/strcpy(addr, "Hello World\n") Not exactly a nit ;). > > + > > + /* Write to a file */ > > + write(fd, addr, sizeof(addr)); I presume this was supposed to write "Hello World\n" to a file but sizeof(addr) is 1. Since we already support tagged pointers in user space (as long as they are not passed into the kernel), the above example could tag the pointer unconditionally and only clear it before write() if !arm64_syscall_tbi_is_present(). -- Catalin