Re: A question about PROT_NONE on PPC and PPC64

From: Paul Mackerras
Date: Tue Jun 29 2004 - 23:51:05 EST


Jamie Lokier writes:

> PPC32
> =====
>
> In include/asm-ppc/pgtable.h, there's:
>
> #define PAGE_NONE __pgprot(_PAGE_BASE)
> #define PAGE_READONLY __pgprot(_PAGE_BASE | _PAGE_USER)
>
> It appears the only difference betwen PROT_READ and PROT_NONE is
> whether _PAGE_USER is set.
>
> Thus PROT_NONE pages aren't readable from userspace, but it appears
> they _are_ readable from kernel space. Is this correct?

No. Kernel accesses to pages in the user portion of the address space
(0 .. TASK_SIZE-1) are done using the user permissions. On classic
PPC this is implemented (in part) by setting Ks = Kp = 1 in the
segment descriptors for the user segments, which tells the hardware to
check the access as if it was a user access even in supervisor mode.

We do the same on ppc64 as well.

> So does this mean that PROT_NONE pages, although they aren't readable
> from userspace, are readable from kernel space? I.e. that write()
> with a PROT_NONE region would succeed, instead of returning EFAULT as
> it should?

If you do find a ppc32 or ppc64 machine where the write succeeds
instead of returning EFAULT, let me know please.

Paul.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/