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 02276C433E0 for ; Thu, 11 Mar 2021 21:37:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7B4BE64F19 for ; Thu, 11 Mar 2021 21:37:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B4BE64F19 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 0AA018D02FF; Thu, 11 Mar 2021 16:37:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0872D8D02B2; Thu, 11 Mar 2021 16:37:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3DD78D02FF; Thu, 11 Mar 2021 16:37:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id C63738D02B2 for ; Thu, 11 Mar 2021 16:37:43 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 843654DD9 for ; Thu, 11 Mar 2021 21:37:43 +0000 (UTC) X-FDA: 77908905606.06.4F9DE03 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf24.hostedemail.com (Postfix) with ESMTP id E1A02A0009CE for ; Thu, 11 Mar 2021 21:37:38 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id s10so10129276wre.0 for ; Thu, 11 Mar 2021 13:37:42 -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=gThu0TE1qL9hnbQQaxSk/qxvpsDDtC1CzspsMmD08OE=; b=SwiE2He5npvJprt4/ga+llX7ojAaiSnGKufJo3KbwrKI0MdyKm/xmoaT5N75+/BdU9 WC+y1cqw+sVbpHcx5n4ctV0zVSX/DIrtsaYoLK/pm2iQV5lB693Aar8uRhFpxZx++ik9 S7aCiEApckhoJfIMNlPJHjiigMU46WdgOGiIV1p6qPCXW3IhaBGLhblGHqAdyKqxZxYQ aOJH1yCva5uRQHxKvUrRU2yBMEdW1LYdohvTOnq9dkdphiaIGN7RJjNkH0Vc7q4hposB +GXH4NSOCvv2pOX1uJGUVZR4gmWDyxxMYbd5ip6L0RcVRrWEwcdfG+Z4XsdOv9fBFg7n 29BA== 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=gThu0TE1qL9hnbQQaxSk/qxvpsDDtC1CzspsMmD08OE=; b=ZHkvxkp3ZOr6RnIH1PIKbrkIgUEeDfnlJMziy6baBe2ycfriHeVZwGvuT2jBEp51CQ BvWjS86sX92N9F4jCBI5YNaQygealOoZM4LQLL0h9I4B+Vv616r+bBnv0VWQOCgiNvgk KyHuFGeBs9CC3B/H4Qx1DYqy1OSpTxyuMqW2QU11b6tvi5Pcuia3+U+NeAAVYeMyLJYq kUO2DBvf6yLrqBDNuPQNTFWAoP0wdvcxh8f5xlzViOr5mU9NpxYswlLoCMJpD69TPYpG vo+8EfhZI6eW/jBO3MpU0Lfbpj3MeVwR3duq4il1ki/z6ZBwZfB98xLSlvNtcJw0o9oq bi6w== X-Gm-Message-State: AOAM530EkkON7t2BRKjVqBNRRaDFRo0qyPMA7urNeMmEpkkFj8lwi3+L SgU1Km17SuSx6p8nJPOq6hIC2UdycFhHQkAk X-Google-Smtp-Source: ABdhPJzT6Acki3u676PB0Tv/dBARyH8t1RaPBLvxeQVuHtvcC5rv/V0863W+inBzbIKsqJ8x8rC70h3o60/IqeXf X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:95a:d8a8:4925:42be]) (user=andreyknvl job=sendgmr) by 2002:a1c:f614:: with SMTP id w20mr9884303wmc.70.1615498661923; Thu, 11 Mar 2021 13:37:41 -0800 (PST) Date: Thu, 11 Mar 2021 22:37:19 +0100 In-Reply-To: Message-Id: <3ec89a4e0783ff3d345310343d7ef10d46c8adb2.1615498565.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH 07/11] kasan: docs: update SW_TAGS implementation details 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 Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: kuitdi1ucpx3c419g8w8nzszrh5mdqbf X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: E1A02A0009CE Received-SPF: none (flex--andreyknvl.bounces.google.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from="<3pY1KYAoKCPIUhXlYsehpfaiiafY.Wigfchor-ggepUWe.ila@flex--andreyknvl.bounces.google.com>"; helo=mail-wr1-f74.google.com; client-ip=209.85.221.74 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615498658-207562 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 "Implementation details" section for SW_TAGS KASAN: - Clarify the introduction sentence. - Punctuation, readability, and other minor clean-ups. Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 39 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index 1fb4b715a3ce..dff18e180120 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -235,38 +235,37 @@ quarantine (see mm/kasan/quarantine.c for implementation). Software tag-based KASAN ~~~~~~~~~~~~~~~~~~~~~~~~ -Software tag-based KASAN requires software memory tagging support in the form -of HWASan-like compiler instrumentation (see HWASan documentation for details). - -Software tag-based KASAN is currently only implemented for arm64 architecture. +Software tag-based KASAN uses a software memory tagging approach to checking +access validity. It is currently only implemented for the arm64 architecture. Software tag-based KASAN uses the Top Byte Ignore (TBI) feature of arm64 CPUs -to store a pointer tag in the top byte of kernel pointers. Like generic KASAN -it uses shadow memory to store memory tags associated with each 16-byte memory -cell (therefore it dedicates 1/16th of the kernel memory for shadow memory). +to store a pointer tag in the top byte of kernel pointers. It uses shadow memory +to store memory tags associated with each 16-byte memory cell (therefore, it +dedicates 1/16th of the kernel memory for shadow memory). -On each memory allocation software tag-based KASAN generates a random tag, tags -the allocated memory with this tag, and embeds this tag into the returned +On each memory allocation, software tag-based KASAN generates a random tag, tags +the allocated memory with this tag, and embeds the same tag into the returned pointer. Software tag-based KASAN uses compile-time instrumentation to insert checks -before each memory access. These checks make sure that tag of the memory that -is being accessed is equal to tag of the pointer that is used to access this -memory. In case of a tag mismatch software tag-based KASAN prints a bug report. +before each memory access. These checks make sure that the tag of the memory +that is being accessed is equal to the tag of the pointer that is used to access +this memory. In case of a tag mismatch, software tag-based KASAN prints a bug +report. -Software tag-based KASAN also has two instrumentation modes (outline, that -emits callbacks to check memory accesses; and inline, that performs the shadow +Software tag-based KASAN also has two instrumentation modes (outline, which +emits callbacks to check memory accesses; and inline, which performs the shadow memory checks inline). With outline instrumentation mode, a bug report is -simply printed from the function that performs the access check. With inline -instrumentation a brk instruction is emitted by the compiler, and a dedicated -brk handler is used to print bug reports. +printed from the function that performs the access check. With inline +instrumentation, a ``brk`` instruction is emitted by the compiler, and a +dedicated ``brk`` handler is used to print bug reports. Software tag-based KASAN uses 0xFF as a match-all pointer tag (accesses through -pointers with 0xFF pointer tag aren't checked). The value 0xFE is currently +pointers with the 0xFF pointer tag are not checked). The value 0xFE is currently reserved to tag freed memory regions. -Software tag-based KASAN currently only supports tagging of -kmem_cache_alloc/kmalloc and page_alloc memory. +Software tag-based KASAN currently only supports tagging of slab and page_alloc +memory. Hardware tag-based KASAN ~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.31.0.rc2.261.g7f71774620-goog