From patchwork Mon Jun 11 20:08:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10458779 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 66E6E60234 for ; Mon, 11 Jun 2018 20:08:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4573F277D9 for ; Mon, 11 Jun 2018 20:08:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3807D27B81; Mon, 11 Jun 2018 20:08:22 +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=-2.9 required=2.0 tests=BAYES_00, 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 816C0277D9 for ; Mon, 11 Jun 2018 20:08:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E8B66B0005; Mon, 11 Jun 2018 16:08:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 798086B0006; Mon, 11 Jun 2018 16:08:20 -0400 (EDT) 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 660166B0007; Mon, 11 Jun 2018 16:08:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f199.google.com (mail-wr0-f199.google.com [209.85.128.199]) by kanga.kvack.org (Postfix) with ESMTP id 06BC66B0005 for ; Mon, 11 Jun 2018 16:08:20 -0400 (EDT) Received: by mail-wr0-f199.google.com with SMTP id j14-v6so11952363wrq.4 for ; Mon, 11 Jun 2018 13:08:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:date:from:to :cc:subject:reply-to:references:mime-version:in-reply-to:user-agent :message-id:content-transfer-encoding:content-disposition; bh=hTGRli/n8Y0OfwWJpmoyqH/MVDtAiJDSDaIMXbmtO7g=; b=WAnFmt7H7S/iApSe4QRRPUsOVFmvP5m1D2ZCqjNYZ8/y4Sp//VAJNIMpKn20o7q9fU on0vqa71hitWVAOaDHO65RBbGNO3PO+dLBY5UI1Nf+EwzoNVgmQWtSK5yio69oBbaOUn mRLozpQak7C6EcosYoruzLyTd5VD60EKI9hsV15zkv5tTx1eDGxgWzxbkWxf2LFKH7Ro 39V1IRYSz0fHbaQSPZeX4DpXe1GBPWOIwlPqE58Wms7iOXtda4oeJDmJB6nkj8MqClpT qkXzXOtOH+mhtBfqKmkAOGfO+5VD5f2WwqSUTsrQgHF9T3AncNS/MJ2cQnSPVHNxNwXC BPXA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of linuxram@us.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=linuxram@us.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: APt69E11TdMLD5VAbR1z0aHaUUf8TrPaHsr267ESFRfkXDAJZfdbjHdP 7xOuOzgAMOUxxxm/Vk9bOOhE+4HnuNNokmRhjOdpC2z8JunHoBif6v8J1v9jTqaz5zE2GlKjk2X xTuEmaIG49Dk0sYNjZVlM8gbfxOruK9PzbYCp6SupsLXi7tI2kFoLoT2z8gZh6fJ0Sg== X-Received: by 2002:adf:e881:: with SMTP id d1-v6mr438521wrm.43.1528747699214; Mon, 11 Jun 2018 13:08:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJBscdpYUyGP+JaCMqNTdm00Fc+7i35Ol21zJLB+G7d7BuB6X+MIY2zUAyDF2zJszkKjk1s X-Received: by 2002:adf:e881:: with SMTP id d1-v6mr438484wrm.43.1528747698183; Mon, 11 Jun 2018 13:08:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528747698; cv=none; d=google.com; s=arc-20160816; b=W9nXtuAC0PM/igF+SHNcAnD19qYqM0GUZBZguMLOgh/l9QBwNWWdKkxyIGEg/f0A2i 1xmZCzkCRcZSRfkekBeO7+SaKGKXn4Hi3+zDKGE0PhTRzKAajLJCN8Fm1E67mEDLzIkU JflPhTfpX5UCGmagAxiw7VwOb7Xd7lsTbjNnoXZwqatdeUk2NC75+HRss3WwojJ2LFJd Grpv9BzxIg5U/zt7886JazWjCmcHyGN3W31ofDLoJr27jx+SL21EZt/4iUODzf1PFSui iWJ2ooQGhi6qBJ3/sLUUco4L+lDMdv+0bdFU4bAEqy5q5FYMb/q8AH5t6tkpeV4+qsXv I47g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:content-transfer-encoding:message-id:user-agent :in-reply-to:mime-version:references:reply-to:subject:cc:to:from :date:arc-authentication-results; bh=hTGRli/n8Y0OfwWJpmoyqH/MVDtAiJDSDaIMXbmtO7g=; b=MBIdYiJDaSDhq7iuAcVQmjbjaM7yZX8+yEC/bik2WmGQSfeVsQQcvgzBVVKFYKEb9d fxSCsxnK5/cNI9fCRdFa5MdawtsF5na4CA1wXLSzRLgjqrh8Dg9IFPQ1f3PpKAvDAJuF vKM+UiCuVj1l+8F2u8uAJ+XuhVNLa7yfPWwiFUgGbrCwhqp+hY8lA8wF7eX540LAx/Xd dngrLT9R/OpiqU2MN8oBVra/Danb6+kzZBmXUOFiedZRJ5ZPK6xY6DuBJ0hemD85qItT M8EuiYFqFKE9f+gHwZ1WaB0A1HG8bOKzJkwk/SHUQt0m2/RCVhX4AyYrn5Zze5UIkKo3 gb8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linuxram@us.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=linuxram@us.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id m14-v6si39153942wrf.250.2018.06.11.13.08.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 13:08:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linuxram@us.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linuxram@us.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=linuxram@us.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w5BK3ovN177724 for ; Mon, 11 Jun 2018 16:08:16 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2jhx6ev61a-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 11 Jun 2018 16:08:16 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Jun 2018 21:08:14 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 11 Jun 2018 21:08:12 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w5BK8BT534341056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 11 Jun 2018 20:08:11 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D4BF42049; Mon, 11 Jun 2018 20:58:25 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD81342042; Mon, 11 Jun 2018 20:58:23 +0100 (BST) Received: from ram.oc3035372033.ibm.com (unknown [9.85.200.252]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 11 Jun 2018 20:58:23 +0100 (BST) Date: Mon, 11 Jun 2018 13:08:07 -0700 From: Ram Pai To: Florian Weimer Cc: Linux-MM , linuxppc-dev , Andy Lutomirski , Dave Hansen Subject: Re: pkeys on POWER: Access rights not reset on execve Reply-To: Ram Pai References: <20180603201832.GA10109@ram.oc3035372033.ibm.com> <4e53b91f-80a7-816a-3e9b-56d7be7cd092@redhat.com> <20180604140135.GA10088@ram.oc3035372033.ibm.com> <20180604190229.GB10088@ram.oc3035372033.ibm.com> <30040030-1aa2-623b-beec-dd1ceb3eb9a7@redhat.com> <20180608023441.GA5573@ram.oc3035372033.ibm.com> <2858a8eb-c9b5-42ce-5cfc-74a4b3ad6aa9@redhat.com> <20180611172305.GB5697@ram.oc3035372033.ibm.com> <30f5cb0e-e09a-15e6-f77d-a3afa422a651@redhat.com> MIME-Version: 1.0 In-Reply-To: <30f5cb0e-e09a-15e6-f77d-a3afa422a651@redhat.com> User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18061120-0016-0000-0000-000001DA91B9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18061120-0017-0000-0000-0000322DC026 Message-Id: <20180611200807.GA5773@ram.oc3035372033.ibm.com> Content-Disposition: inline X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-11_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806110225 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 On Mon, Jun 11, 2018 at 07:29:33PM +0200, Florian Weimer wrote: > On 06/11/2018 07:23 PM, Ram Pai wrote: > >On Fri, Jun 08, 2018 at 07:53:51AM +0200, Florian Weimer wrote: > >>On 06/08/2018 04:34 AM, Ram Pai wrote: > >>>> > >>>>So the remaining question at this point is whether the Intel > >>>>behavior (default-deny instead of default-allow) is preferable. > >>> > >>>Florian, remind me what behavior needs to fixed? > >> > >>See the other thread. The Intel register equivalent to the AMR by > >>default disallows access to yet-unallocated keys, so that threads > >>which are created before key allocation do not magically gain access > >>to a key allocated by another thread. > > > >Are you referring to the thread > >'[PATCH] pkeys: Introduce PKEY_ALLOC_SIGNALINHERIT and change signal semantics' > > >Otherwise please point me to the URL of that thread. Sorry and thankx. :) > > No, it's this issue: > > ... Ok. try this patch. This patch is on top of the 5 patches that I had sent last week i.e "[PATCH 0/5] powerpc/pkeys: fixes to pkeys" The following is a draft patch though to check if it meets your expectations. commit fe53b5fe2dcb3139ea27ade3ae7cbbe43c4af3be Author: Ram Pai Date: Mon Jun 11 14:57:34 2018 -0500 powerpc/pkeys: Deny read/write/execute by default Deny everything for all keys; with some exceptions. Do not do this for pkey-0, or else everything will come to a screaching halt. Also by default, do not deny execute for execute-only key. This is a draft-patch for now. Signed-off-by: Ram Pai diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 8225263..289aafd 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c @@ -128,13 +128,13 @@ int pkey_initialize(void) /* register mask is in BE format */ pkey_amr_mask = ~0x0ul; - pkey_iamr_mask = ~0x0ul; + pkey_amr_mask &= ~(0x3ul << pkeyshift(PKEY_0)); + pkey_amr_mask &= ~(0x3ul << pkeyshift(1)); - for (i = 0; i < (pkeys_total - os_reserved); i++) { - pkey_amr_mask &= ~(0x3ul << pkeyshift(i)); - pkey_iamr_mask &= ~(0x1ul << pkeyshift(i)); - } - pkey_amr_mask |= (AMR_RD_BIT|AMR_WR_BIT) << pkeyshift(EXECUTE_ONLY_KEY); + pkey_iamr_mask = ~0x0ul; + pkey_iamr_mask &= ~(0x3ul << pkeyshift(PKEY_0)); + pkey_iamr_mask &= ~(0x3ul << pkeyshift(1)); + pkey_iamr_mask &= ~(0x3ul << pkeyshift(EXECUTE_ONLY_KEY)); pkey_uamor_mask = ~0x0ul; pkey_uamor_mask &= ~(0x3ul << pkeyshift(PKEY_0));