mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 15:28:30 +00:00
Implement more security stuff
- Support deterministic stacks on OpenBSD - Support OpenBSD system call origin verification - Fix overrun by one in chibicc string token allocator - Get all chibicc tests passing under Address Sanitizer
This commit is contained in:
parent
cbfd4ccd1e
commit
c843243322
56 changed files with 376 additions and 245 deletions
|
@ -21,7 +21,7 @@
|
|||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/nr.h"
|
||||
#include "libc/macros.h"
|
||||
.real
|
||||
.text.syscall
|
||||
.source __FILE__
|
||||
|
||||
/ Terminates program abnormally.
|
||||
|
|
|
@ -95,7 +95,7 @@ static int arch_prctl$freebsd(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
|
||||
static int arch_prctl$xnu(int code, int64_t addr) {
|
||||
static textsyscall int arch_prctl$xnu(int code, int64_t addr) {
|
||||
int ax;
|
||||
switch (code) {
|
||||
case ARCH_SET_GS:
|
||||
|
@ -113,7 +113,7 @@ static int arch_prctl$xnu(int code, int64_t addr) {
|
|||
}
|
||||
}
|
||||
|
||||
static int arch_prctl$openbsd(int code, int64_t addr) {
|
||||
static textsyscall int arch_prctl$openbsd(int code, int64_t addr) {
|
||||
int64_t rax;
|
||||
switch (code) {
|
||||
case ARCH_GET_FS:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/macros.h"
|
||||
.privileged
|
||||
.text.syscall
|
||||
.source __FILE__
|
||||
|
||||
/ Terminates process, ignoring destructors and atexit() handlers.
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#define WasImported(SLOT) \
|
||||
((void *)*SLOT && *SLOT != (void *)&missingno /* see libc/crt/crt.S */)
|
||||
|
||||
static privileged void __print$nt(const void *data, size_t len) {
|
||||
static void __print$nt(const void *data, size_t len) {
|
||||
int64_t hand;
|
||||
char xmm[256];
|
||||
uint32_t wrote;
|
||||
|
@ -49,7 +49,7 @@ static privileged void __print$nt(const void *data, size_t len) {
|
|||
* @param len can be computed w/ tinystrlen()
|
||||
* @clob nothing except flags
|
||||
*/
|
||||
privileged void __print(const void *data, size_t len) {
|
||||
textsyscall void __print(const void *data, size_t len) {
|
||||
int64_t ax, ordinal;
|
||||
if (WasImported(__imp_WriteFile)) {
|
||||
__print$nt(data, len);
|
||||
|
@ -68,7 +68,7 @@ privileged void __print(const void *data, size_t len) {
|
|||
}
|
||||
}
|
||||
|
||||
privileged void __print_string(const char *s) {
|
||||
void __print_string(const char *s) {
|
||||
size_t n = 0;
|
||||
while (s[n]) ++n;
|
||||
__print(s, n);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
/**
|
||||
* Aborts program under enemy fire to avoid being taken alive.
|
||||
*/
|
||||
void __stack_chk_fail(void) {
|
||||
textsyscall void __stack_chk_fail(void) {
|
||||
size_t len;
|
||||
const char *msg;
|
||||
int64_t ax, cx, si;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue