Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp661014imm; Fri, 29 Jun 2018 04:24:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcpKAM3AI5HtnYi4et9yq5sgG56P5MIqlCO1gX/l6o6+XJirMWw6H7iifYJEUGin7ppHnub X-Received: by 2002:a62:6147:: with SMTP id v68-v6mr5452077pfb.115.1530271471818; Fri, 29 Jun 2018 04:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530271471; cv=none; d=google.com; s=arc-20160816; b=qiJBYgnvDqC6o/kkfZHBI3o1y1XeZiTF0iu/DNLVDIIIYQ2volGodT1ezTRswswuWm Ipy2jKzLSq51Bsl4cPS+4zQry8J0AYPlY3wJTdwTwj9s6jgbCRsH9v4Z7ph0t4gCgoEL y2TjlqoOmS13NHInIkOEN4JiKdt5jXaaPaBt4vbQrgQEHrb9lMaFnUSbogZaFqLwXBS0 vtB007DUYrBeTlMgQgIc7AniEoBi8aOaElAFfPBVKJCE/kXq4A/SEwL5YQayaqZ5SIz7 7L0p6XG5FPCAkiXWxJHnzh3cxpEtsCWMbKJARHaX7eh/8r6rPGRB+6enUDjXtqqQOXhB hynA== 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:arc-authentication-results; bh=NWbZMmCEsVmXSWQSkjlMfTccnHcJWlkRv3CLhlf5gog=; b=YsAT81kITvDGeLBOFUsVBWtYZypmCHbuK/D30CEDiOScYiEXQZOYUIM2KHcO2ww5OF F3dB8shwvyemo068RAGpUxBFTAjp/2Gas6Px7HvWevpMeeYcJOBtWHiSn2BZUZpsPKyZ luWZ/jRKzsMHbH1k6gw4f8/a+qhjImDrrzAI02yo5hoS38bsotb8N23yhKdR0wiHMchn y0szn0MnOpLCv9UdPdDaszXqRfqtYpoyNwiExAfiqpk39mODPcMyhUwBFU/xLASYx6pS IG2+NSCRIFyfoN/vxb+CJsQWfULSGjZZgjZMicOYJztdtFOlSWM6xBF1EivQhYImdM0P UfWQ== 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 a143-v6si9708861pfd.258.2018.06.29.04.24.17; Fri, 29 Jun 2018 04:24:31 -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 S935441AbeF2LHR (ORCPT + 99 others); Fri, 29 Jun 2018 07:07:17 -0400 Received: from foss.arm.com ([217.140.101.70]:59842 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932119AbeF2LHP (ORCPT ); Fri, 29 Jun 2018 07:07:15 -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 2432F18A; Fri, 29 Jun 2018 04:07:15 -0700 (PDT) Received: from armageddon.cambridge.arm.com (armageddon.cambridge.arm.com [10.1.206.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 72CA03F266; Fri, 29 Jun 2018 04:07:09 -0700 (PDT) Date: Fri, 29 Jun 2018 12:07:06 +0100 From: Catalin Marinas To: Andrey Konovalov Cc: Dave Martin , Mark Rutland , Kate Stewart , linux-doc@vger.kernel.org, Will Deacon , Paul Lawrence , Linux Memory Management List , Alexander Potapenko , Chintan Pandya , Christoph Lameter , Ingo Molnar , Jacob Bramley , Jann Horn , Mark Brand , kasan-dev , linux-sparse@vger.kernel.org, Geert Uytterhoeven , Linux ARM , Andrey Ryabinin , Evgeniy Stepanov , Arnd Bergmann , Linux Kbuild mailing list , Marc Zyngier , Ramana Radhakrishnan , Ruben Ayrapetyan , Mike Rapoport , Dmitry Vyukov , Kostya Serebryany , Ard Biesheuvel , Greg Kroah-Hartman , Nick Desaulniers , LKML , "Eric W . Biederman" , Lee Smith , Andrew Morton , "Kirill A . Shutemov" Subject: Re: [PATCH v4 00/17] khwasan: kernel hardware assisted address sanitizer Message-ID: <20180629110706.37aqq6x4vhnblkb6@armageddon.cambridge.arm.com> References: <20180628105057.GA26019@e103592.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 28, 2018 at 08:56:41PM +0200, Andrey Konovalov wrote: > On Thu, Jun 28, 2018 at 12:51 PM, Dave Martin wrote: > > On Tue, Jun 26, 2018 at 03:15:10PM +0200, Andrey Konovalov wrote: > >> 1. By using the Top Byte Ignore arm64 CPU feature, we can store pointer > >> tags in the top byte of each kernel pointer. > > > > [...] > > > > This is a change from the current situation, so the kernel may be > > making implicit assumptions about the top byte of kernel addresses. > > > > Randomising the top bits may cause things like address conversions and > > pointer arithmetic to break. > > > > For example, (q - p) will not produce the expected result if q and p > > have different tags. > > If q and p have different tags, that means they come from different > allocations. I don't think it would make sense to calculate pointer > difference in this case. Well, there is a lot of pointer comparison in the kernel which means pointer difference. Take is_vmalloc_addr() for example, even if your patchset does not cover (IIUC) vmalloc() at the moment, this function may be called with slab addresses. Presumably they would all fail the check with a non-0xff tag but it's something needs understood. If you later add support for vmalloc(), this test would fail (as would the rb tree search in find_vmap_area(). Kmemleak would probably break as well as it makes heavy use of rb tree. Basically you need to be very clear about kernel pointer usage (with an associated tag or type) vs address range it refers to and in most cases converted to an unsigned long. See the other discussion on sparse, it could potentially be useful if we can detect the places where a pointer is converted to ulong and maybe hide such conversion behind a macro with the arm64 implementation also clearing the tag. -- Catalin