Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3554053ybl; Mon, 12 Aug 2019 02:25:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTEPcZK2Qwi7+4oUi8jU16aKzLlCiAUu2JMYzBsIrnHi7MNcRCGUBBDw2sc5SiwtqtH8e9 X-Received: by 2002:a17:90a:974c:: with SMTP id i12mr1107525pjw.12.1565601920118; Mon, 12 Aug 2019 02:25:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565601920; cv=none; d=google.com; s=arc-20160816; b=SaXj0iQayy6B7bSOyPzbpu3c11Up3imAx5cVaRu4CdrJ2V+tlAu2zap5Ew5dxcTeZ6 IKhrtvbULK0KjqOEcQuClzfieHno4nNDbGlk+3IdwfXChkMNbSd4zVSZeGT+acdaS7HP vIxkwTJBo5ZiysHZiaWhxHWnv0AXii4jS/T4+PCYbq20/x9xWeYIe7zIYp2AQZnBDdoe qlkV7M0TMj5lf7GhC7zrr9H0jDzOjcN6Vb4aAKUI1909S98060lByiJvoGB26tm5sbbw 1qKWKDM8C5wCyGhohDngkRPLtsuLnGoOc9XINyTDDXEaj3aYcBr/vDaUt4YQDEgSGJ5h Ls6Q== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/fmDyudl4ch4OP62eHQXqnVTVLm5jUqLhjp55PmzJvo=; b=mTmpRnw3IHfYMu7sIeChV4c0jNU5xw7j6Bfb81bzwAsY8LxgjoB/qAfuqileWGHiMH qgdEX4/OGrK+R/lzU33RHgDbQtfNrRvvW2Ou5vP3kBz5I7VsRpX+JwcOwSlQLyMF1sHT uemoD9lZrKkdKab01KeKKcE7+cj4V98Vplmf0yp+jhn+zHfgZidTT8Nc++/FQViFXNQI f+CAYkKkKOXq700k6NjUiSWDXBFs833xl+XYLl3Ax9crVlmaH6P2FPKg+1gXh8aBcJ+p WsvvMheWPuzBylTPx8uMqBL32V8Gd8+a0waqTvgGdYzQbgefWCP3+rpbtlqGSJTmiyvv fp8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=FXLvaXon; 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 i4si13931110pgj.558.2019.08.12.02.25.05; Mon, 12 Aug 2019 02:25:20 -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=@fossix-org.20150623.gappssmtp.com header.s=20150623 header.b=FXLvaXon; 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 S1727528AbfHLJXT (ORCPT + 99 others); Mon, 12 Aug 2019 05:23:19 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:43314 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727524AbfHLJXR (ORCPT ); Mon, 12 Aug 2019 05:23:17 -0400 Received: by mail-pf1-f195.google.com with SMTP id v12so1612363pfn.10 for ; Mon, 12 Aug 2019 02:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fossix-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/fmDyudl4ch4OP62eHQXqnVTVLm5jUqLhjp55PmzJvo=; b=FXLvaXonyVIAIIdHfE+h+/srPCOougwvG/jI7j3hLrjD+C6AvBOGYiXQTlTO3Dhciz MyxbG20eAjLWMBWN4CnSPXkbLzkzkKYnlueT8mDCN9+BjwJv0UShmzszeoBGKxhij0+2 +mIQgoYUKWkHjbFK7l4Shd8rvC/LRZcYT0HQ6ERx0tOdtDHxn+3pwtXWX6PLTuhzvo2q M/5VtViQNupTnwfoqVDhPOxkPssGQaLTGHeEMtMazGK0nt7XOp1ZAlfDszbXjX0mMDc6 TeEcKeGnLpzFp8CI7MYzCuCHoRRrgnEXJWqiZtcKLq3x4rTdSrYdsO1oNfN8Pl1j1bBS dhig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/fmDyudl4ch4OP62eHQXqnVTVLm5jUqLhjp55PmzJvo=; b=monCgNGn2hy2j8qw5pbGdzaYoZ4rurx5JljEPoOJ5f91v446pFoTuP3+LHaM4UwFPP aopoSQdFFA1AJBds52c7nhYYYLr5dNvIN7RBLeOO38ljgrU2oTrorJM14xA0ENAkYQcq Xe848PNghK6SE9y7l6/vEzV003q8fj5I0mL/TW/NqyEb0L+wfeLL2q8oX5nX9dqU99Xr XG7KVf34e9MjWyppmvbKie3TEQCr2vp6CzbyZE0Mf9kqU4f9h4ct6Y1kuPofZJbWBm5+ O6pqxxLSkf0ZiPVNXgqij7/KFJ0Klge4HdZdA3emNQCn5kgdQd5p1/uSTVzSzj+JlBUF qSgA== X-Gm-Message-State: APjAAAWG1um/hPDGH0P3uJ+U0o+2VKSDpSH4QCMVqwbH/bAqakttzH3t WsM0yr2yoM5X9WuWN2ElIf+DZA== X-Received: by 2002:a63:6947:: with SMTP id e68mr29764764pgc.60.1565601796914; Mon, 12 Aug 2019 02:23:16 -0700 (PDT) Received: from santosiv.in.ibm.com ([129.41.84.75]) by smtp.gmail.com with ESMTPSA id y188sm10543517pfb.115.2019.08.12.02.23.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 02:23:16 -0700 (PDT) From: Santosh Sivaraj To: linuxppc-dev , Linux Kernel Cc: "Aneesh Kumar K.V" , Mahesh Salgaonkar , Reza Arbab , Balbir Singh , Chandan Rajendra , Michael Ellerman , Nicholas Piggin , christophe leroy Subject: [PATCH v9 7/7] powerpc: add machine check safe copy_to_user Date: Mon, 12 Aug 2019 14:52:36 +0530 Message-Id: <20190812092236.16648-8-santosh@fossix.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190812092236.16648-1-santosh@fossix.org> References: <20190812092236.16648-1-santosh@fossix.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; +} + extern unsigned long __clear_user(void __user *addr, unsigned long size); static inline unsigned long clear_user(void __user *addr, unsigned long size) -- 2.21.0