Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp796437imm; Fri, 29 Jun 2018 06:35:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJnYr24bTh20Hkyt1fm/Atr4FutA5FG0tykupsenbtkaUtgn/H788VV9qlCODq1Xg5GYCxJ X-Received: by 2002:a17:902:4381:: with SMTP id j1-v6mr14965314pld.104.1530279334810; Fri, 29 Jun 2018 06:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530279334; cv=none; d=google.com; s=arc-20160816; b=eXct5D91qk0ToRgr8FfV35lXDEsNaDyedmmUBGd/LvLgOALwsL0GI1CSu4cZ843ZRi lPEEe6CdKKt1iLvwD6ATmcnRGhb2GwjDzkf47y34IeFRdX/tju4snHe281nbXx6aVX+9 xfF1a4ADo3fIGIMsqjkfukQm/UarXvkul5Z0HZp4PYmSntYAdkojTDAUkVRi8vtkbJv+ XSgaY3LE+pBynrdlKQHBP9YK3G+5xKFiApQmClGNSNZEzNlzFDvjoVN0Nvz87sueuoMF 9VXEB8eCLvRPn9jRrmBQwQ+uh8iAOBR4tTwreYkPirghuyx+QRgk/84BCzIEHM/VD/mu ADwg== 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=RB8adx+hiCwxvvDHTBEC5GPy7jG4I2n+7088NHM0LXI=; b=O2ho1speNQ/o+DleOmgHmWZDWQiCL1/Izbv+NiZ6LnGzHb3L1jJyOuL37DSm2uMN05 imD7NcqqoPiLs2e8tAG1z9En7oy9a7of9Kpn+577Ky8vXNYbEauwAcw8zcg93UpnS7Fv UeuCG6F1uaWnss5IvbGN/kvVoYy3twJGYFzxBqD6VdvcKyg608MUNEbBD8rHlqTF0g5a +Ro092YOQHes4sR5fmEZv7W86bF0EpC3ZVSc1zaerrZql/Peu/rQsydCHPeXR9THSIwO 7H0U5jneDvybOuW0P4GUZ4HFXcHDAYtTC/4u/dftnwD148bS9OPD5TiY9iEBALsRJj8h L9Cg== 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 k15-v6si8284145pgr.286.2018.06.29.06.35.20; Fri, 29 Jun 2018 06:35:34 -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 S933545AbeF2LEe (ORCPT + 99 others); Fri, 29 Jun 2018 07:04:34 -0400 Received: from foss.arm.com ([217.140.101.70]:59654 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932078AbeF2LEb (ORCPT ); Fri, 29 Jun 2018 07:04:31 -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 9570018A; Fri, 29 Jun 2018 04:04:30 -0700 (PDT) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E02B73F266; Fri, 29 Jun 2018 04:04:24 -0700 (PDT) Date: Fri, 29 Jun 2018 12:04:22 +0100 From: Dave Martin To: Andrey Konovalov Cc: Mark Rutland , Kate Stewart , linux-doc@vger.kernel.org, Catalin Marinas , 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: <20180629110419.GC26019@e103592.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: Mutt/1.5.23 (2014-03-12) 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. It's not strictly valid to subtract pointers from different allocations in C, but it's hard to prove statically that two pointers are guaranteed to point into the same allocation. It's likely that we're getting away with it in some places today. > > Conversions, such as between pointer and pfn, may also go wrong if not > > appropriately masked. > > > > There are also potential pointer comparison and aliasing issues if > > the tag bits are ever stripped or modified. > > > > > > What was your approach to tracking down all the points in the code > > where we have a potential issue? > > I've been fuzzing the kernel built with KWHASAN with syzkaller. This > gives a decent coverage and I was able to find some places where > fixups were required this way. Right now the fuzzer is running without > issues. It doesn't prove that all such places are fixed, but I don't > know a better way to test this. Can sparse be hacked to identify pointer subtractions where the pointers are cannot be statically proved to point into the same allocation? Maybe the number of hits for this wouldn't be outrageously high, though I expect there would be a fair number. Tracking pointers that have been cast to integer types is harder. Ideally we'd want to do that, to flag up potentially problematic masking and other similar hacks. Cheers ---Dave