Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp577969ybl; Wed, 14 Aug 2019 02:41:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRDwP6vJ/NEjPI9EvRk4NXAHmr6bElKe5eL0ORAf6ihgAHdeIyEjVy/M49e7waIM07AlkB X-Received: by 2002:aa7:851a:: with SMTP id v26mr159770pfn.238.1565775718452; Wed, 14 Aug 2019 02:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565775718; cv=none; d=google.com; s=arc-20160816; b=isZwdcSibuyimtJYqaeWGkc6bSk2iMs7dE/FoW+eAGKoowPYJ1+vAIek4jc4ZGDigC i5/Cxzo96E/0ZBO6PLunA+BsM9yJ6OEyO+cYUjl4FFwvMF/oCt/w+T2jvydULjOrtEps xWnzBhIGzANlFMKJ3vaicOf4oIXkvSkWIEZf3nJVpOF676B55ooCvxCXUc+sxczxfsuu mOUK2ckqLDpFjGDwnexHDfZMOHAGQkoudHx2ahg9jyl93T4hTN4dN9nDDJy/ugoVyTcA TBJyzv3mDWzIyPuTDCMPlWSK2Yxhyn9GGfwMNVrba4ILNYNbYMTOngG46WfnI0NxcZ+Z eQMw== 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=LfFkLwjqyQIH9T75mSQkj/WAlvM62io+hnQFkWZp6Pc=; b=k83+SHvDK/PeIlEQuXNMMgOrkGROtTEyDZ8vDAxxxunnIZfSEBvAW/y9GnFDM4Sugf UFp7TF6uuyPI0Gw91ZW62laU0PC7iOlVBhAPhfzcpd3A8YjedfMjyIEFIwHUSzBK7qa9 y2bV9WeeNekUb/eS3wd5nJDh/DBb2NVRRlz5IKN+XpXRdjO1Bq+UPmCcCqmG9eSvikmY BGzL57qBPcKKqdO0m0p09xyS2J8HNoaHZqH63O/f7BdqBPsF0qu8w1ow+45n02NSDyf/ sz27MmeR9tY7sjflmNib3mvKbqGxm+P7L2sS3QIb8mIfcqdWge0eTIaeVFx4vcPCEOyF XaqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jFuFnRB0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x5si2192204pln.274.2019.08.14.02.41.42; Wed, 14 Aug 2019 02:41:58 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=jFuFnRB0; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726575AbfHNJlF (ORCPT + 99 others); Wed, 14 Aug 2019 05:41:05 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39885 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfHNJlF (ORCPT ); Wed, 14 Aug 2019 05:41:05 -0400 Received: by mail-pf1-f195.google.com with SMTP id f17so49260087pfn.6 for ; Wed, 14 Aug 2019 02:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=LfFkLwjqyQIH9T75mSQkj/WAlvM62io+hnQFkWZp6Pc=; b=jFuFnRB0/8csf+W8FViKPIDaEmS37F+row4a3iyvUZTk3+UEYYsc/umedWVPXZUEPN LDdtmXgjxyfggY0JP9gzuxWNLkt9w7hpjz8XuE2kCmm80gh3Ki9JQxk9tWm1EBPlfH/K DP12ymtzlN9IHXiSHs19xPERgy/Qb624g0yuWHYl2dH4tQJSIcz8tQn7dX+ptc4xCSJz B5+5z3lM3tK0y5tdfekEiXiAa3s+bulCjpDfShlgK+v7H75t366TqhsaV7NYrIMciMC/ qdUcENrR41a7h870LEPPVNzFj8aZQuAJJprtvNeh4/Pv5rXpcBKXNaVjOrJr6lJaZqWu frmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=LfFkLwjqyQIH9T75mSQkj/WAlvM62io+hnQFkWZp6Pc=; b=Aj9qcNqyQvqljSwKM5tuXeVILdC7qsBgSYICNuq5EcoU+zvasZ9rUIHzR5zoBRyO06 3mD62vp+ZKbDRq9JlFooQW4NO84v0BFkv8AmQHUGWSUh6uQqCOihMLG2gLtXWrsR+/QI KQw9hGcRE83d/ZOFAEKP6rh+FBQ51Sdxwih2wsf4wSBBLBwJDvtGt7lafsVJ4lQ+z0/j 1bUfED4rCWjciDZFJHQRCrdXSuENB683ClsfnTFKVeZOagMLlYpXEGz39RBFmTXNczJy fNGYLc52tQ+QmyIieVzRwlDaQ7Id3w5NSuy+UgDBaPBgqmeFSO3wuUNgz4yUPD6J7ikC Kc8Q== X-Gm-Message-State: APjAAAXHRpsLnc3hrCLLIAB8poMZTBYXYYykm50VHFWqYS+bVYMKXfkT ouPlFVDKYfun5F4nbiXjS4U02IM6JyLObg== X-Received: by 2002:a62:7a0f:: with SMTP id v15mr26284997pfc.35.1565775664294; Wed, 14 Aug 2019 02:41:04 -0700 (PDT) Received: from [192.168.68.119] (203-219-253-117.static.tpgi.com.au. [203.219.253.117]) by smtp.gmail.com with ESMTPSA id i11sm17425385pfk.34.2019.08.14.02.41.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Aug 2019 02:41:03 -0700 (PDT) Subject: Re: [PATCH v9 7/7] powerpc: add machine check safe copy_to_user To: Santosh Sivaraj , linuxppc-dev , Linux Kernel Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Reza Arbab , Chandan Rajendra , Michael Ellerman , Nicholas Piggin , christophe leroy References: <20190812092236.16648-1-santosh@fossix.org> <20190812092236.16648-8-santosh@fossix.org> From: Balbir Singh Message-ID: <74d12529-d068-0210-e229-5cea68bcf9da@gmail.com> Date: Wed, 14 Aug 2019 19:40:58 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190812092236.16648-8-santosh@fossix.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/8/19 7:22 pm, Santosh Sivaraj wrote: > Use memcpy_mcsafe() implementation to define copy_to_user_mcsafe() > > Signed-off-by: Santosh Sivaraj > --- > arch/powerpc/Kconfig | 1 + > arch/powerpc/include/asm/uaccess.h | 14 ++++++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig > index 77f6ebf97113..4316e36095a2 100644 > --- a/arch/powerpc/Kconfig > +++ b/arch/powerpc/Kconfig > @@ -137,6 +137,7 @@ config PPC > select ARCH_HAS_STRICT_KERNEL_RWX if ((PPC_BOOK3S_64 || PPC32) && !RELOCATABLE && !HIBERNATION) > select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST > select ARCH_HAS_UACCESS_FLUSHCACHE if PPC64 > + select ARCH_HAS_UACCESS_MCSAFE if PPC64 > select ARCH_HAS_UBSAN_SANITIZE_ALL > select ARCH_HAVE_NMI_SAFE_CMPXCHG > select ARCH_KEEP_MEMBLOCK > diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h > index 8b03eb44e876..15002b51ff18 100644 > --- a/arch/powerpc/include/asm/uaccess.h > +++ b/arch/powerpc/include/asm/uaccess.h > @@ -387,6 +387,20 @@ static inline unsigned long raw_copy_to_user(void __user *to, > return ret; > } > > +static __always_inline unsigned long __must_check > +copy_to_user_mcsafe(void __user *to, const void *from, unsigned long n) > +{ > + if (likely(check_copy_size(from, n, true))) { > + if (access_ok(to, n)) { > + allow_write_to_user(to, n); > + n = memcpy_mcsafe((void *)to, from, n); > + prevent_write_to_user(to, n); > + } > + } > + > + return n; Do we always return n independent of the check_copy_size return value and access_ok return values? Balbir Singh. > +} > + > extern unsigned long __clear_user(void __user *addr, unsigned long size); > > static inline unsigned long clear_user(void __user *addr, unsigned long size) >