Received: by 10.223.164.200 with SMTP id h8csp921796wrb; Mon, 6 Nov 2017 01:01:07 -0800 (PST) X-Google-Smtp-Source: ABhQp+QgvKrhnU0fsqGbz2rgQ0cOoa/pm93at6MIxSB5bs3VINIbqvfhcBf8tkq1P/l8a/VvRX8j X-Received: by 10.99.102.129 with SMTP id a123mr14505311pgc.10.1509958867873; Mon, 06 Nov 2017 01:01:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1509958867; cv=none; d=google.com; s=arc-20160816; b=uem3Ayv6QDM6rt/Djb1IQTdCracSgNQYShtKdDtiZy58H0c1YOVIago2ZblASgTdLr M2YDL4GCzbZCN5Xbd+Ha4psyjdLXuvFYkaYwL0JutmUDyAOWd0qPNVbnI20LnOcey3Io stGhVNYsQ5hexfuiGDpVPPzjZdR9q41h/z4xwElTGneGTpPtKw6B5Pxdhiwo2dl/C29h /k47baqBqNrqQ1FVwNHwWQWv9nzmZ2egG+v1Hwe6tXiMT8KPSDRrRyhla+Oyp5xKzHkH J7tVKvSWp+Fzk+bizMgPNtJvBtsqm4j2Wl2AaxOaOSVEcHC1HnAoajaGCYUugryZHh9s 8T6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=nxk5VMPpg3HXaVzjsrCv8GKh2UzEGwd1dacz4RORheI=; b=P9nawmS0msdFX9AyMiyV6CMVsUph131xcjlYdmvwojV+cYs/moIAoJgD2eK0/AB45v TZyfUtqjXPpSsd5M1uONxEzuFT0+ewal6jIWtFLhYKOZsXrNQDBc37Vb/jY/W2UYC9hv 52nfn/GXZm+THbhtFXWaRmP5AQaVe7ky1JgFGbBSYH7ld5CgpLqDW/iFH3V4jyUawxdD likTszOxPwXtdV0zv1jLz5W7Z0+B6fDkymgGXzZajatYfORaNH23gCyLqgNXJar4Qxol XRyGYE6wtoX15Qdkco5fVxnzuD2FqfzzrN9lT1Xb0PiAGeo/7lawAdo6DF6zWZNQbgUx UQ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=UXyNo4WT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z24si11248251pgc.720.2017.11.06.01.00.53; Mon, 06 Nov 2017 01:01:07 -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=fail header.i=@gmail.com header.s=20161025 header.b=UXyNo4WT; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752300AbdKFI7K (ORCPT + 98 others); Mon, 6 Nov 2017 03:59:10 -0500 Received: from mail-qk0-f194.google.com ([209.85.220.194]:55893 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752117AbdKFI7H (ORCPT ); Mon, 6 Nov 2017 03:59:07 -0500 Received: by mail-qk0-f194.google.com with SMTP id x195so4394827qkb.12; Mon, 06 Nov 2017 00:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=nxk5VMPpg3HXaVzjsrCv8GKh2UzEGwd1dacz4RORheI=; b=UXyNo4WTCt5ZHgZxUuLMqFZytTXutxM1H4r71mpUj/OEOqoSgUe4VPhHj9f+/0t0qu Ccfc/AzmJclLs/hddILslZHdLkfnfomqH3jfwoWSTFSHklZgE5yLVGu6gManm6sheRl3 tQB9yX9CaVbH5gvM1Wc7kANgv0g2N6OEYzm8AiKu2ZQeynlZVGOPak9D16PHCms/TwBF SDn+aPM0ilTtCjQQ/AqGFaqN7iKZ5/puXAt4KTU9QmlM0IQE0PbOU++nrzyApkChpu1w Ed8NfCiLGg2stqCN3zE5XRpDm9sA0+roP/kMuCZLZk7zNu+GNXddCur9rsXxfk4DiQTZ K2xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=nxk5VMPpg3HXaVzjsrCv8GKh2UzEGwd1dacz4RORheI=; b=Rpu68rlWOW9k+EtYzCdjxzottTT/yjlUEI12OeBtINfid/8OSntFhvYlsQ/kj0jGSs CEo3JvV4M1u04tyVAdygHXlzl4UqdpsVaq0quCc+J7ihadAO8FDXk8NL0YBR5sar4iIF ppEdnJOGX/uBwjc+4FdVkLmT21OjwiUgFXMYGkTEnNINxXlrSwFdZemNmwVZxBZQxUkI F3Jnzi0eujMiYyqrxL9uC0L7+jWLfYHOJk/41U3DEmUcFF8A9wHvFolSc8LJpCs52WJ5 Xn6ybH5Q9/qLWEYXzOERK+rxDoHmXiRcvkkgoRSaoWLCkghlvfIx7bGmNobhBPk0I7Jx +UnA== X-Gm-Message-State: AMCzsaUG0KcasVUfTXwPnGf0423huRgvf7wFcDM5SJQuvxECqf9PBKMs Z2NzWQm//e8LF4IGF8Wp0rc= X-Received: by 10.55.82.7 with SMTP id g7mr21372901qkb.276.1509958746408; Mon, 06 Nov 2017 00:59:06 -0800 (PST) Received: from localhost.localdomain (50-39-103-96.bvtn.or.frontiernet.net. [50.39.103.96]) by smtp.gmail.com with ESMTPSA id r26sm8001094qki.42.2017.11.06.00.59.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Nov 2017 00:59:06 -0800 (PST) From: Ram Pai To: mpe@ellerman.id.au, mingo@redhat.com, akpm@linux-foundation.org, corbet@lwn.net, arnd@arndb.de Cc: linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, x86@kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, benh@kernel.crashing.org, paulus@samba.org, khandual@linux.vnet.ibm.com, aneesh.kumar@linux.vnet.ibm.com, bsingharora@gmail.com, hbabu@us.ibm.com, mhocko@kernel.org, bauerman@linux.vnet.ibm.com, ebiederm@xmission.com, linuxram@us.ibm.com Subject: [PATCH v9 17/51] powerpc: check key protection for user page access Date: Mon, 6 Nov 2017 00:57:09 -0800 Message-Id: <1509958663-18737-18-git-send-email-linuxram@us.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> References: <1509958663-18737-1-git-send-email-linuxram@us.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure that the kernel does not access user pages without checking their key-protection. Signed-off-by: Ram Pai --- arch/powerpc/include/asm/book3s/64/pgtable.h | 13 +++++++++++++ 1 files changed, 13 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/pgtable.h b/arch/powerpc/include/asm/book3s/64/pgtable.h index c277a63..5ecb846 100644 --- a/arch/powerpc/include/asm/book3s/64/pgtable.h +++ b/arch/powerpc/include/asm/book3s/64/pgtable.h @@ -464,6 +464,19 @@ static inline void huge_ptep_set_wrprotect(struct mm_struct *mm, #ifdef CONFIG_PPC_MEM_KEYS extern bool arch_pte_access_permitted(u64 pte, bool write, bool execute); + +#define pte_access_permitted(pte, write) \ + (pte_present(pte) && \ + ((!(write) || pte_write(pte)) && \ + arch_pte_access_permitted(pte_val(pte), !!write, 0))) + +/* + * We store key in pmd for huge tlb pages. So need to check for key protection. + */ +#define pmd_access_permitted(pmd, write) \ + (pmd_present(pmd) && \ + ((!(write) || pmd_write(pmd)) && \ + arch_pte_access_permitted(pmd_val(pmd), !!write, 0))) #endif /* CONFIG_PPC_MEM_KEYS */ #define __HAVE_ARCH_PTEP_GET_AND_CLEAR -- 1.7.1 From 1583299646624991096@xxx Mon Nov 06 07:10:08 +0000 2017 X-GM-THRID: 1583299646624991096 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread