public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* A question about PROT_NONE on ARM and ARM26
@ 2004-06-30  2:44 Jamie Lokier
  2004-06-30  3:38 ` William Lee Irwin III
  2004-06-30  8:16 ` A question about PROT_NONE on ARM and ARM26 Russell King
  0 siblings, 2 replies; 34+ messages in thread
From: Jamie Lokier @ 2004-06-30  2:44 UTC (permalink / raw)
  To: Ian Molton, Russell King, linux-arm-kernel; +Cc: linux-kernel

Hi folks,

I'm doing a survey of the different architectural implementations of
PROT_* flags for mmap() and mprotect().  I'm looking at linux-2.6.5.

The ARM and ARM26 implementations are very similar to plain x86: read
implies exec, exec implies read and write implies read.

But I see a potential bug with PROT_NONE.  I'm not sure if it's real,
so could you please confirm?

In include/asm-arm26/pgtable.h, I see this (reindented for mail):

#define PAGE_NONE \
       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY | _PAGE_NOT_USER)
#define PAGE_READONLY \
       __pgprot(_PAGE_PRESENT | _PAGE_CLEAN | _PAGE_READONLY                 )

In include/asm-arm/pgtable.h, I see this (reindented for mail):

#define _L_PTE_DEFAULT \
        L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_CACHEABLE | L_PTE_BUFFERABLE
#define _L_PTE_READ \
        L_PTE_USER | L_PTE_EXEC
#define PAGE_NONE \
        __pgprot(_L_PTE_DEFAULT)
#define PAGE_READONLY
        __pgprot(_L_PTE_DEFAULT | _L_PTE_READ)

Apparently the difference between PAGE_NONE and PAGE_READONLY, in each
case, is that PAGE_NONE is not readable from userspace but _is_
readable from kernel space.

Therefore all user accesses to a PROT_NONE page will cause a fault.

My question is: if the _kernel_ reads a PROT_NONE page, will it fault?
It looks likely to me.

This means that calling write() with a PROT_NONE region would succeed,
wouldn't it?

If so, this is a bug.  A minor bug, perhaps, but nonetheless I wish to
document it.

I don't know if you would be able to rearrange the pte bits so that a
PROT_NONE page is not accessible to the kernel either.  E.g. on i386
this is done by making PROT_NONE not set the hardware's present bit
but a different bit, and "pte_present()" tests both of those bits to
test the virtual present bit.

Thanks,
-- Jamie

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

end of thread, other threads:[~2004-07-02 18:39 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-30  2:44 A question about PROT_NONE on ARM and ARM26 Jamie Lokier
2004-06-30  3:38 ` William Lee Irwin III
2004-07-01  3:26   ` Testing PROT_NONE and other protections, and a surprise Jamie Lokier
2004-07-01  3:35     ` William Lee Irwin III
2004-07-01  4:01       ` Jamie Lokier
2004-07-01  3:44     ` Kyle Moffett
2004-07-01  4:11       ` Jamie Lokier
2004-07-01  4:59         ` Kyle Moffett
2004-07-01 12:39           ` Jamie Lokier
2004-07-01 14:43             ` [OT] " Kyle Moffett
2004-07-01 14:50               ` Jamie Lokier
2004-07-01 15:01                 ` Kyle Moffett
2004-07-01 16:37                   ` Matt Mackall
2004-07-01 17:26               ` Michael Driscoll
2004-07-02  7:37               ` Gabriel Paubert
2004-07-01 12:52     ` Russell King
2004-07-01 14:26     ` Richard Curnow
2004-06-30  8:16 ` A question about PROT_NONE on ARM and ARM26 Russell King
2004-06-30 14:59   ` Jamie Lokier
2004-06-30 15:22     ` Ian Molton
2004-06-30 18:26     ` Russell King
2004-06-30 19:14       ` Jamie Lokier
2004-06-30 19:23         ` Russell King
2004-06-30 20:15           ` Jamie Lokier
2004-06-30 22:59             ` Russell King
2004-06-30 23:30               ` Jamie Lokier
2004-06-30 23:48                 ` Ian Molton
2004-07-01  1:59                   ` Jamie Lokier
2004-07-01  1:05                 ` Nicolas Pitre
2004-07-01  1:50                   ` Jamie Lokier
2004-07-02 18:39                 ` Russell King
2004-07-01 15:27               ` Scott Wood
2004-07-01 23:53                 ` Jamie Lokier
2004-07-02 14:36                   ` Scott Wood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox