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=-26.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT,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 CF92FC433DB for ; Fri, 12 Mar 2021 14:24:40 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 79B3964FC3 for ; Fri, 12 Mar 2021 14:24:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79B3964FC3 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 ECE2D8D035B; Fri, 12 Mar 2021 09:24:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E7E298D0346; Fri, 12 Mar 2021 09:24:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D46768D035B; Fri, 12 Mar 2021 09:24:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0242.hostedemail.com [216.40.44.242]) by kanga.kvack.org (Postfix) with ESMTP id BAA908D0346 for ; Fri, 12 Mar 2021 09:24:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7F04818149422 for ; Fri, 12 Mar 2021 14:24:39 +0000 (UTC) X-FDA: 77911443078.19.67626BC Received: from mail-qk1-f202.google.com (mail-qk1-f202.google.com [209.85.222.202]) by imf01.hostedemail.com (Postfix) with ESMTP id 43E792000380 for ; Fri, 12 Mar 2021 14:24:39 +0000 (UTC) Received: by mail-qk1-f202.google.com with SMTP id h134so18300000qke.1 for ; Fri, 12 Mar 2021 06:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=iXUBccT1s/Tpz0xpM0wAfa/pMQuz7eoXMXGou1E4nY8=; b=nXGX3uu1DMoAwGMzh6ZF3gsPGgxXAloDpF10xlKbClV0eN/txB0mPw/MO61bESnYPT O3eBA7dXz9prhNZzsetEN2ZQGjvCLoYEu4JFwYiPAUgLsDKEBLDW2HdeogZB6H/8/jlC +3rUnQnIi+sVzOY9L9AgXOxd+I4xNMIVZQBArHnJJ5BHjT0kCarwVSpWrf6sMPAFZZK7 xGujlM8ClMOuEZjK+cJTGGDUDXenoZphVsSac6CId3FGYGrd5nJ4tigA11sKhYU9AU2d KMVNImLe8WH9EM0IZY/K0PYPUudSmeB5CgLTOW6vKnZTsxsEoF6tx37zkTQ1wF7ebK3f MRbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=iXUBccT1s/Tpz0xpM0wAfa/pMQuz7eoXMXGou1E4nY8=; b=mpCCm4ZrLlWf2lIrgNaG2PGscIRj4WmV1PW9CJfcQ3NebLb9gj/7Vk2Jw0KPuaum2a lBTVdqymM5+gzlsgAeO+HeH6nTQiZ1sMe+dk7OL12MVmjNf9l9J/q2yZnl4+m3wmQ/89 KcfuLMtcMaiHnL16Z/7ZmVKZ1NRrYDhA98sIk6SOPpoufV4TsSgOylgAPCLjwHLOb7SR APApRyI1J15ASRJhMWkYWn4+MnIFdtj/HZNuR4q4iJx/ZwfTJCB3N19T+wkkIQp/CrFy K5YTsbO40UtV7wbwhumO12MgeA4jfVPTCjT3IVESsRIJFtZf+orq65x81oZIAMd5w/4g ZqYw== X-Gm-Message-State: AOAM530++GoQbGYCYtV4vb7/ihl1AvAjZ8GEad8giHVaWVdxb1pBTx49 kvvedBOEuW5XK/Inhwnf0dLNkLIin9IisTEV X-Google-Smtp-Source: ABdhPJz9mDUjTU99hjsECwi+EVDjFSiRUu2Cbxnw2RJk16AhnoByPHfMDcrVC6QGLFbIw0tfj/qLuVL6uKemhBfp X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:95a:d8a8:4925:42be]) (user=andreyknvl job=sendgmr) by 2002:a0c:8f1a:: with SMTP id z26mr11991825qvd.51.1615559078072; Fri, 12 Mar 2021 06:24:38 -0800 (PST) Date: Fri, 12 Mar 2021 15:24:24 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v2 01/11] kasan: docs: clean up sections From: Andrey Konovalov To: Andrew Morton , Alexander Potapenko , Marco Elver Cc: Andrey Ryabinin , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: rxddye39oo67snjf6a1nk7e8ie1ehuuz X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 43E792000380 Received-SPF: none (flex--andreyknvl.bounces.google.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from="<3pnlLYAoKCM8v8yCzJ58G619916z.x97638FI-775Gvx5.9C1@flex--andreyknvl.bounces.google.com>"; helo=mail-qk1-f202.google.com; client-ip=209.85.222.202 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615559079-454937 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: Update KASAN documentation: - Give some sections clearer names. - Remove unneeded subsections in the "Tests" section. - Move the "For developers" section and split into subsections. Signed-off-by: Andrey Konovalov --- Changes v1->v2: - Rename "By default" section to "Default behaviour". --- Documentation/dev-tools/kasan.rst | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index ddf4239a5890..b3b2c517db55 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -168,24 +168,6 @@ particular KASAN features. report or also panic the kernel (default: ``report``). Note, that tag checking gets disabled after the first reported bug. -For developers -~~~~~~~~~~~~~~ - -Software KASAN modes use compiler instrumentation to insert validity checks. -Such instrumentation might be incompatible with some part of the kernel, and -therefore needs to be disabled. To disable instrumentation for specific files -or directories, add a line similar to the following to the respective kernel -Makefile: - -- For a single file (e.g. main.o):: - - KASAN_SANITIZE_main.o := n - -- For all files in one directory:: - - KASAN_SANITIZE := n - - Implementation details ---------------------- @@ -299,8 +281,8 @@ support MTE (but supports TBI). Hardware tag-based KASAN only reports the first found bug. After that MTE tag checking gets disabled. -What memory accesses are sanitised by KASAN? --------------------------------------------- +Shadow memory +------------- The kernel maps memory in a number of different parts of the address space. This poses something of a problem for KASAN, which requires @@ -311,8 +293,8 @@ The range of kernel virtual addresses is large: there is not enough real memory to support a real shadow region for every address that could be accessed by the kernel. -By default -~~~~~~~~~~ +Default behaviour +~~~~~~~~~~~~~~~~~ By default, architectures only map real memory over the shadow region for the linear mapping (and potentially other small areas). For all @@ -362,8 +344,29 @@ unmapped. This will require changes in arch-specific code. This allows ``VMAP_STACK`` support on x86, and can simplify support of architectures that do not have a fixed module region. -CONFIG_KASAN_KUNIT_TEST and CONFIG_KASAN_MODULE_TEST ----------------------------------------------------- +For developers +-------------- + +Ignoring accesses +~~~~~~~~~~~~~~~~~ + +Software KASAN modes use compiler instrumentation to insert validity checks. +Such instrumentation might be incompatible with some part of the kernel, and +therefore needs to be disabled. To disable instrumentation for specific files +or directories, add a line similar to the following to the respective kernel +Makefile: + +- For a single file (e.g. main.o):: + + KASAN_SANITIZE_main.o := n + +- For all files in one directory:: + + KASAN_SANITIZE := n + + +Tests +~~~~~ KASAN tests consist of two parts: @@ -409,21 +412,18 @@ Or, if one of the tests failed:: There are a few ways to run KUnit-compatible KASAN tests. 1. Loadable module -~~~~~~~~~~~~~~~~~~ With ``CONFIG_KUNIT`` enabled, ``CONFIG_KASAN_KUNIT_TEST`` can be built as a loadable module and run on any architecture that supports KASAN by loading the module with insmod or modprobe. The module is called ``test_kasan``. 2. Built-In -~~~~~~~~~~~ With ``CONFIG_KUNIT`` built-in, ``CONFIG_KASAN_KUNIT_TEST`` can be built-in on any architecure that supports KASAN. These and any other KUnit tests enabled will run and print the results at boot as a late-init call. 3. Using kunit_tool -~~~~~~~~~~~~~~~~~~~ With ``CONFIG_KUNIT`` and ``CONFIG_KASAN_KUNIT_TEST`` built-in, it's also possible use ``kunit_tool`` to see the results of these and other KUnit tests -- 2.31.0.rc2.261.g7f71774620-goog