Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp737327pxf; Thu, 11 Mar 2021 13:41:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWn3R4y7DtJtwbnsvhzHl4b4Wl5Uuh4vTMf/DLGj+bG5RMqi6D1oVLaBFlxceNOnglcmf2 X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr5369635ejc.166.1615498895945; Thu, 11 Mar 2021 13:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615498895; cv=none; d=google.com; s=arc-20160816; b=I1TG7vHelt8+M7xW/uerj3480jceLTry3VGt4bZcIUjnjlR6VQZOI2xiXH0Hx+g5W+ ESs5HQnjFuR/z8jQERi81JbiZxspMuqNVD8d1k+Dwdr/d7pJ45zYXm7b/c8e/7JxXOuk FtG0N2gSrguLcACglqL6HYO/23FRhr/oZ0PBFCHPzVNJc1GHmt6YPP+BUZtBheqKZpDL dY/VR/bN9lNsWZPH5A7mW9P6tb9CL2Vk7Ih6iLmJr/5gRnezAb4gkoe3MdSFzq9hw73K l2Fi3gpGSLcJ0b5NAqcYSCd/HWUdxFkwnTvhfbkAOp2LGhwRCpjYrEG58Kq2Gf4Gb1ci DIfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=gThu0TE1qL9hnbQQaxSk/qxvpsDDtC1CzspsMmD08OE=; b=arAEyL09vHTRJQehW56k6qVavWX7SMKLa+eb9TPkX9gfS6AZzU6mefd1znWPvJECI/ evL/5utzZaYBiMwrW6V50n0BcgmfTl1UBLqiJ8YNk33NFiCgdzBFRdft+SVi1kvR+g8Q hbeHML59uQ+qt6LwifA0GEi97I6nfCaJnt4SGjh8YoqQWSN7oJp4uqx2PUp0bswfNrkd mFy2221gNnTQ3AERsRwNsEtB6Q5vMzOKXobV9Rz9CwrAn312XNdzWlGaswZdR7tK8aSu nNRfLAScydT/n7jFMAhP1Yzwz2MOE2iqkdAXf4ad6kQWRgjRj+TQHlqfuVON/H9QFgPF JtVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SwiE2He5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c14si2971464edn.71.2021.03.11.13.41.12; Thu, 11 Mar 2021 13:41:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SwiE2He5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231284AbhCKViP (ORCPT + 99 others); Thu, 11 Mar 2021 16:38:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbhCKVhn (ORCPT ); Thu, 11 Mar 2021 16:37:43 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D9FC061574 for ; Thu, 11 Mar 2021 13:37:43 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id g5so10083765wrd.22 for ; Thu, 11 Mar 2021 13:37:43 -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=C5d57c6d7iLeYi4QqcNcPpbrZvP3+R9YzJSlkuK0JGT/mH+L/PCy8RyOWzlQZBMopT nD6WZubX05Ofr+9/ilkDqUwou0yCZ1U+axaqMTuqOrNQNxXdYTaLXuOJ3s591jKIVJpT Z1VvzLaBiVxG+CyS7sAJwh04kwE8O9qp2PRuJ9BUC4q43zoT5Ha1chYNjb+gc9PI+lUg egvjc3SgBXzqU1kl+IwvizTQEoela1u5+ERlDUuQsZitID85eFApN6uiIpNLOZ5CgNFa 1zCFzyPfLoie2GJyolfd5R+UNJwr14SYtQCdrL6MQPy0oU9WzcRuSder+b2ofhxpRTd8 NyOA== X-Gm-Message-State: AOAM531lf6p8JKLsfT+VXmvyq1ScB7aJyxkZmB0mJm8yiuQglBrHs8gY DDTF6WCu1ke+Fl/Ghukynmcmx62Ba9yKeP9f 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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