Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp161294imu; Tue, 15 Jan 2019 18:54:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN4yEkdAviDh9qT1I2ixujFLZUgn3A6NppQZBj9NVtgvLkli9eJVQvIHMrHgyApVY96UdSyW X-Received: by 2002:a17:902:145:: with SMTP id 63mr7416745plb.256.1547607299784; Tue, 15 Jan 2019 18:54:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547607299; cv=none; d=google.com; s=arc-20160816; b=oJmIy8fn+bhLP8B8aOc5UGTwjUQyLVgcqi3TP5gCy77tvw/C6XGMR+OLF3N1y4b96j pYipiskdM7Md/tVFp4XDwCIETher9WwB0GBce6iiMatZdX1GRGx063CU7HIkgQMTWvFW 4ewz3hIL0rhmhLpJJW7Dc+CLRVnNwuzwQgaGjIKoC2KyQPypEbNPFFtTyYqUymlmT5DX 81ZVJXhu26L5ZK65IhYsV8kdJBV9g2HJpc/bqBEo02VpROI89D2RdgmtbXyr96wwSM4c 0jFwXP9RkBBVOcyLE1qrbeDvh3Kkdc8OWFzIHY4ZSVWf3BR+rIMGVzsTiaZuntqWJpos jYFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=nfiqene5M3o5kAGA4cFhUacIFPIGZMQYcHqzH6hGjNc=; b=hj/BiAgqH2WRw8DHrYlWGKe5wEF52OcI/wbmJr/lCJ6PcyeZTGY8ps0HNeNQJ/02K4 sqwn7J5xqFoxhFvTxChzK6/Lh04xeozbd8sjmyt8tgcLePTAGe2MHWs7HgDbrIJSIxno FFspPscGTOmATJea4sgxfCOfEEdLtIqO8GoIkr97swHCwZzeS4vnF+TQbvq5hUthZ1Cn 0/uAvik+r0u/UKzVOpIQ0ZAgmbTg5Sd7gh7agj05U9Wg+wbAtlK807owrXoVz6Phyq44 lc3syR9oZlQISPpIfYdA12sxNYRWoiu/4HYHEsDaBolGOdw4f/IJ3/eKTpeP8g/5rqBE UgmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b="gByyt/X9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d12si5375382pln.340.2019.01.15.18.54.39; Tue, 15 Jan 2019 18:54:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b="gByyt/X9"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388126AbfAORZj (ORCPT + 99 others); Tue, 15 Jan 2019 12:25:39 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:10353 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728736AbfAORZj (ORCPT ); Tue, 15 Jan 2019 12:25:39 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43fHKp6Q7fz9vBJc; Tue, 15 Jan 2019 18:25:34 +0100 (CET) Authentication-Results: localhost; dkim=permerror reason="key not found" header.d=c-s.fr header.i=@c-s.fr header.b=gByyt/X9; dkim-adsp=none (insecure policy); dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id Lf7f_X3vnQ4Y; Tue, 15 Jan 2019 18:25:34 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43fHKp58mcz9vBJY; Tue, 15 Jan 2019 18:25:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1547573134; bh=nfiqene5M3o5kAGA4cFhUacIFPIGZMQYcHqzH6hGjNc=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=gByyt/X9hT/1zq0OG6PlK51/hNVU37xWuECwM4TeCx9xzapEuwjeNIQQt+44LpPVI GPQCzr25yGAZrAYdGATnFGkMH+De6KKTgXyxHHtPY/IM3+wZfsrJ1KyPmYPtItJIXT f2eh28nIAavAM0oJBLzprzk537I97GPpAynb7djXxsCE5sCYXS5NGivFQ8B8J8s1a4 Uz7xlYyFXZxJGIBdlsetKewbArORfGGN6uWVHShkMsbo25geYGrhH1Ai0Uo7oZxYCy yJOF23I25T/AYNkvyzwOfV6pKpK04Sc2YeGRy9aak14ip49YqhvW9n531hafkubKwQ haLmeX+VW4K7P3Y0kPPihVVsCoqq5nOt9apMPYdMrPYiIZIXUUztsNWvp215CQHQJL BHNU06BH9enFTGmo1OfkQas1xZlQZBh+QHMTkOzzTHdGtXM0SJ9ZkkNS5k4ed0A3kQ C9DIKGGtPTtpdBjCz9BqhFZUB021FCYxCGhoCLMycy14x4N9V0JRa2xYNDNRusoLPc 6J/QZi+XnYDnwcCGNW+iqTURwzn+UkQfcd9K/9nBNbPRQrt+PBxoKbONieBwlpa+fA wL+5wfG3g7vIE4rq9ewA1gcfQzuOBzMy/Rya4DVV5yqGoLlge2ozTiQBbZeuRPgNb8 44MeCtd1qJ/r9+Tk7/Q0L7q0= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E11108B7FF; Tue, 15 Jan 2019 18:25:36 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id djneeju_xvcU; Tue, 15 Jan 2019 18:25:36 +0100 (CET) Received: from PO15451 (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id E2C888B7EE; Tue, 15 Jan 2019 18:25:35 +0100 (CET) Subject: Re: [PATCH v3 1/3] powerpc/mm: prepare kernel for KAsan on PPC32 To: Dmitry Vyukov , Andrey Ryabinin Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , "Aneesh Kumar K.V" , Alexander Potapenko , LKML , linuxppc-dev@lists.ozlabs.org, kasan-dev , Linux-MM References: <0c854dd6b110ac2b81ef1681f6e097f59f84af8b.1547289808.git.christophe.leroy@c-s.fr> <801c7d58-417d-1e65-68a0-b8cf02f9f956@c-s.fr> <330696c0-90c6-27de-5eb3-4da2159fdfbc@virtuozzo.com> From: Christophe Leroy Message-ID: <301f5826-64ab-1cf4-7e7e-cd026de77bca@c-s.fr> Date: Tue, 15 Jan 2019 18:25:35 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 15/01/2019 à 18:10, Dmitry Vyukov a écrit : > On Tue, Jan 15, 2019 at 6:06 PM Andrey Ryabinin wrote: >> >> >> >> On 1/15/19 2:14 PM, Dmitry Vyukov wrote: >>> On Tue, Jan 15, 2019 at 8:27 AM Christophe Leroy >>> wrote: >>>> On 01/14/2019 09:34 AM, Dmitry Vyukov wrote: >>>>> On Sat, Jan 12, 2019 at 12:16 PM Christophe Leroy >>>>> wrote: >>>>> > >>>>> > In kernel/cputable.c, explicitly use memcpy() in order >>>>> > to allow GCC to replace it with __memcpy() when KASAN is >>>>> > selected. >>>>> > >>>>> > Since commit 400c47d81ca38 ("powerpc32: memset: only use dcbz once cache is >>>>> > enabled"), memset() can be used before activation of the cache, >>>>> > so no need to use memset_io() for zeroing the BSS. >>>>> > >>>>> > Signed-off-by: Christophe Leroy >>>>> > --- >>>>> > arch/powerpc/kernel/cputable.c | 4 ++-- >>>>> > arch/powerpc/kernel/setup_32.c | 6 ++---- >>>>> > 2 files changed, 4 insertions(+), 6 deletions(-) >>>>> > >>>>> > diff --git a/arch/powerpc/kernel/cputable.c >>>>> b/arch/powerpc/kernel/cputable.c >>>>> > index 1eab54bc6ee9..84814c8d1bcb 100644 >>>>> > --- a/arch/powerpc/kernel/cputable.c >>>>> > +++ b/arch/powerpc/kernel/cputable.c >>>>> > @@ -2147,7 +2147,7 @@ void __init set_cur_cpu_spec(struct cpu_spec *s) >>>>> > struct cpu_spec *t = &the_cpu_spec; >>>>> > >>>>> > t = PTRRELOC(t); >>>>> > - *t = *s; >>>>> > + memcpy(t, s, sizeof(*t)); >>>>> >>>>> Hi Christophe, >>>>> >>>>> I understand why you are doing this, but this looks a bit fragile and >>>>> non-scalable. This may not work with the next version of compiler, >>>>> just different than yours version of compiler, clang, etc. >>>> >>>> My felling would be that this change makes it more solid. >>>> >>>> My understanding is that when you do *t = *s, the compiler can use >>>> whatever way it wants to do the copy. >>>> When you do memcpy(), you ensure it will do it that way and not another >>>> way, don't you ? >>> >>> It makes this single line more deterministic wrt code-gen (though, >>> strictly saying compiler can turn memcpy back into inlines >>> instructions, it knows memcpy semantics anyway). >>> But the problem I meant is that the set of places that are subject to >>> this problem is not deterministic. So if we go with this solution, >>> after this change it's in the status "works on your machine" and we >>> either need to commit to not using struct copies and zeroing >>> throughout kernel code or potentially have a long tail of other >>> similar cases, and since they can be triggered by another compiler >>> version, we may need to backport these changes to previous releases >>> too. Whereas if we would go with compiler flags, it would prevent the >>> problem in all current and future places and with other past/future >>> versions of compilers. >>> >> >> The patch will work for any compiler. The point of this patch is to make >> memcpy() visible to the preprocessor which will replace it with __memcpy(). > > For this single line, yes. But it does not mean that KASAN will work. > >> After preprocessor's work, compiler will see just __memcpy() call here. This problem can affect any arch I believe. Maybe the 'solution' would be to run a generic script similar to arch/powerpc/kernel/prom_init_check.sh on all objects compiled with KASAN_SANITIZE_object.o := n don't include any reference to memcpy() memset() or memmove() ? Christophe