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 D99FCC43457 for ; Fri, 16 Oct 2020 15:52:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3911120848 for ; Fri, 16 Oct 2020 15:52:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iyAo2KZU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3911120848 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 5DAEA6B0072; Fri, 16 Oct 2020 11:52:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B5ED6B0073; Fri, 16 Oct 2020 11:52:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C8536B0074; Fri, 16 Oct 2020 11:52:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 1A9186B0072 for ; Fri, 16 Oct 2020 11:52:30 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 606AB3623 for ; Fri, 16 Oct 2020 15:52:29 +0000 (UTC) X-FDA: 77378230818.04.frogs79_620a0852721e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 40D29800885F for ; Fri, 16 Oct 2020 15:52:29 +0000 (UTC) X-HE-Tag: frogs79_620a0852721e X-Filterd-Recvd-Size: 7727 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Fri, 16 Oct 2020 15:52:28 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id o8so1506657pll.4 for ; Fri, 16 Oct 2020 08:52:28 -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=571s3sQDBAJDkliF7o6LeQ1FWJNszmME0SBRVCm2JiM=; b=iyAo2KZUzj/LDn6ZFkYiu45BJo1ppdpiLdRMB8QctbZlFzkRt9+FYS4/OwxHbehUn2 qZLecRkAGcVurCFpj3AwynSk0e8iyWpALAfP7Ske/9e2LLYxBhQRgAhxgczpE7ofzXr2 nibB6sC4bTNjJBPnTBkXigHYvob4uNHerEueF76qg0gp0RtqVK/e5kVLTeIufqX65EPf PIwdXS5p2lv6SvcyhEARhTiEnhX4fKYJ1Qq6bzErIXaiDetXf4oQDYjUhGPIuAaULwwx wT+WwOWW6INhnwvfaKb4s7bLAtb1VXM+ZaFunxxetlDMKRCFtl14XXOq6oGlH3j6+Gxr OTUQ== 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=571s3sQDBAJDkliF7o6LeQ1FWJNszmME0SBRVCm2JiM=; b=Pe2QYDXzFIXYtrstMJ9GShfl7h94163aPKdsq/1jn/l7ZEZ33XLwEyCIVmcH54Qfmh fPvC7Z6H5NFs/NmQM4YxdT0ZqV9Il9U1B9KNlOQlIv7b6JX/qYvy4/XEA5ipj7H7XZK4 aJ0mniNnm2E/5qHcdkndJfJTom/LHDtNSisRvdngJAnF7BZ9JaqontVAky0pGuw7Uucd Ol3eDxCSu9EG0qJ2VrLLxYpoiQZuGp/U77f242rYjidx2swMg3pSfgMffSFQviqq6XAy 2q+9QSIQ51qAi6GkxP18K0FfQtSsCO2wT/2QT4RqwRJNpljLbXDijskd/07yekwthQuz WhIQ== X-Gm-Message-State: AOAM531VI37VzhGZpJ2aT1TAEqmjMUorsmYejlGLGzsFYvibHFE8xAT4 2vp10FawlXJPIDiRktuiuqZSh55xNbK6IM7/lx4TVA== X-Google-Smtp-Source: ABdhPJxJesxysHwAqwIXLA6gTLyxc6p37UMDFD2+P+vU71kz7jc7JylNAaTUW5g0O3A4qrZWkpDGOGxtrvrUuilCYNA= X-Received: by 2002:a17:902:d888:b029:d0:cb2d:f274 with SMTP id b8-20020a170902d888b02900d0cb2df274mr4625974plz.13.1602863547567; Fri, 16 Oct 2020 08:52:27 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andrey Konovalov Date: Fri, 16 Oct 2020 17:52:16 +0200 Message-ID: Subject: Re: [PATCH RFC 0/8] kasan: hardware tag-based mode for production use on arm64 To: Kostya Serebryany , Serban Constantinescu Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Elena Petrova , Branislav Rankov , Kevin Brodsky , Andrew Morton , kasan-dev , Linux ARM , Linux Memory Management List , LKML , Marco Elver 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 15, 2020 at 4:41 PM Marco Elver wrote: > > On Wed, 14 Oct 2020 at 22:44, Andrey Konovalov wrote: > > This patchset is not complete (see particular TODOs in the last patch), > > and I haven't performed any benchmarking yet, but I would like to start the > > discussion now and hear people's opinions regarding the questions mentioned > > below. > > > > === Overview > > > > This patchset adopts the existing hardware tag-based KASAN mode [1] for > > use in production as a memory corruption mitigation. Hardware tag-based > > KASAN relies on arm64 Memory Tagging Extension (MTE) [2] to perform memory > > and pointer tagging. Please see [3] and [4] for detailed analysis of how > > MTE helps to fight memory safety problems. > > > > The current plan is reuse CONFIG_KASAN_HW_TAGS for production, but add a > > boot time switch, that allows to choose between a debugging mode, that > > includes all KASAN features as they are, and a production mode, that only > > includes the essentials like tag checking. > > > > It is essential that switching between these modes doesn't require > > rebuilding the kernel with different configs, as this is required by the > > Android GKI initiative [5]. > > > > The last patch of this series adds a new boot time parameter called > > kasan_mode, which can have the following values: > > > > - "kasan_mode=on" - only production features > > - "kasan_mode=debug" - all debug features > > - "kasan_mode=off" - no checks at all (not implemented yet) > > > > Currently outlined differences between "on" and "debug": > > > > - "on" doesn't keep track of alloc/free stacks, and therefore doesn't > > require the additional memory to store those > > - "on" uses asyncronous tag checking (not implemented yet) > > > > === Questions > > > > The intention with this kind of a high level switch is to hide the > > implementation details. Arguably, we could add multiple switches that allow > > to separately control each KASAN or MTE feature, but I'm not sure there's > > much value in that. > > > > Does this make sense? Any preference regarding the name of the parameter > > and its values? > > KASAN itself used to be a debugging tool only. So introducing an "on" > mode which no longer follows this convention may be confusing. > Instead, maybe the following might be less confusing: > > "full" - current "debug", normal KASAN, all debugging help available. > "opt" - current "on", optimized mode for production. > "on" - automatic selection => chooses "full" if CONFIG_DEBUG_KERNEL, > "opt" otherwise. > "off" - as before. > > Also, if there is no other kernel boot parameter named "kasan" yet, > maybe it could just be "kasan=..." ? > > > What should be the default when the parameter is not specified? I would > > argue that it should be "debug" (for hardware that supports MTE, otherwise > > "off"), as it's the implied default for all other KASAN modes. > > Perhaps we could make this dependent on CONFIG_DEBUG_KERNEL as above. > I do not think that having the full/debug KASAN enabled on production > kernels adds any value because for it to be useful requires somebody > to actually look at the stacktraces; I think that choice should be > made explicitly if it's a production kernel. My guess is that we'll > save explaining performance differences and resulting headaches for > ourselves and others that way. > > > Should we somehow control whether to panic the kernel on a tag fault? > > Another boot time parameter perhaps? > > It already respects panic_on_warn, correct? > > > Any ideas as to how properly estimate the slowdown? As there's no > > MTE-enabled hardware yet, the only way to test these patches is use an > > emulator (like QEMU). The delay that is added by the emulator (for setting > > and checking the tags) is different from the hardware delay, and this skews > > the results. > > > > A question to KASAN maintainers: what would be the best way to support the > > "off" mode? I see two potential approaches: add a check into each kasan > > callback (easier to implement, but we still call kasan callbacks, even > > though they immediately return), or add inline header wrappers that do the > > same. > [...] CC Kostya and Serban.