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 A8BD7C433E2 for ; Fri, 11 Sep 2020 13:01:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0E11122483 for ; Fri, 11 Sep 2020 13:01:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T96RFKKM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E11122483 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 3F141900002; Fri, 11 Sep 2020 09:01:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3A1518E0001; Fri, 11 Sep 2020 09:01:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28FE5900002; Fri, 11 Sep 2020 09:01:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 146F18E0001 for ; Fri, 11 Sep 2020 09:01:10 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id CA70A1DEA for ; Fri, 11 Sep 2020 13:01:09 +0000 (UTC) X-FDA: 77250791058.19.rain26_5507c79270ee Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id ECD271ACC3A for ; Fri, 11 Sep 2020 13:01:07 +0000 (UTC) X-HE-Tag: rain26_5507c79270ee X-Filterd-Recvd-Size: 6866 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Sep 2020 13:01:06 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id h17so8287275otr.1 for ; Fri, 11 Sep 2020 06:01:06 -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=ge/FjJXhyj8+NsSSsvCMLGtUiAk37fA1+cTelebZ4Go=; b=T96RFKKMbfGXmGKQW/wQkQusFFYQX5igqwU6L75Yeso5+r11VBgv0lztFH9rNbHlY3 5B0LrTTcrBZveyQWzWcwQCKeRcyEas+n8CGz3zVLjk3BHBmngz6iniRoFzLHyeCEKgD0 SfihZ41/sKpTvQWRFJLJgc9OiULTEBppsdBLOZxSHyOPU/g9QcvvDXQh4dY//h83F68D ESzkFo2LP1uYXPiZlMAQQce8uhNDJFIRPkcEU8JQ+J90kOfx32MrFwTnj/mS1FW0RD1e qGrx8cYDqjBlz9uoLUveNlE+9hLQk8moh/ndBUm2Yp5Ev3Kn7jiVpo/Fnwdz/WXss1W+ TXHA== 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=ge/FjJXhyj8+NsSSsvCMLGtUiAk37fA1+cTelebZ4Go=; b=lr3O6h3WCqQze1qQu2LCNrp26gXuUaKM8KN9cXLGBAWkAE7fUDNbrwpHWS3PfHoaNn lJCFXb/W9DeAS19gS2T0v+vd0d8ZM28+rfgZtjhitDus5ny9yHjR5xh5MkC6fnQVS/0b 05GH/oSSMCNgS3GxaGPfs0br8DGJGU0wxHHdftdQcGwSWJ88YJVSfl16kqvYWvQ4pVfr UUeSdSwQKXgyCZeqaKQ1lPOHURuybfoieZjk4dfToqL5W0OLNGHm30XMP9KWi4vHjkkU 0sGYut1RYzi1wc7UneqLsx+xtQUe3Fp7amirTK7odIY+Kw3wNE5oBUb6BKSPHOdDlQ5j vCmw== X-Gm-Message-State: AOAM533ySoGyzCLW29o3DZ6LzYhi+Kg/r30QyxFWqChZBVFXBqch8eZ1 SOkww2+q+g93z1cQmIFndsPHVfVvbVN6pa3+ASYXYg== X-Google-Smtp-Source: ABdhPJyvnEkxpzeJQj2l5oqacEmEr9jCCxehUw6cPnNOvxF93kxRylc4qW/tdBx2vsUZCsc/aeHXDTxenucOjpbTbWU= X-Received: by 2002:a9d:758b:: with SMTP id s11mr1038835otk.251.1599829266141; Fri, 11 Sep 2020 06:01:06 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-7-elver@google.com> In-Reply-To: From: Marco Elver Date: Fri, 11 Sep 2020 15:00:54 +0200 Message-ID: Subject: Re: [PATCH RFC 06/10] kfence, kasan: make KFENCE compatible with KASAN To: Dmitry Vyukov Cc: Alexander Potapenko , Andrew Morton , Catalin Marinas , Christoph Lameter , David Rientjes , Joonsoo Kim , Mark Rutland , Pekka Enberg , "H. Peter Anvin" , "Paul E. McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Dave Hansen , Eric Dumazet , Greg Kroah-Hartman , Ingo Molnar , Jann Horn , Jonathan Corbet , Kees Cook , Peter Zijlstra , Qian Cai , Thomas Gleixner , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux-MM Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: ECD271ACC3A X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 Fri, 11 Sep 2020 at 09:05, Dmitry Vyukov wrote: > > On Mon, Sep 7, 2020 at 3:41 PM Marco Elver wrote: > > > > From: Alexander Potapenko > > > > 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. > > > > Co-developed-by: Marco Elver > > Signed-off-by: Marco Elver > > Signed-off-by: Alexander Potapenko > > --- > > lib/Kconfig.kfence | 2 +- > > mm/kasan/common.c | 7 +++++++ > > 2 files changed, 8 insertions(+), 1 deletion(-) > > > > diff --git a/lib/Kconfig.kfence b/lib/Kconfig.kfence > > index 7ac91162edb0..b080e49e15d4 100644 > > --- a/lib/Kconfig.kfence > > +++ b/lib/Kconfig.kfence > > @@ -10,7 +10,7 @@ config HAVE_ARCH_KFENCE_STATIC_POOL > > > > menuconfig KFENCE > > bool "KFENCE: low-overhead sampling-based memory safety error detector" > > - depends on HAVE_ARCH_KFENCE && !KASAN && (SLAB || SLUB) > > + depends on HAVE_ARCH_KFENCE && (!KASAN || EXPERT) && (SLAB || SLUB) > > depends on JUMP_LABEL # To ensure performance, require jump labels > > select STACKTRACE > > help > > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > > index 950fd372a07e..f5c49f0fdeff 100644 > > --- a/mm/kasan/common.c > > +++ b/mm/kasan/common.c > > @@ -18,6 +18,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -396,6 +397,9 @@ static bool __kasan_slab_free(struct kmem_cache *cache, void *object, > > tagged_object = object; > > object = reset_tag(object); > > > > + if (is_kfence_address(object)) > > + return false; > > Is this needed? > At least in the slab patch I see that we do : > > if (kfence_free(objp)) { > kmemleak_free_recursive(objp, cachep->flags); > return; > } > > before: > > /* Put the object into the quarantine, don't touch it for now. */ /* > Put the object into the quarantine, don't touch it for now. */ > if (kasan_slab_free(cachep, objp, _RET_IP_)) if > (kasan_slab_free(cachep, objp, _RET_IP_)) > return; return; > > > If it's not supposed to be triggered, it can make sense to replace > with BUG/WARN. It is required for SLUB. For SLAB, it seems it might not be necessary. Making the check in kasan/common.c conditional on the allocator seems ugly, so I propose we keep it there. Thanks, -- Marco