From patchwork Thu Mar 11 21:37:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12132961 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 37304C433E6 for ; Thu, 11 Mar 2021 21:37:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C187964F19 for ; Thu, 11 Mar 2021 21:37:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C187964F19 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 53EEA8D0302; Thu, 11 Mar 2021 16:37:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EFB68D02B2; Thu, 11 Mar 2021 16:37:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3681F8D0302; Thu, 11 Mar 2021 16:37:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0231.hostedemail.com [216.40.44.231]) by kanga.kvack.org (Postfix) with ESMTP id 15A1C8D02B2 for ; Thu, 11 Mar 2021 16:37:50 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id C793F1806913E for ; Thu, 11 Mar 2021 21:37:49 +0000 (UTC) X-FDA: 77908905858.21.D278274 Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) by imf13.hostedemail.com (Postfix) with ESMTP id 39568E0011E1 for ; Thu, 11 Mar 2021 21:37:47 +0000 (UTC) Received: by mail-qk1-f201.google.com with SMTP id o70so16661934qke.16 for ; Thu, 11 Mar 2021 13:37:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=d9MD7r+sgefmh6olz506jW43mtPrrCIc3sAEHbrSzj8=; b=ax/rWBbWgfFBi82AU51k9wa1iavqd4Vuv9RUjEWuwWfeWHXtSnX5LFRCyJqlXJfA+W hm1ViC5eQNv6WM0R5WEHJWm1s+Ffj+2G2yuaPXOQny71MI+E7RKHxtVS3De7jyJgvPb1 zBCFJM8tCCXPX/qoWnKZ6FsBO/dnl6Bhc4xLB6jKSvLRtzrTs4djQiwD/8TUzNKrG3j8 gTgtdYh83bQOReTyQLwntQqCzVCikVRaETyy20dw1nOiXapJ5sD0BVRrRr1sCoM+5KVH A5y9ja1C+hbayglpaYIVouChO09VKiH6xoX3Anq/06nYhdxGkt+Xc1XAlrRDvWfHct3N P/Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=d9MD7r+sgefmh6olz506jW43mtPrrCIc3sAEHbrSzj8=; b=pJ84Uc8MdDEeDKUUilTkf2TNHgtDXWVQDMsdZsVeB9LMJ8918E3dikaXP7wxDCGmZK pv7x6ZE2tB7JdwK7/yIBZVzN85CQ2IgZ6q/qErqKaWkRB1VY5FHg/IrCmZwLW7KJgCbV TwoAgyb3BujdPKPAgYwfrxot+Pl250NoUXJBU0vQyac7QVn4t2olnpqAUCYL+JqA+a6b NKaHJndnzUrjDIURVq23HfoYRdCKJlZI8Aggy4S/P5a6pfJfSHOniCUUrXTfOA2gdiR+ yKco6YPcAlMIxPRTWZQIB3fnJpgJdt7Uyk1W5n0xCRAcIvK06D49IOgDKmgTLXCuI5HF wtWg== X-Gm-Message-State: AOAM531UPzMvIRowcrHz7qwUOnaX2xAwMOfyQXgEGHGyF1Umu4a5W1E3 ZUeg9l3lRE/g+TkJIfet0PPVyctL//3sHdlk X-Google-Smtp-Source: ABdhPJzpQZgOsi+fHQ89WFEZlxVp3IMtBdkjlpY0sJb25JmmNWaJDjP0pxKw0uMn7urnS6/1TroiVIGrltIjMgy0 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:95a:d8a8:4925:42be]) (user=andreyknvl job=sendgmr) by 2002:a0c:9cc2:: with SMTP id j2mr6061470qvf.2.1615498668637; Thu, 11 Mar 2021 13:37:48 -0800 (PST) Date: Thu, 11 Mar 2021 22:37:22 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH 10/11] kasan: docs: update ignoring accesses section 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 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 39568E0011E1 X-Stat-Signature: fsg8e6asp7yb8ctzfibnnc6gy5i1zimb Received-SPF: none (flex--andreyknvl.bounces.google.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from="<3rI1KYAoKCPkboesfzlowmhpphmf.dpnmjovy-nnlwbdl.psh@flex--andreyknvl.bounces.google.com>"; helo=mail-qk1-f201.google.com; client-ip=209.85.222.201 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615498667-28848 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 the "Ignoring accesses" section in KASAN documentation: - Mention kasan_disable/enable_current(). - Mention kasan_reset_tag()/page_kasan_tag_reset(). - A punctuation clean-up. Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 2b61d90e136f..6628b133c9ad 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -368,7 +368,7 @@ Ignoring accesses ~~~~~~~~~~~~~~~~~ Software KASAN modes use compiler instrumentation to insert validity checks. -Such instrumentation might be incompatible with some part of the kernel, and +Such instrumentation might be incompatible with some parts 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: @@ -381,6 +381,19 @@ Makefile: KASAN_SANITIZE := n +Other parts of the kernel might access metadata for allocated objects. Normally, +KASAN detects and reports such accesses, but in certain cases (e.g., in memory +allocators) these accesses are valid. Disabling instrumentation for memory +allocators files helps with accesses that happen directly in that code for +software KASAN modes. But it does not help when the accesses happen indirectly +(through generic function calls) or with the hardware tag-based mode that does +not use compiler instrumentation. + +To disable KASAN reports in a certain part of the kernel code: + +- For software modes, add a + ``kasan_disable_current()``/``kasan_enable_current()`` critical section. +- For tag-based modes, use ``kasan_reset_tag()`` or ``page_kasan_tag_reset()``. Tests ~~~~~