Message ID | 20180611200807.GA5773@ram.oc3035372033.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 06/11/2018 10:08 PM, Ram Pai wrote: > 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<linuxram@us.ibm.com> > Date: Mon Jun 11 14:57:34 2018 -0500 > > powerpc/pkeys: Deny read/write/execute by default With this patch, my existing misc/tst-pkey test in glibc passes. The in-tree version still has some incorrect assumptions on implementation behavior, but those are test bugs. The kernel behavior with your patch look good to me. Thanks. Florian
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));