Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp949182pxx; Thu, 29 Oct 2020 19:54:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwePuRnp4GhQuN7oqp4NRyT7wqTtfWf206G0KA1TWjm/4l/NKtL9+C0EF2T+g1jTkXyHSrS X-Received: by 2002:a17:906:3b8f:: with SMTP id u15mr393564ejf.348.1604026462794; Thu, 29 Oct 2020 19:54:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604026462; cv=none; d=google.com; s=arc-20160816; b=gGHrcLouuSB9Cz1BPKNTJjP50GYDyV71qutZmO9MNxiD2oMr4Q6Y3mS1PJWCOmNmD+ iSU+HoFuydHosoPzf2U2UCXLT8B8ZyW1UOo7EfR0v9HdjULhWQP5tKBhCPW+stNV57zr 4wfUiOVuEz09bCEIunXhJid9hmirszTdjBJtoja3XKHvNUv6OGqewMgFRaNIVSPN98If c8fBH9/5z+5jixk6EEYE2Y5faGvRt1PFe7c1k2itmLiObVzEncUzWiAd5XNxbcwTmZdC e3TYO3SoF1iipEarTuVf8AmVChhYyUznMRhxJpj11uqSZi42+5x/zMuHpZXzFn0tt/Y8 SQqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=29/mvfnx5ijMJBRqUvdSEy/Y/vTbwUpvdNL7Ey86vSQ=; b=eb4XKIvmirGQADl+HCgjyFpxwt9SC0CySz4k0Q4wvNnTrMQD56iGI+nPM2XbN1Byij hGtUkLbtebCiVWIG0xkPDniFY4GbUpfSFUCkF3Gq5RoqSCHwYiWoPApfWj6pBDgr3VXl dzHOSLRui5JUEhxZTVO09XiT+8UZbH8IhGKno5UBwxb+mpT4sUUenKI5SALEM+GhYgfo zngi0tmom1Jecja5jp2CoCS9Eg+I7TdJ0b9jN4Zke2l/fbKGeOcjlTaaZ4s1vopqtNQQ IaRLiNhH25I3UUkwb0G9m1y27ifVU+HplQaKMG5pEPEURhvvRf8GHjwIJwlMx2uLKvHM bjIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=faQ03KFX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id y16si1179584edq.162.2020.10.29.19.54.00; Thu, 29 Oct 2020 19:54:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=faQ03KFX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726311AbgJ3CuQ (ORCPT + 99 others); Thu, 29 Oct 2020 22:50:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725963AbgJ3CuQ (ORCPT ); Thu, 29 Oct 2020 22:50:16 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8087C0613CF for ; Thu, 29 Oct 2020 19:50:15 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id d24so5306391ljg.10 for ; Thu, 29 Oct 2020 19:50:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=29/mvfnx5ijMJBRqUvdSEy/Y/vTbwUpvdNL7Ey86vSQ=; b=faQ03KFXKTqcZsL9fNFS449tMLuSCnxgJhFtKnocwN9b8EWh6TdCML+T98o4vgW7Bu XCQiDVChwaKfpII7QJ2X4N5GwQ1TPBeAjfsX/8MLjFClRaQq+OqOOfP+roZR/UGlXVbb 4YgxL9/KNeIMCBpTL8YLMVECSbAzn3aDvGoLs04L1RJZGeLUvrTQRykq5sSoL1e+g9wg h7UL/N4Xs7ifr6BQXsfIqsuv9NA8kAuUtAe3XL1FrrBskNV6jNxlegPBEkzQoyGx4ZGK XDJ6FzSnZVFU10lqVIb2wCF7ByrUQ9rGD6xhdqwFvzrziUaCOySrO9CoTcPqUBJKDnBT MNUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=29/mvfnx5ijMJBRqUvdSEy/Y/vTbwUpvdNL7Ey86vSQ=; b=H0PVU/q59xd/xEgi+Nem2ii+Yugnw2dxBOsC+KnOW81vinYJKsz3UFvO2qKawFy6ky /0gywFHGFPV0BH0nfKGPfM78lj0vHNMcCNgYWWbBII4kFvewREtqfGlm0nbh1yY/cSlt ru5O4pLLVPDmUrvcboWKoExrQ2fQYsbt0WCR4HkUrOTRwN0HiLfHr4cUg9lru0nLCSh3 U6hHh0qlGWl+V8CDRU6x/UIb67K6FpeEGp/8OBEZQoK/FuuwLZ+LZmW756jb4sskUK1A XNaqEA445+z0uptEpAA8/2HPPHnTDmGsrBRSSwKm1LwftSngdir3dlVFnFSYdCBMOhTQ yHsw== X-Gm-Message-State: AOAM532eL43GsDcHBgm1MZXVBBs7REwHB1H7Fywqb1xpOTUJbKEw6czx p4owthYbixNcd/WEkU2654oDsgYTTLTtPI+D+WB+9w== X-Received: by 2002:a2e:9f13:: with SMTP id u19mr101336ljk.160.1604026214056; Thu, 29 Oct 2020 19:50:14 -0700 (PDT) MIME-Version: 1.0 References: <20201029131649.182037-1-elver@google.com> <20201029131649.182037-7-elver@google.com> In-Reply-To: <20201029131649.182037-7-elver@google.com> From: Jann Horn Date: Fri, 30 Oct 2020 03:49:47 +0100 Message-ID: Subject: Re: [PATCH v6 6/9] kfence, kasan: make KFENCE compatible with KASAN To: Marco Elver Cc: Andrew Morton , Alexander Potapenko , "H . Peter Anvin" , "Paul E . McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Catalin Marinas , Christoph Lameter , Dave Hansen , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Hillf Danton , Ingo Molnar , Jonathan Cameron , Jonathan Corbet , Joonsoo Kim , joern@purestorage.com, Kees Cook , Mark Rutland , Pekka Enberg , Peter Zijlstra , SeongJae Park , Thomas Gleixner , Vlastimil Babka , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , kernel list , kasan-dev , Linux ARM , Linux-MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 29, 2020 at 2:17 PM Marco Elver wrote: > We make KFENCE compatible with KASAN for testing KFENCE itself. In > particular, KASAN helps to catch any potential corruptions to KFENCE > state, or other corruptions that may be a result of freepointer > corruptions in the main allocators. > > To indicate that the combination of the two is generally discouraged, > CONFIG_EXPERT=y should be set. It also gives us the nice property that > KFENCE will be build-tested by allyesconfig builds. > > Reviewed-by: Dmitry Vyukov > Co-developed-by: Marco Elver > Signed-off-by: Marco Elver > Signed-off-by: Alexander Potapenko Reviewed-by: Jann Horn with one nit: [...] > diff --git a/mm/kasan/common.c b/mm/kasan/common.c [...] > @@ -141,6 +142,14 @@ void kasan_unpoison_shadow(const void *address, size_t size) > */ > address = reset_tag(address); > > + /* > + * We may be called from SL*B internals, such as ksize(): with a size > + * not a multiple of machine-word size, avoid poisoning the invalid > + * portion of the word for KFENCE memory. > + */ > + if (is_kfence_address(address)) > + return; It might be helpful if you could add a comment that explains that kasan_poison_object_data() does not need a similar guard because kasan_poison_object_data() is always paired with kasan_unpoison_object_data() - that threw me off a bit at first.