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=-24.8 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_SANE_1,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 E8E7EC433DB for ; Fri, 12 Mar 2021 15:10:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 902FF64DF0 for ; Fri, 12 Mar 2021 15:10:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 902FF64DF0 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 2BAD06B006C; Fri, 12 Mar 2021 10:10:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 241C66B0070; Fri, 12 Mar 2021 10:10:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 094F56B0073; Fri, 12 Mar 2021 10:10:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id E1D406B006C for ; Fri, 12 Mar 2021 10:10:07 -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 9A4E91820C7A4 for ; Fri, 12 Mar 2021 15:10:07 +0000 (UTC) X-FDA: 77911557654.14.C95F3B9 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by imf09.hostedemail.com (Postfix) with ESMTP id 7081F6000116 for ; Fri, 12 Mar 2021 15:10:01 +0000 (UTC) Received: by mail-wm1-f54.google.com with SMTP id d191so3997809wmd.2 for ; Fri, 12 Mar 2021 07:10:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=q9bPQXFsE5NHB3Ewyjn3BKLWEisEUyEGFLv0VSHg4OQ=; b=TQB5C6l4OeABWHlvhNhcWyrxqsv8C5QqNwZAyjKBcdX4BE0mTAHDSS5KczD4DVscFY oEeMrljq4zm4xmSq5u5jDjffWqLEs5i0GqJ+4ZRe5FC0NziHFBTQvGkx7QAUhHMEHYkp 12yQhaakrbwFPoci6sX2/uKuLi9rDFnKtNWszi/eR8cbsdS5NWnr21AWJzF64dooYlQT 1f0LyNEj8qTzwl+i6gqqR05RRq9MLqYnFpXbyNdTH2kf6T6+bG6s6xDEphFoFAXQrP/U Hw0x3631EZJQGSz8MJsvQweXwbT+JDe2ndTPUXf5S3Xah5t4kezG4UzQex3V7Rz+umzX 3rrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=q9bPQXFsE5NHB3Ewyjn3BKLWEisEUyEGFLv0VSHg4OQ=; b=cM+Y2LtlnZPa7umZlBRC4uYKpFmysDPnCqlRc/njzgJIiEkDJ9guxqMp5p9Fermu5z l0G0IAmtiki/TkICLnk49XFOLu9w4wdgHM0LQZ6Tq3IiLa6ASjxS2fnt+/EkOsx/aPEU jcwKfSQgE2nJ7SjI41racz1uqzJfIxc5z0eUWOpmq0ERpons7RfR9HVGS1UqyqlW9+Hm L/RcoK01aayIvv80Qbj0vUx5ZpZOejUQgY9czphcP7o7mU1KsXiOgJTYpDwCENF9hgkj FBt0JJ+ycQ8xPp5+87+H7AG7lqKZGtXslPsJBKfXLZlJpbIEHbYnq/KYRny59XB62u5C kXOw== X-Gm-Message-State: AOAM533DSmZFukqbdF/74nYhHRQGRmUFAMi+pMUaEeiyqjYA1AGRdyEz odYSZJfQeU+MLEA9VXgS6klemg== X-Google-Smtp-Source: ABdhPJz5IH7Ok3UON2hlkoU2lpeCCjiad8g3I7jy472VKyfIa2m7Uio36UODP+qSoYfFrknHPzUbTA== X-Received: by 2002:a1c:c20a:: with SMTP id s10mr13423275wmf.144.1615561802386; Fri, 12 Mar 2021 07:10:02 -0800 (PST) Received: from elver.google.com ([2a00:79e0:15:13:d5de:d45f:f79c:cb62]) by smtp.gmail.com with ESMTPSA id q4sm2523647wma.20.2021.03.12.07.10.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 07:10:01 -0800 (PST) Date: Fri, 12 Mar 2021 16:09:55 +0100 From: Marco Elver To: Andrey Konovalov Cc: Andrew Morton , Alexander Potapenko , Andrey Ryabinin , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 09/11] kasan: docs: update shadow memory section Message-ID: References: <00f8c38b0fd5290a3f4dced04eaba41383e67e14.1615559068.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <00f8c38b0fd5290a3f4dced04eaba41383e67e14.1615559068.git.andreyknvl@google.com> User-Agent: Mutt/2.0.5 (2021-01-21) X-Stat-Signature: r1ioqa6kqkfirxs3doqbdxbqan57bw6s X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 7081F6000116 Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf09; identity=mailfrom; envelope-from=""; helo=mail-wm1-f54.google.com; client-ip=209.85.128.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615561801-826026 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: On Fri, Mar 12, 2021 at 03:24PM +0100, Andrey Konovalov wrote: > 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 Reviewed-by: Marco Elver > --- > 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 2744ae6347c6..d0c1796122df 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. > > Default behaviour > ~~~~~~~~~~~~~~~~~ > @@ -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 >