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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS 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 96410C4361B for ; Sat, 19 Dec 2020 01:13:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F135423BAC for ; Sat, 19 Dec 2020 01:13:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F135423BAC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 59F7C6B005C; Fri, 18 Dec 2020 20:13:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 54FCA6B005D; Fri, 18 Dec 2020 20:13:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 417F56B0068; Fri, 18 Dec 2020 20:13:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0127.hostedemail.com [216.40.44.127]) by kanga.kvack.org (Postfix) with ESMTP id 290EB6B005C for ; Fri, 18 Dec 2020 20:13:30 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D7DA340E1 for ; Sat, 19 Dec 2020 01:13:29 +0000 (UTC) X-FDA: 77608258938.20.lake91_0714d1b27442 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id B6796180C6E32 for ; Sat, 19 Dec 2020 01:13:29 +0000 (UTC) X-HE-Tag: lake91_0714d1b27442 X-Filterd-Recvd-Size: 5530 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Sat, 19 Dec 2020 01:13:29 +0000 (UTC) Date: Fri, 18 Dec 2020 17:13:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608340408; bh=nKaF5qMP2EADBNzYCp8XcuHsLze37G8BzZ55UwoLvGA=; h=From:To:Cc:Subject:In-Reply-To:References:From; b=ugBwM0PbxDkOZP+paw7FM6DkKwSuAnWHNcIUQQTQ3hDWacF7zYfvz5uQImRqJSIJ7 /wCCVQ40FuOQrnp/I5c+/ke889q+1fDwBwDG+IcopVvbET2FfN6d4JE1CBwElSgAC5 n3Xxhc+H/YPAcSRpkieRoBrgO9mlaZoPqu7zCU98= From: Andrew Morton To: Marco Elver Cc: andreyknvl@google.com, aryabinin@virtuozzo.com, Branislav.Rankov@arm.com, catalin.marinas@arm.com, dvyukov@google.com, eugenis@google.com, glider@google.com, gor@linux.ibm.com, kevin.brodsky@arm.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, vincenzo.frascino@arm.com, will.deacon@arm.com Subject: Re: [patch 21/78] kasan: split out shadow.c from common.c Message-Id: <20201218171327.180140338d183b41a962742d@linux-foundation.org> In-Reply-To: References: <20201218140046.497484741326828e5b5d46ec@linux-foundation.org> <20201218220233.pgX0nYYVt%akpm@linux-foundation.org> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 Sat, 19 Dec 2020 01:28:29 +0100 Marco Elver wrote: > [...] > > -/* > > - * Poisons the shadow memory for 'size' bytes starting from 'addr'. > > - * Memory addresses should be aligned to KASAN_GRANULE_SIZE. > > - */ > > -void poison_range(const void *address, size_t size, u8 value) > > -{ > > - void *shadow_start, *shadow_end; > > - > > - /* > > - * Perform shadow offset calculation based on untagged address, as > > - * some of the callers (e.g. kasan_poison_object_data) pass tagged > > - * addresses to this function. > > - */ > > - address = reset_tag(address); > > - > > The moved lines do not mention kfence... > (The same commit in -next does.) They shouldn't. > > - shadow_start = kasan_mem_to_shadow(address); > > - shadow_end = kasan_mem_to_shadow(address + size); > > - > > - __memset(shadow_start, value, shadow_end - shadow_start); > > -} > [...] > > --- /dev/null > > +++ a/mm/kasan/shadow.c > > @@ -0,0 +1,518 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * This file contains KASAN runtime code that manages shadow memory for > > + * generic and software tag-based KASAN modes. > > + * > > + * Copyright (c) 2014 Samsung Electronics Co., Ltd. > > + * Author: Andrey Ryabinin > > + * > > + * Some code borrowed from https://github.com/xairy/kasan-prototype by > > + * Andrey Konovalov > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > This is the first time kfence is mentioned. Is this correct? Yes. > Is my assumption correct that the kasan changes and kfence changes are > to be swapped? Yes, kfence came in fairly late and seems a bit fresh. I was planning on holding it off until next cycle. Sigh. I don't have access to my capable-of-compiling-KASAN machine at present :( We'll need this, yes? --- a/mm/kasan/kasan.h~a +++ a/mm/kasan/kasan.h @@ -3,7 +3,6 @@ #define __MM_KASAN_KASAN_H #include -#include #include #ifdef CONFIG_KASAN_HW_TAGS @@ -305,20 +304,12 @@ static inline u8 random_tag(void) { retu static inline void poison_range(const void *address, size_t size, u8 value) { - /* Skip KFENCE memory if called explicitly outside of sl*b. */ - if (is_kfence_address(address)) - return; - hw_set_mem_tag_range(kasan_reset_tag(address), round_up(size, KASAN_GRANULE_SIZE), value); } static inline void unpoison_range(const void *address, size_t size) { - /* Skip KFENCE memory if called explicitly outside of sl*b. */ - if (is_kfence_address(address)) - return; - hw_set_mem_tag_range(kasan_reset_tag(address), round_up(size, KASAN_GRANULE_SIZE), get_tag(address)); } --- a/mm/kasan/shadow.c~a +++ a/mm/kasan/shadow.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -85,10 +84,6 @@ void poison_range(const void *address, s address = kasan_reset_tag(address); size = round_up(size, KASAN_GRANULE_SIZE); - /* Skip KFENCE memory if called explicitly outside of sl*b. */ - if (is_kfence_address(address)) - return; - shadow_start = kasan_mem_to_shadow(address); shadow_end = kasan_mem_to_shadow(address + size); @@ -106,14 +101,6 @@ void unpoison_range(const void *address, */ address = kasan_reset_tag(address); - /* - * Skip KFENCE memory if called explicitly outside of sl*b. Also note - * that calls to ksize(), where size is not a multiple of machine-word - * size, would otherwise poison the invalid portion of the word. - */ - if (is_kfence_address(address)) - return; - poison_range(address, size, tag); if (size & KASAN_GRANULE_MASK) { _