Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1434418ybm; Thu, 23 May 2019 00:37:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTJydj46D6NznsEwo7TxJMbWkWna0v5MEEwYF3EKJrdoZkNTYnbxROYA2MiitZ+xp53Hty X-Received: by 2002:a63:da14:: with SMTP id c20mr33659688pgh.191.1558597035946; Thu, 23 May 2019 00:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558597035; cv=none; d=google.com; s=arc-20160816; b=ciuSIEfo3B6jEYNpI9WF+Ti4tJLz81gg+M/n2Lm12UfIECecl4fLqXi41S4KAp3mwv s2NOBvvulcdTTTbUXc8bmxwsW8YeB9tSEzHq8SfIQTr3NPUOZ37jVkUAGAQ+WvYSBeHd gwCgLULtlY14y7w9hXEKoKe1uYOhxATVhrVlHLE50CJbQqZNPRaknxXjO4qB5kuLoDic IImQ2DwqHEIEXj+inbrmKdVaAaNnZOzqVzxopim8ndoAb/DvqID9ATp7IQFixN7Dp+/c UeL6Agm0mbvjW3GhtqsmM3yPjBN3+6giPLBkUcysmZ4jB4EMCJ8AByHXxOJIzaElRXW4 4tzA== 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=IVl4LltDxPODbndeBL2zCf1BFEvRQB4sJ5VTDw4EkxQ=; b=0oyv8hNe8q6qfvZ4a61qYV9PtnAnNqs5rmIYW6Fhi7/+7q4sFlsf7sA95yJuZxT3Lt zVvB+2Wc2u3o++KA0E2fqljo1sQ/0g6fJrvrJc8fxiGOhWDNyp6POIN2WSvl2hGs29UN w10PYI3/Ze+vuNtKDijD221TLoVZqqdJZT33yi+5vQr5xLASDWFmlKyW7V4SWjo68J/5 GxMp8YfLeYgUg/x1QXUm5SqY/BwJSb1PwxRKbZfND/jxutzrDHogkOlTKbCasQfEkS/A B4+KKyvz0aK63x5fVp1QH36nxr1gaRHNPOa6UjXRAEjwKwbUsNDQx9h9mt0UJIfnTtBz +riQ== 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 e23si28590288pgl.293.2019.05.23.00.37.00; Thu, 23 May 2019 00:37:15 -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 S1728518AbfEWHeg (ORCPT + 99 others); Thu, 23 May 2019 03:34:36 -0400 Received: from foss.arm.com ([217.140.101.70]:39058 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbfEWHef (ORCPT ); Thu, 23 May 2019 03:34:35 -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 AF17480D; Thu, 23 May 2019 00:34:34 -0700 (PDT) Received: from MBP.local (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89C463F575; Thu, 23 May 2019 00:34:28 -0700 (PDT) Date: Thu, 23 May 2019 08:34:25 +0100 From: Catalin Marinas To: enh Cc: Evgenii Stepanov , Kees Cook , Andrey Konovalov , Khalid Aziz , 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 , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Dmitry Vyukov , Kostya Serebryany , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Luc Van Oostenryck , Dave Martin , Kevin Brodsky , Szabolcs Nagy Subject: Re: [PATCH v15 00/17] arm64: untag user pointers passed to the kernel Message-ID: <20190523073425.GA43379@MBP.local> References: <20190517144931.GA56186@arrakis.emea.arm.com> <20190521182932.sm4vxweuwo5ermyd@mbp> <201905211633.6C0BF0C2@keescook> <20190522101110.m2stmpaj7seezveq@mbp> <20190522163527.rnnc6t4tll7tk5zw@mbp> <201905221316.865581CF@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 On Wed, May 22, 2019 at 04:09:31PM -0700, enh wrote: > On Wed, May 22, 2019 at 4:03 PM Evgenii Stepanov wrote: > > On Wed, May 22, 2019 at 1:47 PM Kees Cook wrote: > > > On Wed, May 22, 2019 at 05:35:27PM +0100, Catalin Marinas wrote: > > > > I would also expect the C library or dynamic loader to check for the > > > > presence of a HWCAP_MTE bit before starting to tag memory allocations, > > > > otherwise it would get SIGILL on the first MTE instruction it tries to > > > > execute. > > > > > > I've got the same question as Elliot: aren't MTE instructions just NOP > > > to older CPUs? I.e. if the CPU (or kernel) don't support it, it just > > > gets entirely ignored: checking is only needed to satisfy curiosity > > > or behavioral expectations. > > > > MTE instructions are not NOP. Most of them have side effects (changing > > register values, zeroing memory). > > no, i meant "they're encoded in a space that was previously no-ops, so > running on MTE code on old hardware doesn't cause SIGILL". It does result in SIGILL, there wasn't enough encoding left in the NOP space for old/current CPU implementations (in hindsight, we should have reserved a bigger NOP space). As Evgenii said, the libc needs to be careful when tagging the heap as it would cause a SIGILL if the HWCAP_MTE is not set. The standard application doesn't need to be recompiled as it would not issue MTE colouring instructions, just standard LDR/STR. Stack tagging is problematic if you want to colour each frame individually, the function prologue would need the non-NOP MTE instructions. The best we can do here is just having the (thread) stacks of different colours. -- Catalin