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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 64347C433E2 for ; Thu, 10 Sep 2020 14:58:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EFFA32075A for ; Thu, 10 Sep 2020 14:58:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uBOlTGMa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EFFA32075A 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 60EE290001D; Thu, 10 Sep 2020 10:58:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E60890001C; Thu, 10 Sep 2020 10:58:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FAC890001D; Thu, 10 Sep 2020 10:58:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 3820F90001C for ; Thu, 10 Sep 2020 10:58:08 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C2C83181AEF30 for ; Thu, 10 Sep 2020 14:58:07 +0000 (UTC) X-FDA: 77247457014.30.value21_50106ff270e6 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id 9DBA3180B3C8B for ; Thu, 10 Sep 2020 14:58:07 +0000 (UTC) X-HE-Tag: value21_50106ff270e6 X-Filterd-Recvd-Size: 5878 Received: from mail-qt1-f196.google.com (mail-qt1-f196.google.com [209.85.160.196]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 10 Sep 2020 14:58:07 +0000 (UTC) Received: by mail-qt1-f196.google.com with SMTP id g3so5040705qtq.10 for ; Thu, 10 Sep 2020 07:58: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=psWYZztgZCmOanZbN0KVSKVg8aC+fzD9jcmxhuC+NNI=; b=uBOlTGMa94CWWF6b+8C6NaJQaNcmte0pvB20fB/uVnBUUG8bvWgUMpgmpjaAvmfxr7 AOtJ+KbVmezhukeZRCHFU6HqC8v/EauaFyhX9aa15oWd0ENqKLPrc8KSgg30BLwgc/yj AapZ46xO0EI3jLRHYfn/B5QbXVDv9AKyvij0LRF3yZomuokQyFfGZCZuGmBYRJuT/lH+ cweg8VGv/ZI014+jDzWXQPJjA4oi3ZWbNm4yvus4D8czoI73PkA8zOT/lsnuJ0Or7lM6 Vv8DYVqjz6dYkI89w1eFdCBIcEOC0NR9mZBsy2hRME9X71MtGhDIwU80FS74v9831tWA E5wg== 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=psWYZztgZCmOanZbN0KVSKVg8aC+fzD9jcmxhuC+NNI=; b=YAP+NRFuMm7iwCQhfOusNrVjbb4zug5fWsEKvmM0RD+wSbUHmyl1IEJB+j+nvLpiYg NqyGTNeB/WPma9TCcuvn9Vidcbl/rWrohPkSbhPfcHj8yJV9EOAYgPSn4D47wllY+LRR DwV1GQT2VWjKlFnmXEYiJULaKBMdYS9kpn8pmwU30PJpdBGIns3kguyf7pwvsCZ/5Z8y M5cFeIN5QgfJSR4j8ej2Z0cgZSficQ+iXmbEJK/+v2Le3pXTyh/KiOeUn5hFoDCQQk24 Y+i0Hs9Gdy46dHrjm/UXTe6mUDfhI/d5E73LMcxX2CswZ2lAADghBTYJZkFGwRTWoWpx G0xw== X-Gm-Message-State: AOAM532ItLSJigrjVt8yxJ45kTB0QSDSxOiNIocNBFz3Yus3qPCtN9Ol T/4Gim5UIjazr21JhKkpyHpaxY9/W9+gfV76MCnjsw== X-Google-Smtp-Source: ABdhPJyXKZK4qpETW5dxMgNJ4lmga0bIB3HhLdqOmOK7G/KhIAL9x+/iQr16cfal7ToieRC4QB+fxYBPp6QW6lBF30g= X-Received: by 2002:ac8:5215:: with SMTP id r21mr8150267qtn.257.1599749886066; Thu, 10 Sep 2020 07:58:06 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-2-elver@google.com> In-Reply-To: <20200907134055.2878499-2-elver@google.com> From: Dmitry Vyukov Date: Thu, 10 Sep 2020 16:57:54 +0200 Message-ID: Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure To: Marco Elver 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: 9DBA3180B3C8B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Mon, Sep 7, 2020 at 3:41 PM Marco Elver wrote: > +config KFENCE_NUM_OBJECTS > + int "Number of guarded objects available" > + default 255 > + range 1 65535 > + help > + The number of guarded objects available. For each KFENCE object, 2 > + pages are required; with one containing the object and two adjacent > + ones used as guard pages. Hi Marco, Wonder if you tested build/boot with KFENCE_NUM_OBJECTS=65535? Can a compiler create such a large object? > +config KFENCE_FAULT_INJECTION > + int "Fault injection for stress testing" > + default 0 > + depends on EXPERT > + help > + The inverse probability with which to randomly protect KFENCE object > + pages, resulting in spurious use-after-frees. The main purpose of > + this option is to stress-test KFENCE with concurrent error reports > + and allocations/frees. A value of 0 disables fault injection. I would name this differently. "FAULT_INJECTION" is already taken for a different thing, so it's a bit confusing. KFENCE_DEBUG_SOMETHING may be a better name. It would also be good to make it very clear in the short description that this is for testing of KFENCE itself. When I configure syzbot I routinely can't figure out if various DEBUG configs detect user errors, or enable additional unit tests, or something else. Maybe it should depend on DEBUG_KERNEL as well? > +/* > + * Get the canary byte pattern for @addr. Use a pattern that varies based on the > + * lower 3 bits of the address, to detect memory corruptions with higher > + * probability, where similar constants are used. > + */ > +#define KFENCE_CANARY_PATTERN(addr) ((u8)0xaa ^ (u8)((unsigned long)addr & 0x7)) (addr) in macro body > + seq_con_printf(seq, > + "kfence-#%zd [0x" PTR_FMT "-0x" PTR_FMT PTR_FMT is only used in this file, should it be declared in report.c? Please post example reports somewhere. It's hard to figure out all details of the reporting/formatting.