All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] powerpc/cxl: Use REGION_ID instead of opencoding
@ 2016-04-20  7:59 Aneesh Kumar K.V
  2016-04-28 14:23 ` [V2] " Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Aneesh Kumar K.V @ 2016-04-20  7:59 UTC (permalink / raw)
  To: benh, paulus, mpe; +Cc: linuxppc-dev, Aneesh Kumar K.V, Frederic Barrat

Also the wrong `~` operation resulted in wrong access check as explained
below.

The current code will set _PAGE_USER to the access flags for any
fault address because ~ operation will be true for all address we take
a fault on. But setting _PAGE_USER also means that the fault will be
handled only if the page table have _PAGE_USER set. Hence there is
no security hole with the current code.

Now if it is an user space access, then the change in this patch really
don't have an impact because we have (!ctx->kernel) set true
and we take the if condition true.

Now kernel context created fault on an address in the kernel range
will result in a fault loop because we will not insert the
hash pte due to access and pte permission mismatch. This patch fix
the above issue.

fixes: f204e0b8cedd ("cxl: Driver code for powernv PCIe based cards for
userspace acces")

Cc: Frederic Barrat <fbarrat@linux.vnet.ibm.com>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
Changes from v1:
* v1 never reached mailing list

 drivers/misc/cxl/fault.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/misc/cxl/fault.c b/drivers/misc/cxl/fault.c
index 9a8650bcb042..9a236543da23 100644
--- a/drivers/misc/cxl/fault.c
+++ b/drivers/misc/cxl/fault.c
@@ -152,7 +152,7 @@ static void cxl_handle_page_fault(struct cxl_context *ctx,
 	access = _PAGE_PRESENT;
 	if (dsisr & CXL_PSL_DSISR_An_S)
 		access |= _PAGE_RW;
-	if ((!ctx->kernel) || ~(dar & (1ULL << 63)))
+	if ((!ctx->kernel) || (REGION_ID(dar) == USER_REGION_ID))
 		access |= _PAGE_USER;
 
 	if (dsisr & DSISR_NOHPTE)
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [V2] powerpc/cxl: Use REGION_ID instead of opencoding
  2016-04-20  7:59 [PATCH V2] powerpc/cxl: Use REGION_ID instead of opencoding Aneesh Kumar K.V
@ 2016-04-28 14:23 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-04-28 14:23 UTC (permalink / raw)
  To: Aneesh Kumar K.V, benh, paulus
  Cc: linuxppc-dev, Aneesh Kumar K.V, Frederic Barrat

On Wed, 2016-20-04 at 07:59:47 UTC, "Aneesh Kumar K.V" wrote:
> Also the wrong `~` operation resulted in wrong access check as explained
> below.
>
...
> Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
> Acked-by: Ian Munsie <imunsie@au1.ibm.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/3b1dbfa14f97188ec33fdfc7ac

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-28 14:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-20  7:59 [PATCH V2] powerpc/cxl: Use REGION_ID instead of opencoding Aneesh Kumar K.V
2016-04-28 14:23 ` [V2] " Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.