From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D41EEC4741F for ; Fri, 30 Oct 2020 02:50:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 554D02076E for ; Fri, 30 Oct 2020 02:50:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="faQ03KFX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 554D02076E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B7B496B0081; Thu, 29 Oct 2020 22:50:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B28B16B0082; Thu, 29 Oct 2020 22:50:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F1A56B0083; Thu, 29 Oct 2020 22:50:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0115.hostedemail.com [216.40.44.115]) by kanga.kvack.org (Postfix) with ESMTP id 6EFCC6B0081 for ; Thu, 29 Oct 2020 22:50:16 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 052AC8249980 for ; Fri, 30 Oct 2020 02:50:16 +0000 (UTC) X-FDA: 77427062832.01.basin47_040256127292 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id DC85D1004BA7C for ; Fri, 30 Oct 2020 02:50:15 +0000 (UTC) X-HE-Tag: basin47_040256127292 X-Filterd-Recvd-Size: 5502 Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Fri, 30 Oct 2020 02:50:15 +0000 (UTC) Received: by mail-lj1-f193.google.com with SMTP id c21so5391569ljj.0 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=h/XOZBKNGqRdEtcH/WmsIafj2DNT/39S+ejO5MulENhOBDmM7DVXH1Jp1QaApaHF0B xP/sOOG4TAEPVXZL1ySThAzxYlnXmVoG/p99znOoKgvII9yXOLlIevG+Xxl9GkGna9Ph aIEmw7Ep2oXuN41EUXY9sx/c95qxdslHVm5Y6XxjJYMev7RNXw994BVpNhIXth9fouHn sstjsij/kBF7qhB+zoG5agn/0bqQTDp8aRvK9azNJkuskaE4j5MaKsHsw+DTxwxx+75K 0n5O++NWtROCQ8xehwBu6d3wPa0pgK/k7CZNiscFrjWW/J0qa40YC3QM04dIihFf21GZ vejw== X-Gm-Message-State: AOAM533VZObtmQCmYdSSkSP0BjQbH1lAFRBxACXunJ85Y450dxudZi+j TbjqK6iW3Ch2apraTAOl0s9aL0C6BbcGoMEt+ENvQQ== X-Google-Smtp-Source: ABdhPJy0sA1WwM3kiKvHJaFMz/TR3IbjqMOlo5/1P3W63q7nS9+CEqGgFqxqrIzS0II1dZBsMQzuyhJLO08x8Y27c1k= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.