From patchwork Mon Jun 4 19:02:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ram Pai X-Patchwork-Id: 10447191 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 2D38D60284 for ; Mon, 4 Jun 2018 19:02:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15CA129092 for ; Mon, 4 Jun 2018 19:02:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 083202909C; Mon, 4 Jun 2018 19:02:55 +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 761F529092 for ; Mon, 4 Jun 2018 19:02:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76CDD6B0003; Mon, 4 Jun 2018 15:02:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 71A936B0005; Mon, 4 Jun 2018 15:02:43 -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 5E2706B0006; Mon, 4 Jun 2018 15:02:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr0-f198.google.com (mail-wr0-f198.google.com [209.85.128.198]) by kanga.kvack.org (Postfix) with ESMTP id 0583E6B0003 for ; Mon, 4 Jun 2018 15:02:43 -0400 (EDT) Received: by mail-wr0-f198.google.com with SMTP id k18-v6so8613798wrn.8 for ; Mon, 04 Jun 2018 12:02:42 -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:in-reply-to:user-agent:message-id :content-disposition:content-transfer-encoding:mime-version; bh=RpsTiyxDQ/h5wVhrKjIdsndVmLViRtPE+cK/R5isi9E=; b=bDRa3wzMwgo0DGpm+KP0J3VszFPbz6qKCTm7lGZ5PDXUamPb9obAgxYt1we+QMILc0 0e4IR9QH2zwGLkeStE7OZHBQgE2Sg559mGvvIaMbwtQ0IdDFCuwhxTM1HXDpfq3kO7zW bUFyQKGqtaTZGqGncp5TetNkqdkX1HyrRbTjmRDaU2EhJaPcj6mEfWedE4FA44a4RA2c L84qldV6DyKmm6OlJeUYxzx3GSCcaExX16ZcAtaD+fCQEq7tbHQsyPKLce2q1CAEVijC +uPbnOW4ZTjCDPzvT6fvvlBCyzMOme4xxPbHKA+RnT4TGhwUWNndcwAo1vWviLh+1+dx Chkw== 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: ALKqPwcgVvWVOsUWDqONdWa4zW1RJduKwsDBttYC7SZD36ZQUVGKCzin qAV0zCio5sccuS67ekszP3r1dwHQnHlnniV1Tz301PHb4ZHffcNY0leAFAXvPAYB3OeO9nKBTKX 6PsqyUVXcCewKSoGwPLTzWa6jUJ7GDUM+bkszDxJ1Peo7Wr9I3bSPbWTUCnrSz+ypbQ== X-Received: by 2002:a50:9fab:: with SMTP id c40-v6mr24995088edf.277.1528138962584; Mon, 04 Jun 2018 12:02:42 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL0KZpyxt2+M/TbwDFjmJHKMY6Q3q/GN44bg/YLSkvexGK+vopXab/G07Qn7rl2G3RMro6U X-Received: by 2002:a50:9fab:: with SMTP id c40-v6mr24995034edf.277.1528138961532; Mon, 04 Jun 2018 12:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528138961; cv=none; d=google.com; s=arc-20160816; b=sQPyn5TH08woIFhNLli195UAUDBdduWQ+cxIskksfrJqq4rCkih0jrCursm0fYgLe1 L+LClMpy/cVB49+oPOGtPEDvfaLnDo4teNBVKnVnmVLH50lAKE0hsRDkyTnsxyLywYUP HdxnQUt6MQFQ840KM9gxYSHiEbKCPDeWoar5tLu8r/Bz63G01VpE0a9OVbxlF3FXK8Yd 3RsYU93E01LAzhR575ylto0wQPsnN6DL2A3aJLOhDzKm57iZ7tmYsHCIovJAmrS6Sd0s 5bYcdC46VjDEpzlUFaCK/OYGrC6/bjAuuJKxWS2q/kdezTYi3hH8OWkLtFL3q0+zvR6p oz3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-disposition :message-id:user-agent:in-reply-to:references:reply-to:subject:cc:to :from:date:arc-authentication-results; bh=RpsTiyxDQ/h5wVhrKjIdsndVmLViRtPE+cK/R5isi9E=; b=f8d/jIyAfu6V6zmbvsO5SbmvhmMECfkI9Mgwayqxq5r0rZweIsEbawcArFRnccXKGE +VHsjX4e9Wc0oTxYypC4Xz8cmjN2f7bKz03Mo3WGdxamoxDKXSXEjYJ7FbG8hipzoEAT UBW/1z87GsciCrnI0hIRNPEOGBG5JZrIuY/8Xhtgx6aMgfGmRGSYFi7iCYzKxORbVEy9 0QmuPlGOwW3gZeedjqA5LpCjnQegtZnujkO5x61r6G37aHAQAxxUoZ8c+RXMry9CZLgg 5Ia01aJPj0wK2Bli7MNWMLo/yoyVKRbf45O3fXvTxKAPGviO+G/MAYIWGZxn3JOMiMtM 80GA== 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 g61-v6si1399806ede.420.2018.06.04.12.02.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 12:02:41 -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 (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w54Iwkjf065104 for ; Mon, 4 Jun 2018 15:02:39 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jd9c7cpmt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 04 Jun 2018 15:02:39 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Jun 2018 20:02:37 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 4 Jun 2018 20:02:34 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w54J2YKq27459672 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 4 Jun 2018 19:02:34 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8C94A404D; Mon, 4 Jun 2018 19:53:37 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9786A4040; Mon, 4 Jun 2018 19:53:36 +0100 (BST) Received: from ram.oc3035372033.ibm.com (unknown [9.85.153.100]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 4 Jun 2018 19:53:36 +0100 (BST) Date: Mon, 4 Jun 2018 12:02:29 -0700 From: Ram Pai To: Florian Weimer Cc: Andy Lutomirski , Linux-MM , linuxppc-dev , Dave Hansen Subject: Re: pkeys on POWER: Access rights not reset on execve Reply-To: Ram Pai References: <20180519202747.GK5479@ram.oc3035372033.ibm.com> <20180520060425.GL5479@ram.oc3035372033.ibm.com> <20180520191115.GM5479@ram.oc3035372033.ibm.com> <20180603201832.GA10109@ram.oc3035372033.ibm.com> <4e53b91f-80a7-816a-3e9b-56d7be7cd092@redhat.com> <20180604140135.GA10088@ram.oc3035372033.ibm.com> In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-TM-AS-GCONF: 00 x-cbid: 18060419-0020-0000-0000-000002970DC1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18060419-0021-0000-0000-000020E30ECE Message-Id: <20180604190229.GB10088@ram.oc3035372033.ibm.com> Content-Disposition: inline MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-06-04_13:, , 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-1806040219 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 On Mon, Jun 04, 2018 at 07:57:46PM +0200, Florian Weimer wrote: > On 06/04/2018 04:01 PM, Ram Pai wrote: > >On Mon, Jun 04, 2018 at 12:12:07PM +0200, Florian Weimer wrote: > >>On 06/03/2018 10:18 PM, Ram Pai wrote: > >>>On Mon, May 21, 2018 at 01:29:11PM +0200, Florian Weimer wrote: > >>>>On 05/20/2018 09:11 PM, Ram Pai wrote: > >>>>>Florian, > >>>>> > >>>>> Does the following patch fix the problem for you? Just like x86 > >>>>> I am enabling all keys in the UAMOR register during > >>>>> initialization itself. Hence any key created by any thread at > >>>>> any time, will get activated on all threads. So any thread > >>>>> can change the permission on that key. Smoke tested it > >>>>> with your test program. > >>>> > >>>>I think this goes in the right direction, but the AMR value after > >>>>fork is still strange: > >>>> > >>>>AMR (PID 34912): 0x0000000000000000 > >>>>AMR after fork (PID 34913): 0x0000000000000000 > >>>>AMR (PID 34913): 0x0000000000000000 > >>>>Allocated key in subprocess (PID 34913): 2 > >>>>Allocated key (PID 34912): 2 > >>>>Setting AMR: 0xffffffffffffffff > >>>>New AMR value (PID 34912): 0x0fffffffffffffff > >>>>About to call execl (PID 34912) ... > >>>>AMR (PID 34912): 0x0fffffffffffffff > >>>>AMR after fork (PID 34914): 0x0000000000000003 > >>>>AMR (PID 34914): 0x0000000000000003 > >>>>Allocated key in subprocess (PID 34914): 2 > >>>>Allocated key (PID 34912): 2 > >>>>Setting AMR: 0xffffffffffffffff > >>>>New AMR value (PID 34912): 0x0fffffffffffffff > >>>> > >>>>I mean this line: > >>>> > >>>>AMR after fork (PID 34914): 0x0000000000000003 > >>>> > >>>>Shouldn't it be the same as in the parent process? > >>> > >>>Fixed it. Please try this patch. If it all works to your satisfaction, I > >>>will clean it up further and send to Michael Ellermen(ppc maintainer). > >>> > >>> > >>>commit 51f4208ed5baeab1edb9b0f8b68d7144449b3527 > >>>Author: Ram Pai > >>>Date: Sun Jun 3 14:44:32 2018 -0500 > >>> > >>> Fix for the fork bug. > >>> Signed-off-by: Ram Pai > >> > >>Is this on top of the previous patch, or a separate fix? > > > >top of previous patch. > > Thanks. With this patch, I get this on an LPAR: > > AMR (PID 1876): 0x0000000000000003 > AMR after fork (PID 1877): 0x0000000000000003 > AMR (PID 1877): 0x0000000000000003 > Allocated key in subprocess (PID 1877): 2 > Allocated key (PID 1876): 2 > Setting AMR: 0xffffffffffffffff > New AMR value (PID 1876): 0x0fffffffffffffff > About to call execl (PID 1876) ... > AMR (PID 1876): 0x0000000000000003 > AMR after fork (PID 1878): 0x0000000000000003 > AMR (PID 1878): 0x0000000000000003 > Allocated key in subprocess (PID 1878): 2 > Allocated key (PID 1876): 2 > Setting AMR: 0xffffffffffffffff > New AMR value (PID 1876): 0x0fffffffffffffff > > Test program is still this one: > > > > So the process starts out with a different AMR value for some > reason. That could be a pre-existing bug that was just hidden by the > reset-to-zero on fork, or it could be intentional. But the kernel yes it is a bug, a patch for which is lined up for submission.. The fix is commit eaf5b2ac002ad2f5bca118d7ce075ce28311aa8e Author: Ram Pai Date: Mon Jun 4 10:58:44 2018 -0500 powerpc/pkeys: fix total pkeys calculation Total number of pkeys calculation is off by 1. Fix it. Signed-off-by: Ram Pai diff --git a/arch/powerpc/mm/pkeys.c b/arch/powerpc/mm/pkeys.c index 4530cdf..3384c4e 100644 --- a/arch/powerpc/mm/pkeys.c +++ b/arch/powerpc/mm/pkeys.c @@ -93,7 +93,7 @@ int pkey_initialize(void) * arch-neutral code. */ pkeys_total = min_t(int, pkeys_total, - (ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT)); + ((ARCH_VM_PKEY_FLAGS >> VM_PKEY_SHIFT)+1)); if (!pkey_mmu_enabled() || radix_enabled() || !pkeys_total) static_branch_enable(&pkey_disabled);