Commit a0dafc99 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: make vsyscall page into process page tables

From: Bodo Stroesser

To make the vsyscall-page available for copy_from_user() and
ptrace(), we should use kernel's "gate-vma" mechanism.
Therefore we need a valid page structure. To have this, one
page (or more) is allocated at boot time, the contents of the
vsyscall-page is copied into this page and the page's pte is
inserted in swapper's pagetables.
Now it will be copied into the pagetables of all processes.

Note: this alone doesn't work, since FIXADDR_USER_START and
      FIXADDR_USER_END are not yet defined correctly. Also
      access_ok_skas() does not yet grant read accesses to
      pages not in the normal user area.

Risks:
Please check the first hunk! I don't know, whether this change is OK.
Maybe fixrange_init() is wrong anyway with 3-level-pagetables?

Here access_ok_skas() and FIXADDR_USER_XXXX are fixed.
Now everything should work fine, while the processes are
running. But if a process crashes, the vsyscall-page will
not be dumped.
Signed-off-by: default avatarBodo Stroesser <bodo.stroesser@fujitsu-siemens.com>
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 22f0b7f9
......@@ -173,6 +173,29 @@ static void init_highmem(void)
}
#endif /* CONFIG_HIGHMEM */
static void __init fixaddr_user_init( void)
{
long size = FIXADDR_USER_END - FIXADDR_USER_START;
pgd_t *pgd;
pmd_t *pmd;
pte_t *pte;
unsigned long paddr, vaddr = FIXADDR_USER_START;
if ( ! size )
return;
fixrange_init( FIXADDR_USER_START, FIXADDR_USER_END, swapper_pg_dir);
paddr = (unsigned long)alloc_bootmem_low_pages( size);
memcpy( (void *)paddr, (void *)FIXADDR_USER_START, size);
paddr = __pa(paddr);
for ( ; size > 0; size-=PAGE_SIZE, vaddr+=PAGE_SIZE, paddr+=PAGE_SIZE) {
pgd = swapper_pg_dir + pgd_index(vaddr);
pmd = pmd_offset(pgd, vaddr);
pte = pte_offset_kernel(pmd, vaddr);
pte_set_val( (*pte), paddr, PAGE_READONLY);
}
}
void paging_init(void)
{
unsigned long zones_size[MAX_NR_ZONES], vaddr;
......@@ -193,6 +216,8 @@ void paging_init(void)
vaddr = __fix_to_virt(__end_of_fixed_addresses - 1) & PMD_MASK;
fixrange_init(vaddr, FIXADDR_TOP, swapper_pg_dir);
fixaddr_user_init();
#ifdef CONFIG_HIGHMEM
init_highmem();
#endif
......
......@@ -7,11 +7,16 @@
#define __SKAS_UACCESS_H
#include "asm/errno.h"
#include "asm/fixmap.h"
#define access_ok_skas(type, addr, size) \
((segment_eq(get_fs(), KERNEL_DS)) || \
(((unsigned long) (addr) < TASK_SIZE) && \
((unsigned long) (addr) + (size) <= TASK_SIZE)))
((unsigned long) (addr) + (size) <= TASK_SIZE)) || \
((type == VERIFY_READ ) && \
(size <= (FIXADDR_USER_END - FIXADDR_USER_START)) && \
((unsigned long) (addr) >= FIXADDR_USER_START) && \
((unsigned long) (addr) + (size) <= FIXADDR_USER_END)))
static inline int verify_area_skas(int type, const void * addr,
unsigned long size)
......
......@@ -3,6 +3,7 @@
#include <linux/config.h>
#include <asm/kmap_types.h>
#include <asm/archparam.h>
/*
* Here we define all the compile-time 'special' virtual
......@@ -34,7 +35,6 @@ enum fixed_addresses {
FIX_KMAP_BEGIN, /* reserved pte's for temporary kernel mappings */
FIX_KMAP_END = FIX_KMAP_BEGIN+(KM_TYPE_NR*NR_CPUS)-1,
#endif
FIX_VSYSCALL,
__end_of_fixed_addresses
};
......@@ -68,8 +68,8 @@ extern unsigned long get_kmem_end(void);
* This is the range that is readable by user mode, and things
* acting like user mode such as get_user_pages.
*/
#define FIXADDR_USER_START (__fix_to_virt(FIX_VSYSCALL))
#define FIXADDR_USER_END (FIXADDR_USER_START + PAGE_SIZE)
#define FIXADDR_USER_START VSYSCALL_BASE
#define FIXADDR_USER_END VSYSCALL_END
extern void __this_fixmap_does_not_exist(void);
......
......@@ -357,6 +357,8 @@ extern unsigned long page_to_phys(struct page *page);
extern pte_t mk_pte(struct page *page, pgprot_t pgprot);
#define pte_set_val(p, phys, prot) pte_val(p) = (phys | pgprot_val(prot))
static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
{
pte_val(pte) = (pte_val(pte) & _PAGE_CHG_MASK) | pgprot_val(newprot);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment