Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp297272imm; Thu, 28 Jun 2018 20:34:59 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJjcwwY4yUfmqXCiZpP4BqWEEC/DahaUKLLUT2+VAG5oRGhYZlU8L1qZfBQTA5HEUsa0RUz X-Received: by 2002:a17:902:8a94:: with SMTP id p20-v6mr12946555plo.258.1530243299724; Thu, 28 Jun 2018 20:34:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530243299; cv=none; d=google.com; s=arc-20160816; b=0XOMmvhXGlvvH0ZbXmNhvChb4ro6w59z8MqPRrs9ctJOo9JDckNK6XJYbGcVdK8Fbh UsJmrKyueejvvsYZSTbC5OUzi2hu1rlFXFx1eh7qesLy+k1dkCTRLGrMp5KpYMIXF0hR Toh0bE1sNL+Tw65MeFoo2kmh+PSTV7XJtgnQoKxCpvBIGnzdG+uBjCyUoy+vhSOzWxO5 cFZ5DkqaqInTz7ReVjKaSBqaYVlFyBNQTU8bneXeD7CZWQpOrPFuK36BVaYHwP/mdwR9 5rBvzd7eZMPd++fNXgTv52tuILGOiCkKByi46xuo6Az6PEDtSkenKpxE5AKb53+wMpK/ o+MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=QJLredR/79RWGbFALXpSskfLR/m9zdyp+5Dp0TDoMmQ=; b=HcDckPL8AAgKDbSa1Y7d+Zj7isar4APg+etZGMVH8Jgwvf2sLO2JJOvyQ024Zo0h+J meXSXMMGn/8x5BI59HhyfjwfYqQXRWXw/b4JozQrd/TnOdyuGks1nZ/ta7H+02eYpxfv kDck2Txa5RQ5N3JjOciw8tXKYPvAsrj1w45MVUpo7Rlfq+Tpb+VzjSMKnoggOyAFkP3F gpf5uWN7k7lUJM2WiEu1r4g2TAWurIkEXrPcdCaBFauGIh69haCAOV+vhynzB1Af7BzZ sRX30h8y6KYpQICkRU/9GE335uNyziI1yaweKp2VGJzUIL3FQY8wgEvAwbHt5Hp9O0zK ZYow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rRTk85np; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2-v6si3035545pfg.126.2018.06.28.20.34.43; Thu, 28 Jun 2018 20:34:59 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=rRTk85np; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935436AbeF1S4r (ORCPT + 99 others); Thu, 28 Jun 2018 14:56:47 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:36318 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935200AbeF1S4n (ORCPT ); Thu, 28 Jun 2018 14:56:43 -0400 Received: by mail-it0-f68.google.com with SMTP id j135-v6so14087078itj.1 for ; Thu, 28 Jun 2018 11:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=QJLredR/79RWGbFALXpSskfLR/m9zdyp+5Dp0TDoMmQ=; b=rRTk85npRi7cYyKqwob9tgl8hYK1TDhfXTgwv5VWLghPmtm8ukMbpvhG3wbOJX63tM cCX7rWPjhhUdQUVLLkO9YbtGEwsa4sD010Tgdem17PELExPWWCXEcPXdm7IWypHFW4TV hOsa1l52cSFcieTAI8fn5APPmiRmvuqamKpGPMeFR/Zul9gX3ZmjdKjyN2WiWMwamhIF +UmR/KK8NhnTAoxEzr9AWRX2gtEW1LzYzfsU/DoDi6a6+axs7EeNT/sUQtJThv5moP77 KqToVIXy7GwItZWdymlOOrdksJs++lOvr5c9slRzuFiokJOJ2/Dmr3IGXYI/rXi5oaXH Ibvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QJLredR/79RWGbFALXpSskfLR/m9zdyp+5Dp0TDoMmQ=; b=p9SLRNqdStER43yIurieN47yKMReLT1iUo8aSdk1agx3A98ESlHocDIYwAH1g//stY ciG/DDaNPRidtBv6kY05IaAV4MIjBItijxqWS1Y75NRpnbzL/TF7hd7gy4k+lHReLFm5 DWT3sRWMH1yZDAoUOVPvVNVVnEvSrvImJ8GT2tHK9u8ji5bmevGgqKtUsW9ropkxYebj f684abdnlIfCakrOpjDq/afASBnS7SGEfZqYFzqOdVqrkxvVKJNgwf13RqgstLPu9uIt BKqtDLJ8rvSb6FPyC8v5nVAg5iJJnDBYMRTMn4TqK2n3t1Wy2DRTNbI0Shat7a2ZkWjH v/IQ== X-Gm-Message-State: APt69E1NGL6ZCgdxfLkN8l9tA6LcXbYUpixfd4enVHuwBPvd1ATbuWmR ZaZZvCNjZrPErgbPKkXjwiLGV5JWk72zg2KxN4BU/w== X-Received: by 2002:a24:4c6:: with SMTP id 189-v6mr9696835itb.53.1530212202616; Thu, 28 Jun 2018 11:56:42 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a02:9082:0:0:0:0:0 with HTTP; Thu, 28 Jun 2018 11:56:41 -0700 (PDT) In-Reply-To: <20180628105057.GA26019@e103592.cambridge.arm.com> References: <20180628105057.GA26019@e103592.cambridge.arm.com> From: Andrey Konovalov Date: Thu, 28 Jun 2018 20:56:41 +0200 Message-ID: Subject: Re: [PATCH v4 00/17] khwasan: kernel hardware assisted address sanitizer To: Dave Martin Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Mark Rutland , Nick Desaulniers , Marc Zyngier , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev , linux-doc@vger.kernel.org, LKML , Linux ARM , linux-sparse@vger.kernel.org, Linux Memory Management List , Linux Kbuild mailing list , Chintan Pandya , Jacob Bramley , Jann Horn , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Mark Brand , Ramana Radhakrishnan , Evgeniy Stepanov Content-Type: text/plain; charset="UTF-8" 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 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. > > 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.