Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp738653pxf; Thu, 11 Mar 2021 13:44:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJzejoVsvF3Qna381yrarshW720mg2i96Xv8085Vy/J/cikthbVs5XGQ+FsPzx1s8QOGagon X-Received: by 2002:a17:906:add7:: with SMTP id lb23mr5043709ejb.273.1615499043507; Thu, 11 Mar 2021 13:44:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615499043; cv=none; d=google.com; s=arc-20160816; b=KEngboigLRkquWdpIg6Vp6Bc7C2T70jEisp89K4JAYLDVBQ/k1zxddyRnURhcyo7cg 06CCpVX7c5VVgTFVkN0M9heO4sr4+IBSulMok/Ts0TiNrExzQuLK57xy3kVS3G/tgNbO VbxdO4iAXJTWoCbZJXGdbeXvK1WuObQzzb+EhA2GlL/5ZqmNQFM4B8COHkureNBtdVqj XseKPegCZWThWjMlGV1w0+23AWUmmgnrg9AF5yBCipwlR93smuNkXNz9sgEpDUvjVaYP z05NO/WAVXm/cWxAaxBbAe2mZtG0wnuoEeLMrW8aao1hC8ziTstc47EiYwuMnRXc9eKa KkYQ== 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=ftjCjXXHVhB6VMD5t3OFCFAtHdmXgYbSUPbbr/Gj6M0=; b=rZuvKlo6AfLn8aWioF6N56/Ip3/BRumHmDwVIBckJX8fT9v7Q0sm+azlQMubS3J200 D7Krf4mWeY9wPeHV527ijujTgSKa1vQux++54RT3W/7MmHr3n7Hh4uYSWalf0VjPOCIi R15dihgHpljztngofsL/i42daLV+xumKnUz3swD3L3usnYqQc8HNe8av2PdsOkDYdYLz uOgQYe8Z8rJ6FyVChpOSP3mYwU4BeyFqtrh6uT4S3Xj0eSyk/96hsYoxTD+KWCkm0oNY SW72cY46whZN2/W0uC+gIzXux6SPmNhQ14fjal1UXKzJ8xFgwMt6Y//xHM64xnsecFGS A03Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ESbdDH1d; 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 l23si2537774ejb.447.2021.03.11.13.43.40; Thu, 11 Mar 2021 13:44:03 -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=ESbdDH1d; 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 S231320AbhCKViS (ORCPT + 99 others); Thu, 11 Mar 2021 16:38:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231180AbhCKVhr (ORCPT ); Thu, 11 Mar 2021 16:37:47 -0500 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C984C061574 for ; Thu, 11 Mar 2021 13:37:47 -0800 (PST) Received: by mail-qk1-x74a.google.com with SMTP id x11so13474478qki.22 for ; Thu, 11 Mar 2021 13:37:47 -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=ftjCjXXHVhB6VMD5t3OFCFAtHdmXgYbSUPbbr/Gj6M0=; b=ESbdDH1dGDyJVOngrIaGau1OqUj/sBoi5iMhooMRu0pkICXzAdcFpDb2Ul/KLNFn99 lZofYcZStifebLYgoQqfyIDIDZPygmK4tKz809cgrrLgeaEFORYIMtasnVGJEyJjHkEa E/K8ivFsvqiyEa4HwIB6Mh9BfTO+xCkQwFnZciD1y6y3RDdaejO3SsIpy7ww3zplxkd+ 4Wgy/It2jaGw6T7SoFg+2X2fAIar9JEXkV+lEzvZvRf/69TJ2BhSbH7NeIqQD0PmVu7j M7miv5kkKHtosvttGtJ9aFfUacFCA102qbBPhQO2Ciwz4rvUYeRTH2j682GaHq76n11H IwSw== 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=ftjCjXXHVhB6VMD5t3OFCFAtHdmXgYbSUPbbr/Gj6M0=; b=nCoOKmOWyCChivf8DyhEd2gMem18zdEHKJV9u5hyJ35QrLNkH5fKG8UiLQHoNr+aOf 1AmhDguetvZqV9jDggK+jsZbHRxj4U9pMZ6kkBg5lG5n48S1hZS/LLoyUgLddJlVxKSN bWbY56hn1aKMIc/2AqGvqGFB5d0VPXTJMQ0588LYLKGpNTc3xI+q2y5eggyntQXaJ6SQ HaOgPSa1zXdchmkSwDfdubW/jnXoMN64riq/1spxUyt+TdN0NfbvpLNxghfjddPa9UiD apAM0VNOTNgbfGyzIjZdOV0ZbTOPJZm0sGDxTf+Mg/QqG8aFohQzOIBoUZneAEfful2d vaaQ== X-Gm-Message-State: AOAM531JUlidyVCgd8HQtRXhVKJ62Ztjq2WIAFqS9Ei0e8+bmpSiEobl cGuDDoh8gwLzrWcy11yqAX3yfygwMbyY2vsM X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:95a:d8a8:4925:42be]) (user=andreyknvl job=sendgmr) by 2002:a0c:f541:: with SMTP id p1mr9682518qvm.14.1615498666324; Thu, 11 Mar 2021 13:37:46 -0800 (PST) Date: Thu, 11 Mar 2021 22:37:21 +0100 In-Reply-To: Message-Id: <6cb4988a241f086be7e7df3eea79416a53377ade.1615498565.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH 09/11] kasan: docs: update shadow memory 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 "Shadow memory" section in KASAN documentation: - Rearrange the introduction paragraph do it doesn't give a "KASAN has an issue" impression. - Update the list of architectures with vmalloc support. - Punctuation, readability, and other minor clean-ups. Signed-off-by: Andrey Konovalov --- Documentation/dev-tools/kasan.rst | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Documentation/dev-tools/kasan.rst b/Documentation/dev-tools/kasan.rst index f5c746a475c1..2b61d90e136f 100644 --- a/Documentation/dev-tools/kasan.rst +++ b/Documentation/dev-tools/kasan.rst @@ -304,14 +304,11 @@ checking gets disabled. 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 -that all addresses accessed by instrumented code have a valid shadow -region. - -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. +The kernel maps memory in several different parts of the address space. +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. Therefore, KASAN only maps real shadow for certain +parts of the address space. By default ~~~~~~~~~~ @@ -323,10 +320,9 @@ page is mapped over the shadow area. This read-only shadow page declares all memory accesses as permitted. This presents a problem for modules: they do not live in the linear -mapping, but in a dedicated module space. By hooking in to the module -allocator, KASAN can temporarily map real shadow memory to cover -them. This allows detection of invalid accesses to module globals, for -example. +mapping but in a dedicated module space. By hooking into the module +allocator, KASAN temporarily maps real shadow memory to cover them. +This allows detection of invalid accesses to module globals, for example. This also creates an incompatibility with ``VMAP_STACK``: if the stack lives in vmalloc space, it will be shadowed by the read-only page, and @@ -337,9 +333,10 @@ CONFIG_KASAN_VMALLOC ~~~~~~~~~~~~~~~~~~~~ With ``CONFIG_KASAN_VMALLOC``, KASAN can cover vmalloc space at the -cost of greater memory usage. Currently this is only supported on x86. +cost of greater memory usage. Currently, this is supported on x86, +riscv, s390, and powerpc. -This works by hooking into vmalloc and vmap, and dynamically +This works by hooking into vmalloc and vmap and dynamically allocating real shadow memory to back the mappings. Most mappings in vmalloc space are small, requiring less than a full @@ -358,10 +355,10 @@ memory. To avoid the difficulties around swapping mappings around, KASAN expects that the part of the shadow region that covers the vmalloc space will -not be covered by the early shadow page, but will be left -unmapped. This will require changes in arch-specific code. +not be covered by the early shadow page but will be left unmapped. +This will require changes in arch-specific code. -This allows ``VMAP_STACK`` support on x86, and can simplify support of +This allows ``VMAP_STACK`` support on x86 and can simplify support of architectures that do not have a fixed module region. For developers -- 2.31.0.rc2.261.g7f71774620-goog