Re:Boringcc: Proposal for a C compiler for secure software
by qb45 on Monday December 21, 2015 @04:03PM
(#10773494)
Which x86 kernel maps something at 0? In Windows and Linux, the low part of virtual address space is reserved for userspace.
In fact, Linux had several privilege escalation bugs which involved putting something at 0 and executing a buggy syscall which loaded this thing due to NULL dereference and believed it's some legit internal kernel data.
Re:Boringcc: Proposal for a C compiler for secure software
by 0x0 on Monday December 21, 2015 @04:49PM
(#10773768)
Which was probably the reason why "mmap_min_addr" was added :) https://wiki.debian.org/mmap_min_addr
Re:Boringcc: Proposal for a C compiler for secure software
by jevinskie on Monday December 21, 2015 @07:19PM
(#10774649)
OS X and iOS map in __TEXT,__PAGEZERO to 0x0.* Of course, it is mapped without any protection levels so it isn't of much use except for catching most nullptr dereferences (just 4 GB of protection on x86_64!).
* Well, this is implemented by the default system toolchain. You'r particular toolchain can opt out of this behavior if they want to.
Re:Boringcc: Proposal for a C compiler for secure software
by makomk on Monday December 21, 2015 @05:48PM
(#10774136)
Mappings at zero are used by legacy code like 16-bit Windows applications, if I remember correctly.
Re:Boringcc: Proposal for a C compiler for secure software
by noselasd on Monday December 21, 2015 @05:00PM
(#10773854)
"perfectly fine" does not depend on the processor alone, it depends on the compiler. A compiler for x86 can assume dereferencing a NULL pointer is undefined behavior, and optimize your code in ways you perhaps didn't expect.
Or it could document and provide a well defined behavior of derefrencing a NULL pointer.
(e.g. gcc provides -fdelete-null-pointer-checks to control this)
It's also perfectly fine on x86, in kernel memory page 0 is often mapped, the OS is the one mapping page 0 so that userland dereferencing it faults.