Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 1479562 in mainline


Ignore:
Timestamp:
2010-11-15T23:02:23Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
74c57908
Parents:
dd567c6
Message:

Let copy_from/to_uspace() detect attempts to access the address space memory
hole on amd64.

Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/mm/as.h

    rdd567c6 r1479562  
    3636#define KERN_amd64_AS_H_
    3737
     38#define ADDRESS_SPACE_HOLE_START        0x0000800000000000ULL
     39#define ADDRESS_SPACE_HOLE_END          0xffff7fffffffffffULL
     40
    3841#define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH  0
    3942
    40 #define KERNEL_ADDRESS_SPACE_START_ARCH  (unsigned long) 0xffff800000000000
    41 #define KERNEL_ADDRESS_SPACE_END_ARCH    (unsigned long) 0xffffffffffffffff
     43#define KERNEL_ADDRESS_SPACE_START_ARCH 0xffff800000000000ULL
     44#define KERNEL_ADDRESS_SPACE_END_ARCH   0xffffffffffffffffULL
    4245
    43 #define USER_ADDRESS_SPACE_START_ARCH    (unsigned long) 0x0000000000000000
    44 #define USER_ADDRESS_SPACE_END_ARCH      (unsigned long) 0x00007fffffffffff
     46#define USER_ADDRESS_SPACE_START_ARCH   0x0000000000000000ULL
     47#define USER_ADDRESS_SPACE_END_ARCH     0x00007fffffffffffULL
    4548
    4649#define USTACK_ADDRESS_ARCH  (USER_ADDRESS_SPACE_END_ARCH - (PAGE_SIZE - 1))
  • kernel/generic/src/syscall/copy.c

    rdd567c6 r1479562  
    6868        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    6969                if (overlaps((uintptr_t) uspace_src, size,
    70                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     70                        KERNEL_ADDRESS_SPACE_START,
     71                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    7172                        /*
    7273                         * The userspace source block conflicts with kernel address space.
     
    7576                }
    7677        }
     78
     79#ifdef ADDRESS_SPACE_HOLE_START
     80        /*
     81         * Check whether the address is outside the address space hole.
     82         */
     83        if (overlaps((uintptr_t) uspace_src, size, ADDRESS_SPACE_HOLE_START,
     84            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     85                return EPERM;
     86#endif
    7787       
    7888        ipl = interrupts_disable();
     
    109119        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    110120                if (overlaps((uintptr_t) uspace_dst, size,
    111                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     121                        KERNEL_ADDRESS_SPACE_START,
     122                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    112123                        /*
    113124                         * The userspace destination block conflicts with kernel address space.
     
    116127                }
    117128        }
     129
     130#ifdef ADDRESS_SPACE_HOLE_START
     131        /*
     132         * Check whether the address is outside the address space hole.
     133         */
     134        if (overlaps((uintptr_t) uspace_dst, size, ADDRESS_SPACE_HOLE_START,
     135            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     136                return EPERM;
     137#endif
    118138       
    119139        ipl = interrupts_disable();
Note: See TracChangeset for help on using the changeset viewer.