Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1699100

Re: [RFC v6 27/62] powerpc: helper to validate key-access permissions of a pte

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
Newsgroups linux.kernel
Subject Re: [RFC v6 27/62] powerpc: helper to validate key-access permissions of a pte
Date Fri, 28 Jul 2017 23:10:02 +0200
Message-ID <u8kGe-C9-9@gated-at.bofh.it> (permalink)
References <u3ISR-1St-3@gated-at.bofh.it> <u3J2y-2aY-25@gated-at.bofh.it>
X-Original-To Ram Pai <linuxram@us.ibm.com>
MIME-Version 1.0
Content-Type text/plain
X-Tm-As-Mml disable
X-Cbid 17072821-0028-0000-0000-000001CCB3EE
X-Ibm-Av-Detection SAVI=unused REMOTE=unused XFE=unused
X-Cbparentid 17072821-0029-0000-0000-000014CF1B41
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2017-07-28_10:,, signatures=0
X-Proofpoint-Spam-Details rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1707280337
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 41
Organization linux.* mail to news gateway
X-Original-Cc linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, arnd@arndb.de, corbet@lwn.net, mhocko@kernel.org, dave.hansen@intel.com, mingo@redhat.com, paulus@samba.org, aneesh.kumar@linux.vnet.ibm.com, akpm@linux-foundation.org, khandual@linux.vnet.ibm.com
X-Original-Date Fri, 28 Jul 2017 18:00:02 -0300
X-Original-Message-ID <87tw1we0q5.fsf@linux.vnet.ibm.com>
X-Original-References <1500177424-13695-1-git-send-email-linuxram@us.ibm.com> <1500177424-13695-28-git-send-email-linuxram@us.ibm.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1699100

Show key headers only | View raw


Ram Pai <linuxram@us.ibm.com> writes:
> --- a/arch/powerpc/mm/pkeys.c
> +++ b/arch/powerpc/mm/pkeys.c
> @@ -201,3 +201,36 @@ int __arch_override_mprotect_pkey(struct vm_area_struct *vma, int prot,
>  	 */
>  	return vma_pkey(vma);
>  }
> +
> +static bool pkey_access_permitted(int pkey, bool write, bool execute)
> +{
> +	int pkey_shift;
> +	u64 amr;
> +
> +	if (!pkey)
> +		return true;
> +
> +	pkey_shift = pkeyshift(pkey);
> +	if (!(read_uamor() & (0x3UL << pkey_shift)))
> +		return true;
> +
> +	if (execute && !(read_iamr() & (IAMR_EX_BIT << pkey_shift)))
> +		return true;
> +
> +	if (!write) {
> +		amr = read_amr();
> +		if (!(amr & (AMR_RD_BIT << pkey_shift)))
> +			return true;
> +	}
> +
> +	amr = read_amr(); /* delay reading amr uptil absolutely needed */

Actually, this is causing amr to be read twice in case control enters
the "if (!write)" block above but doesn't enter the other if block nested
in it.

read_amr should be called only once, right before "if (!write)".

-- 
Thiago Jung Bauermann
IBM Linux Technology Center

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: [RFC v6 27/62] powerpc: helper to validate key-access permissions of a pte Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com> - 2017-07-28 23:10 +0200
  Re: [RFC v6 27/62] powerpc: helper to validate key-access  permissions of a pte Ram Pai <linuxram@us.ibm.com> - 2017-07-30 02:40 +0200

csiph-web