Improved safety for user memory accesses.
* Changed IS_USER_ADDRESS to check an address using USER_BASE and USER_SIZE, rather than just !IS_KERNEL_ADDRESS. The old check would allow user buffers to point into the physical memory map area. * Added an unmapped hole at the end of the bottom half of the address space which catches buffers that cross into the uncanonical address region. This also removes the need to check for uncanonical return addresses in the syscall handler, it is no longer possible for the return address to be uncanonical under normal circumstances. All cases in which the return address might be changed by the kernel are still handled via the IRET path.
This commit is contained in:
@@ -31,7 +31,14 @@
|
||||
#endif
|
||||
|
||||
// Buffers passed in from user-space shouldn't point into the kernel.
|
||||
#define IS_USER_ADDRESS(x) (!IS_KERNEL_ADDRESS(x))
|
||||
#if USER_BASE == 0
|
||||
# define IS_USER_ADDRESS(x) ((addr_t)(x) <= USER_TOP)
|
||||
#elif USER_TOP == __HAIKU_ADDR_MAX
|
||||
# define IS_USER_ADDRESS(x) ((addr_t)(x) >= USER_BASE)
|
||||
#else
|
||||
# define IS_USER_ADDRESS(x) \
|
||||
((addr_t)(x) >= USER_BASE && (addr_t)(x) <= USER_TOP)
|
||||
#endif
|
||||
|
||||
#define DEBUG_KERNEL_STACKS
|
||||
// Note, debugging kernel stacks doesn't really work yet. Since the
|
||||
|
||||
Reference in New Issue
Block a user