From patchwork Tue Feb 26 17:22:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 10830653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A9CD13B5 for ; Tue, 26 Feb 2019 17:22:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 403922D3E7 for ; Tue, 26 Feb 2019 17:22:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 344FA2D3D2; Tue, 26 Feb 2019 17:22:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D6882D388 for ; Tue, 26 Feb 2019 17:22:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80B6F8E0007; Tue, 26 Feb 2019 12:22:48 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 740898E0003; Tue, 26 Feb 2019 12:22:48 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BB048E0007; Tue, 26 Feb 2019 12:22:48 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by kanga.kvack.org (Postfix) with ESMTP id F1FF08E0003 for ; Tue, 26 Feb 2019 12:22:47 -0500 (EST) Received: by mail-wm1-f72.google.com with SMTP id t133so710534wmg.4 for ; Tue, 26 Feb 2019 09:22:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:message-id:in-reply-to:references :from:subject:to:cc:date; bh=g6fhwCUzzCOYhxsR7m9Lo9kcYtSGDH5kmO2yLp27uXY=; b=VYkyFY7n6fvApIBGBaUbhqc42HFsAhBl/CogJ2QgUG8PyAOLLi8Bu9z3nm5K87fOj6 1IPd+GC/1MPAhFcUqCk532L8n/EkI8pGYU5L3QV7t+j9gs8dRR4MHVWbY6WXO14WEXxI ucbjxF+nnE12uvSSLKryn80uwouNOizIKku5otGBR0sm9sSJBgAZ3Kiq9PN+my6XEFnn LLh0QMzZ6uBORWwbZRe9iHRtUXyHFEWYqNOfhxPvLS0ec+lZfcST2VreWmfit4BVmXJ3 0mM4IEdvugQ0Fk8GQ++07tw0r3vaeZ3e2zq7nfV7x8SZ23kKFM3MtmsbpdA0HQN0XIHJ +UUg== X-Gm-Message-State: AHQUAuZVAGep+QMWqtBuPHvpeXlmsG6viE/rVj/ESqLlrdAl3ExA448o p84E9BK8M6Ty0iZQLc2Wjbkvouhkj2W9CU4W0zpcb3itSwjYHsfXzWTzv1UVTG9nE3KdLi2mxw4 dZYByAcc36xC1tov9Fklqp7LHTok8EGjx44FyHxaZ3TpBTQFHh3KiwC7Lh1rJ9XC78Q== X-Received: by 2002:a1c:2743:: with SMTP id n64mr3585958wmn.143.1551201767518; Tue, 26 Feb 2019 09:22:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IYmY5HTOgDtqV1Pp+0wp9qiwxuSaffaQ9yk6IaKGAfgqMmogN0XakajTrsCJhttuaBSx2q6 X-Received: by 2002:a1c:2743:: with SMTP id n64mr3585911wmn.143.1551201766390; Tue, 26 Feb 2019 09:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551201766; cv=none; d=google.com; s=arc-20160816; b=PsqfBV/mrZJsUZJPcNzetyd4WaKXkwRmb+uaYXcG+ga7d20boQ7D9i9YKm8fWNn5EL k3e/HcOnVpkTfpHkYjo/q7OpP/gMJAd4Jbz8d8jWcR8VlBuXjevfqLUvvAcLoxk4HFu9 X81hZ9bulkvHlLlUUxsqNf94CJXc9LWyy7Gbe/6NK6fJSpgrnBCRw+RyioEXIzaazhhu T/OI6Q+MAoZZ4KGcogpQ3qfT2I/5wDYtWbCDtpZDvt7BGu13sryOrXdNcJs7SSaq09Wc WBMlSU71zjX1C/ALwMwn56yjw3nMPyFtEmmxJdMOjbhwg010g7mLO9nMIzdrLtoUFsfa cLWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=date:cc:to:subject:from:references:in-reply-to:message-id :dkim-signature; bh=g6fhwCUzzCOYhxsR7m9Lo9kcYtSGDH5kmO2yLp27uXY=; b=i7diXIKNoqbtHdXF3TM/D7kb41huraktdrGn3cLjQwBMnlyv5jpE94EkxbNAcwhFhq JIbxm/zsetZ44eILZ6sHSmQdDw5Lfff1GXQqBRvJ4mKkQiFiUDWEXEOI6lKbMiyvfXEF Mf2J0yXUQ/GCl6wcs6bYVsRY2AY2u0VlZD7zvoEKFLlSsMMBGGQqgEiH82EWn1erEQcO 2H1DQlferDo4kshEaUsw06NnCZmtYlJO4zgL0+g7JUHybtlu9ukCke+ppkC+kjhTP2ao /ZTdHcFsShuq8H7XZas7Hj8ngAO5CZzJM0PYDwgu+LYV2ax8TbnXdBkY31ITfbjCDGOg iCzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=ti1gVhxy; spf=pass (google.com: domain of christophe.leroy@c-s.fr designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@c-s.fr Received: from pegase1.c-s.fr (pegase1.c-s.fr. [93.17.236.30]) by mx.google.com with ESMTPS id h65si9035506wmg.67.2019.02.26.09.22.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Feb 2019 09:22:46 -0800 (PST) Received-SPF: pass (google.com: domain of christophe.leroy@c-s.fr designates 93.17.236.30 as permitted sender) client-ip=93.17.236.30; Authentication-Results: mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=ti1gVhxy; spf=pass (google.com: domain of christophe.leroy@c-s.fr designates 93.17.236.30 as permitted sender) smtp.mailfrom=christophe.leroy@c-s.fr Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4485H81cRnz9vJLf; Tue, 26 Feb 2019 18:22:44 +0100 (CET) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=ti1gVhxy; dkim-adsp=pass; 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 YOx664-dutKR; Tue, 26 Feb 2019 18:22:44 +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 4485H80QF9z9vJLY; Tue, 26 Feb 2019 18:22:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1551201764; bh=g6fhwCUzzCOYhxsR7m9Lo9kcYtSGDH5kmO2yLp27uXY=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=ti1gVhxyHR1EvrNdR4KPf3SZ+OfMqvO5xQo4KDWAttWKHQctabiTkPCjAmwXBDInv 43t2J8BJYVHmrr1aVPUuxFMair+woIM74TbrxfjfUGnjIuy7vWaDCmnC+GeNapRCx+ 1/aq0Z4u+d8SVSJtWwtfNNE30GRtJLC6KEwtHst0= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A87DD8B97A; Tue, 26 Feb 2019 18:22:45 +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 wssN5870d0AG; Tue, 26 Feb 2019 18:22:45 +0100 (CET) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6DBB28B96A; Tue, 26 Feb 2019 18:22:45 +0100 (CET) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 4DA666F7B5; Tue, 26 Feb 2019 17:22:45 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v8 04/11] powerpc/mm: don't use direct assignation during early boot. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Nicholas Piggin , Aneesh Kumar K.V , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Daniel Axtens Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Date: Tue, 26 Feb 2019 17:22:45 +0000 (UTC) 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: X-Virus-Scanned: ClamAV using ClamSMTP In kernel/cputable.c, explicitly use memcpy() instead of *y = *x; This will allow GCC to replace it with __memcpy() when KASAN is selected. Acked-by: Dmitry Vyukov Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/cputable.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 1eab54bc6ee9..cd12f362b61f 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c @@ -2147,7 +2147,11 @@ void __init set_cur_cpu_spec(struct cpu_spec *s) struct cpu_spec *t = &the_cpu_spec; t = PTRRELOC(t); - *t = *s; + /* + * use memcpy() instead of *t = *s so that GCC replaces it + * by __memcpy() when KASAN is active + */ + memcpy(t, s, sizeof(*t)); *PTRRELOC(&cur_cpu_spec) = &the_cpu_spec; } @@ -2161,8 +2165,11 @@ static struct cpu_spec * __init setup_cpu_spec(unsigned long offset, t = PTRRELOC(t); old = *t; - /* Copy everything, then do fixups */ - *t = *s; + /* + * Copy everything, then do fixups. Use memcpy() instead of *t = *s + * so that GCC replaces it by __memcpy() when KASAN is active + */ + memcpy(t, s, sizeof(*t)); /* * If we are overriding a previous value derived from the real