]> git.baikalelectronics.ru Git - kernel.git/commit
s390/uaccess: fix page table walk
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Thu, 21 Mar 2013 11:50:39 +0000 (12:50 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 2 Apr 2013 06:53:08 +0000 (08:53 +0200)
commite38f968f6ced36c194fa0945ccff5f730dd1fedc
treee1978efab8d5b900ca5fe7d82ca0079c259cc8dc
parent7e046dea731deefd97fd2c10d5acf0e8b6347e92
s390/uaccess: fix page table walk

When translating user space addresses to kernel addresses the follow_table()
function had two bugs:

- PROT_NONE mappings could be read accessed via the kernel mapping. That is
  e.g. putting a filename into a user page, then protecting the page with
  PROT_NONE and afterwards issuing the "open" syscall with a pointer to
  the filename would incorrectly succeed.

- when walking the page tables it used the pgd/pud/pmd/pte primitives which
  with dynamic page tables give no indication which real level of page tables
  is being walked (region2, region3, segment or page table). So in case of an
  exception the translation exception code passed to __handle_fault() is not
  necessarily correct.
  This is not really an issue since __handle_fault() doesn't evaluate the code.
  Only in case of e.g. a SIGBUS this code gets passed to user space. If user
  space can do something sane with the value is a different question though.

To fix these issues don't use any Linux primitives. Only walk the page tables
like the hardware would do it, however we leave quite some checks away since
we know that we only have full size page tables and each index is within bounds.

In theory this should fix all issues...

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/pgtable.h
arch/s390/lib/uaccess_pt.c