Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1325800pxf; Fri, 12 Mar 2021 07:12:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyddTc8Y28RcWG8S7znZ9Srw2gL5IT/BpZOledCQIERw024k9DwO0w2pJnmtwS8V5u3Yi3F X-Received: by 2002:adf:a219:: with SMTP id p25mr14745144wra.400.1615561929882; Fri, 12 Mar 2021 07:12:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615561929; cv=none; d=google.com; s=arc-20160816; b=WTzknfpT9OSGHDhIFu6VCTTXZT0HOIu5bGCknd5ymrlfWylIz8wrPYgQw34p8rUhBr vyi8avT3SaZoCWQE0bvT/vbyscqgH5T158C45Pn0fUYNRPShUonVFaenberRw8gYBWJ/ 5qmIFe/27545WpuMUOGn0l21O1EvXjBPN9Ozlp/2mNlJbetT1L95xj3fJy2WRluB8C1H FT1x+NG1ZCecYYjZiGGuqxM3bTFtIjblMfvzsk160DT49eTxfkoEtUrEgx4aohxFoQfu UlrAQ28vGLnQvoBZedNa7kJ9+kJ6bYPrhS0zq8Wrb4OrhpX/Aco8FhOejzxahCOpwlgR HmOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=q9bPQXFsE5NHB3Ewyjn3BKLWEisEUyEGFLv0VSHg4OQ=; b=zKV/Uuapq2tL8KD+N1pZoraor9SAPOOhamhhLY+wcC98f7iIy98tn4LXc7/094KJfY vs1NtAprSU492ug9aQ/Qt3d/aSWROBWbnJzyeGojW6FZaIcxFVosuJDfFUH7UF5Q44MX 4p7vWfdfeJhrksx5VzfuTe123X7MohBpvMZg78Evp/Ki/ujJNl1nDtez2T6GQUbuOS3D LgUqrfoRKD3Fx52oe1nFS58LVMLZiG+L7n36U8hMADEhS7f8Sxi43TeIpRPGhjJLolQ4 5WO7HY9nZYiqbNmekX7PfsYt7AX+19DLGOSY8HQ1HJ5kiges01DpA0ZSYKKFyULYxP5T qrjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TQB5C6l4; 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 s11si4279446edd.147.2021.03.12.07.11.40; Fri, 12 Mar 2021 07:12:09 -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=TQB5C6l4; 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 S232187AbhCLPKa (ORCPT + 99 others); Fri, 12 Mar 2021 10:10:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232244AbhCLPKE (ORCPT ); Fri, 12 Mar 2021 10:10:04 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3551C061574 for ; Fri, 12 Mar 2021 07:10:03 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id g25so4007324wmh.0 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=g8BwVFZk+/iMZaOMBYU25ZQU76P73zqJ1MEX/sUPYOu28QuUYZVfksWHSCdkdJbIkW N9gyPHvLk6vQ6NfTZkgigMcrkKfqg3QGF4x1v9hJAPvEiOv4BAbozl5lcqgbdF4YwnHx vwKlz8sfo5gqXvIm7V17Hvb5nheFKBeeqql//rAwt1h1pWj27PZ7EQPvPZQa0YkzTKhG 7wfHGLFH1RtSOO7EbryLDj5rFv9riZkN6nvK0gJAItrdB1oM4ynSb9kg57nOLVRAyQko 3FCfpRXvEMIMGfjbmzxHeDN7dWQowkU6VRbw1AHq7KAI5WSEf+mPkqfKJlFi4lwMiRUr D9Zg== X-Gm-Message-State: AOAM532cjlrWSoXMUUiGP5LKi5hjgth0AYFEXCd5U/+zAOnNkX4JQGE0 9/iKt3Cd8SUrZIK9xbxEvMgYFw== 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 >