From patchwork Fri Mar 12 14:24:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12134795 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 96087C433E0 for ; Fri, 12 Mar 2021 14:24:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4790364FB2 for ; Fri, 12 Mar 2021 14:24:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4790364FB2 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 DE4478D0346; Fri, 12 Mar 2021 09:24:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DBBB28D0360; Fri, 12 Mar 2021 09:24:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8F8A8D0346; Fri, 12 Mar 2021 09:24:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0053.hostedemail.com [216.40.44.53]) by kanga.kvack.org (Postfix) with ESMTP id AE0A08D0346 for ; Fri, 12 Mar 2021 09:24:53 -0500 (EST) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 6E288181CBC29 for ; Fri, 12 Mar 2021 14:24:53 +0000 (UTC) X-FDA: 77911443666.14.FF3D219 Received: from mail-qv1-f74.google.com (mail-qv1-f74.google.com [209.85.219.74]) by imf17.hostedemail.com (Postfix) with ESMTP id 2A3014080F45 for ; Fri, 12 Mar 2021 14:24:52 +0000 (UTC) Received: by mail-qv1-f74.google.com with SMTP id i1so17663104qvu.12 for ; Fri, 12 Mar 2021 06:24:52 -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=VB+ZOM8lapdi+RHL0OEgOVW/Ip9OH5XFkGtr1r4Q8HI=; b=uWDK3QcUxzcXn0PrMjJgoILZW+lLMhmo2tzHSZsYKl2ch8lC3FXnh/zZ351EHfhY1s P87pKmZ1eifIqPh7Vi7zhmDDqxk9gXvznG8RIWGenKV8k71VCASv3jQjfwfwksjODLpv 5+vKtJOikS1lNVbKK3wAR4tu0Qg0pyjuR/FWVfTUAIi2TiTulnphGS4+vOVNaEKNWpbh Biocc2dbahtqtsgd5kADS2ZCApKGYUMoj5Q53ueOuyXTrlBcwuISU6Np4OlUq1ghLK06 kru5vo0RbxesE3Riq6FEUaklKg/oUV0hb6PdggzkEZbO6+Am/TeaVY55Uu+LHD606kLl AiwQ== 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=VB+ZOM8lapdi+RHL0OEgOVW/Ip9OH5XFkGtr1r4Q8HI=; b=Yo2ST3Mo8nYUb9/QZHtgqaeASMYnmlpmClfVAiC28rZjqpX/SX1BtCvtxncQSpzKhE +HwNf/OFk5DAkjBTr7GHE5022w3wdhDyW5AzoEG9lJfXuRrorWnkowBJghse9G4emS0V Z3LEtIdWvG1hNg9pxRMPh6ViN1JkTVf5a1Zh3C0TINrgd8QkAuxbKPbNhpi76MofX3HR kGQa+33PlXd7/VIiEhNxI/lGGCp+eaNQhlYwVDvIYcZJwsjOaELcjkLC5EIY3nU2Z0B1 xbz9aJy6fETDuGFMIPtU2+bZLWYAJsP3pRfmoqz2KqbvUPKb3huKyF9Q0zr34g97Wmji vnow== X-Gm-Message-State: AOAM533+mWPLiFh/fK8Kajj/T2J/2t3bRS0Ugv4s46UssCCJr/MqlN4+ trVVqP3f6xjC51rD0LAygv28a6C0K5mcfal/ X-Google-Smtp-Source: ABdhPJyBtbAk8TcFiX/VIGUhKGiXocxsQgpKLyfaMJwJYGYH+w9IqoQu0ZX31MySwZtsbV34QLPP6DkszPW0GkxK X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:95a:d8a8:4925:42be]) (user=andreyknvl job=sendgmr) by 2002:a05:6214:c8a:: with SMTP id r10mr12774809qvr.13.1615559092223; Fri, 12 Mar 2021 06:24:52 -0800 (PST) Date: Fri, 12 Mar 2021 15:24:30 +0100 In-Reply-To: Message-Id: <69b9b2e49d8cf789358fa24558be3fc0ce4ee32c.1615559068.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v2 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 X-Stat-Signature: zmwtbaunacchnfe1x643uhbko979tr76 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2A3014080F45 Received-SPF: none (flex--andreyknvl.bounces.google.com>: No applicable sender policy available) receiver=imf17; identity=mailfrom; envelope-from="<3tHlLYAoKCN09MCQDXJMUKFNNFKD.BNLKHMTW-LLJU9BJ.NQF@flex--andreyknvl.bounces.google.com>"; helo=mail-qv1-f74.google.com; client-ip=209.85.219.74 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615559092-530372 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 Reviewed-by: Marco Elver --- 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 986410bf269f..5873d80cc1fd 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 ~~~~~~~~~~~~~~~~~~~~~~~~