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,URIBL_BLOCKED,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 A9D19C433E2 for ; Tue, 8 Sep 2020 12:16:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 32A2D21D47 for ; Tue, 8 Sep 2020 12:16:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QPX3it+b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 32A2D21D47 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 A647E6B0002; Tue, 8 Sep 2020 08:16:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A14746B0037; Tue, 8 Sep 2020 08:16:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DB3E6B0055; Tue, 8 Sep 2020 08:16:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0227.hostedemail.com [216.40.44.227]) by kanga.kvack.org (Postfix) with ESMTP id 7A0766B0002 for ; Tue, 8 Sep 2020 08:16:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3E97C247F for ; Tue, 8 Sep 2020 12:16:23 +0000 (UTC) X-FDA: 77239791846.01.mist77_4607319270d4 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id 0764F1004A33A for ; Tue, 8 Sep 2020 12:16:22 +0000 (UTC) X-HE-Tag: mist77_4607319270d4 X-Filterd-Recvd-Size: 8435 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Tue, 8 Sep 2020 12:16:22 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id s13so17045103wmh.4 for ; Tue, 08 Sep 2020 05:16:22 -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:content-transfer-encoding; bh=25SuQDI0eyCRm9y5WDHzplEK9oGtQL3VKe10BEOjmTA=; b=QPX3it+b0HCvDkvbnLXnuah4CoH16gftRJ7806vrwP3qNieZtYGGzWOWb5H6s2Ymo6 tFciYxxHwZ+bLk25IzxWbtHz0zL7hPxojHfBsUJqxOPoVKqSYMw4s5Jhs4CWSe+lLKvZ c5AwWr450MpqcX6CXpFhLMMNrVYkQ9Fjd8nqLWMfFi9LnzsfdtWd0LpKQYtzz+NCxHB3 J637fA5b93NLgh+gh4KvKv3RMjqzd73wNSnuCBKM/un+6MXqTcJ0HEPCNbet4mb1L5NA cKFb0yVJxMPcpuUS6t+uXVXwP2CwZFGY4q8U86OqXN4i0oaciML3l3t5SgA2Rsr+bZIa dFfg== 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:content-transfer-encoding; bh=25SuQDI0eyCRm9y5WDHzplEK9oGtQL3VKe10BEOjmTA=; b=F3hMBMXsDiaLMTolBEqPdeS1sa+2S1GAYJO91b4fGw1DNuh9G66z2lZssv54pm5iec kGz1wPZc7/IhUxAYVg/SAVG1gjeExioSALYeDIigCxieEKtOZXqXyXPY0uSiyN7wdDEn kv4sDFZRAICi2/leT9ISPKnV52ld3AwkCviiZ5WfMtd5gTUhTBMWZ4/Ys+5vqbM0lYp7 /3C4+l0L3NqCTyjOYMkKHlwaFqnOy3fuMDGFxXhTfj7daojJ1GrWPVeL9qPDZ3fddwyC gEWc6k0dgXnDvXfpozgEAc8eHNAsVOXmmbQNemIEMLA2XFELXG/deZZs5pV7DOkRp1bo +shg== X-Gm-Message-State: AOAM533OQLBjtNr8lmHkpdgh94DFX3ys8kK6nehr++XG6zKRPN1tClZI L5GgBxcn9olqKhPf5XcVLBfLCLJSWL3QA7kk+TLiNA== X-Google-Smtp-Source: ABdhPJzNFarnK0nYdbKJBLU0NMJuC6Hpm534oaFYqrVkXTx051ncwUm57xW2hX6Fd0DEO38hfYKPpM9pZm6/JEEqxdA= X-Received: by 2002:a1c:105:: with SMTP id 5mr4078883wmb.175.1599567380842; Tue, 08 Sep 2020 05:16:20 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <4dc8852a-120d-0835-1dc4-1a91f8391c8a@suse.cz> In-Reply-To: <4dc8852a-120d-0835-1dc4-1a91f8391c8a@suse.cz> From: Alexander Potapenko Date: Tue, 8 Sep 2020 14:16:09 +0200 Message-ID: Subject: Re: [PATCH RFC 00/10] KFENCE: A low-overhead sampling-based memory safety error detector To: Vlastimil Babka Cc: Marco Elver , Andrew Morton , Catalin Marinas , Christoph Lameter , David Rientjes , Joonsoo Kim , Mark Rutland , Pekka Enberg , "H. Peter Anvin" , paulmck@kernel.org, Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , dave.hansen@linux.intel.com, Dmitriy Vyukov , 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" , linux-doc@vger.kernel.org, LKML , kasan-dev , linux-arm-kernel@lists.infradead.org, Linux Memory Management List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 0764F1004A33A 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: > Toggling a static branch is AFAIK quite disruptive (PeterZ will probably = tell > you better), and with the default 100ms sample interval, I'd think it's n= ot good > to toggle it so often? Did you measure what performance would you get, if= the > static key was only for long-term toggling the whole feature on and off (= boot > time or even runtime), but the decisions "am I in a sample interval right= now?" > would be normal tests behind this static key? Thanks. 100ms is the default that we use for testing, but for production it should be fine to pick a longer interval (e.g. 1 second or more). We haven't noticed any performance impact with neither 100ms nor bigger val= ues. Regarding using normal branches, they are quite expensive. E.g. at some point we used to have a branch in slab_free() to check whether the freed object belonged to KFENCE pool. When the pool address was taken from memory, this resulted in some non-zero performance penalty. As for enabling the whole feature at runtime, our intention is to let the users have it enabled by default, otherwise someone will need to tell every machine in the fleet when the feature is to be enabled. > > > We have verified by running synthetic benchmarks (sysbench I/O, > > hackbench) that a kernel with KFENCE is performance-neutral compared to > > a non-KFENCE baseline kernel. > > > > KFENCE is inspired by GWP-ASan [1], a userspace tool with similar > > properties. The name "KFENCE" is a homage to the Electric Fence Malloc > > Debugger [2]. > > > > For more details, see Documentation/dev-tools/kfence.rst added in the > > series -- also viewable here: > > > > https://raw.githubusercontent.com/google/kasan/kfence/Documentati= on/dev-tools/kfence.rst > > > > [1] http://llvm.org/docs/GwpAsan.html > > [2] https://linux.die.net/man/3/efence > > > > Alexander Potapenko (6): > > mm: add Kernel Electric-Fence infrastructure > > x86, kfence: enable KFENCE for x86 > > mm, kfence: insert KFENCE hooks for SLAB > > mm, kfence: insert KFENCE hooks for SLUB > > kfence, kasan: make KFENCE compatible with KASAN > > kfence, kmemleak: make KFENCE compatible with KMEMLEAK > > > > Marco Elver (4): > > arm64, kfence: enable KFENCE for ARM64 > > kfence, lockdep: make KFENCE compatible with lockdep > > kfence, Documentation: add KFENCE documentation > > kfence: add test suite > > > > Documentation/dev-tools/index.rst | 1 + > > Documentation/dev-tools/kfence.rst | 285 +++++++++++ > > MAINTAINERS | 11 + > > arch/arm64/Kconfig | 1 + > > arch/arm64/include/asm/kfence.h | 39 ++ > > arch/arm64/mm/fault.c | 4 + > > arch/x86/Kconfig | 2 + > > arch/x86/include/asm/kfence.h | 60 +++ > > arch/x86/mm/fault.c | 4 + > > include/linux/kfence.h | 174 +++++++ > > init/main.c | 2 + > > kernel/locking/lockdep.c | 8 + > > lib/Kconfig.debug | 1 + > > lib/Kconfig.kfence | 70 +++ > > mm/Makefile | 1 + > > mm/kasan/common.c | 7 + > > mm/kfence/Makefile | 6 + > > mm/kfence/core.c | 730 +++++++++++++++++++++++++++ > > mm/kfence/kfence-test.c | 777 +++++++++++++++++++++++++++++ > > mm/kfence/kfence.h | 104 ++++ > > mm/kfence/report.c | 201 ++++++++ > > mm/kmemleak.c | 11 + > > mm/slab.c | 46 +- > > mm/slab_common.c | 6 +- > > mm/slub.c | 72 ++- > > 25 files changed, 2591 insertions(+), 32 deletions(-) > > create mode 100644 Documentation/dev-tools/kfence.rst > > create mode 100644 arch/arm64/include/asm/kfence.h > > create mode 100644 arch/x86/include/asm/kfence.h > > create mode 100644 include/linux/kfence.h > > create mode 100644 lib/Kconfig.kfence > > create mode 100644 mm/kfence/Makefile > > create mode 100644 mm/kfence/core.c > > create mode 100644 mm/kfence/kfence-test.c > > create mode 100644 mm/kfence/kfence.h > > create mode 100644 mm/kfence/report.c > > > --=20 Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg