Delete ASAN

It hasn't been helpful enough to be justify the maintenance burden. What
actually does help is mprotect(), kprintf(), --ftrace and --strace which
can always be counted upon to work correctly. We aren't losing much with
this change. Support for ASAN on AARCH64 was never implemented. Applying
ASAN to the core libc runtimes was disabled many months ago. If there is
some way to have an ASAN runtime for user programs that is less invasive
we can potentially consider reintroducing support. But now is premature.
This commit is contained in:
Justine Tunney 2024-06-22 05:45:49 -07:00
parent 6ffed14b9c
commit d1d4388201
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
198 changed files with 130 additions and 2954 deletions

View file

@ -1,27 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_CALLS_ASAN_INTERNAL_H_
#define COSMOPOLITAN_LIBC_CALLS_ASAN_INTERNAL_H_
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/asmflag.h"
COSMOPOLITAN_C_START_
forceinline bool __asan_is_valid_timespec(const struct timespec *ts) {
#ifdef __x86_64__
bool zf;
asm(ZFLAG_ASM("cmpw\t$0,0x7fff8000(%1)")
: ZFLAG_CONSTRAINT(zf)
: "r"((intptr_t)ts >> 3)
: "memory");
return zf;
#else
return __asan_is_valid(ts, sizeof(*ts));
#endif
}
forceinline bool __asan_is_valid_timeval(const struct timeval *tv) {
return __asan_is_valid_timespec((const struct timespec *)tv);
}
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_CALLS_ASAN_INTERNAL_H_ */

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/log/log.h"
@ -59,7 +58,7 @@ int chdir(const char *path) {
if (_weaken(GetProgramExecutableName)) {
_weaken(GetProgramExecutableName)();
}
if (!path || (IsAsan() && !__asan_is_valid_str(path))) {
if (!path) {
rc = efault();
} else if (_weaken(__zipos_parseuri) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
@ -49,7 +48,7 @@
*/
int chroot(const char *path) {
int rc;
if (!path || (IsAsan() && !__asan_is_valid_str(path))) {
if (!path) {
rc = efault();
} else {
rc = sys_chroot(path);

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/asan.internal.h"
#include "libc/calls/struct/timespec.internal.h"
#include "libc/dce.h"
#include "libc/intrin/describeflags.internal.h"
@ -63,7 +62,7 @@ static int sys_clock_getres_xnu(int clock, struct timespec *ts) {
*/
int clock_getres(int clock, struct timespec *ts) {
int rc;
if (!ts || (IsAsan() && !__asan_is_valid_timespec(ts))) {
if (!ts) {
rc = efault();
} else if (clock == 127) {
rc = einval(); // 127 is used by consts.sh to mean unsupported

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/asan.internal.h"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timespec.internal.h"
#include "libc/calls/struct/timeval.h"
@ -35,7 +34,7 @@ int clock_settime(int clockid, const struct timespec *ts) {
struct timeval tv;
if (clockid == 127) {
rc = einval(); // 127 is used by consts.sh to mean unsupported
} else if (!ts || (IsAsan() && !__asan_is_valid_timespec(ts))) {
} else if (!ts) {
rc = efault();
} else if (IsXnu()) {
if (clockid == CLOCK_REALTIME) {

View file

@ -27,7 +27,6 @@
#include "libc/cosmo.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/sig.h"
@ -109,11 +108,6 @@ ssize_t copy_file_range(int infd, int64_t *opt_in_out_inoffset, int outfd,
if (!g_copy_file_range.ok) {
rc = enosys();
} else if (IsAsan() && ((opt_in_out_inoffset &&
!__asan_is_valid(opt_in_out_inoffset, 8)) ||
(opt_in_out_outoffset &&
!__asan_is_valid(opt_in_out_outoffset, 8)))) {
rc = efault();
} else if (__isfdkind(outfd, kFdZip)) {
rc = ebadf();
} else if (__isfdkind(infd, kFdZip)) {

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -52,10 +51,8 @@
int faccessat(int dirfd, const char *path, int amode, int flags) {
int e, rc;
struct ZiposUri zipname;
if (IsAsan() && !__asan_is_valid_str(path)) {
rc = efault();
} else if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) ||
!(amode == F_OK || !(amode & ~(R_OK | W_OK | X_OK)))) {
if ((flags & ~(AT_SYMLINK_NOFOLLOW | AT_EACCESS)) ||
!(amode == F_OK || !(amode & ~(R_OK | W_OK | X_OK)))) {
rc = einval();
} else if (__isfdkind(dirfd, kFdZip)) {
rc = enotsup();

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -52,10 +51,7 @@ int sys_fchmodat2(int, const char *, unsigned, int);
*/
int fchmodat(int dirfd, const char *path, uint32_t mode, int flags) {
int rc;
if (IsAsan() && !__asan_is_valid_str(path)) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
(rc = __zipos_notat(dirfd, path)) == -1) {
if (_weaken(__zipos_notat) && (rc = __zipos_notat(dirfd, path)) == -1) {
rc = erofs();
} else if (!IsWindows()) {
if (IsLinux() && flags) {

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -43,10 +42,7 @@
int fchownat(int dirfd, const char *path, uint32_t uid, uint32_t gid,
int flags) {
int rc;
if (IsAsan() && !__asan_is_valid_str(path)) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
(rc = __zipos_notat(dirfd, path)) == -1) {
if (_weaken(__zipos_notat) && (rc = __zipos_notat(dirfd, path)) == -1) {
rc = erofs();
} else {
rc = sys_fchownat(dirfd, path, uid, gid, flags);

View file

@ -21,7 +21,6 @@
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/sysv/consts/f.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
@ -32,9 +31,7 @@ int sys_fcntl(int fd, int cmd, uintptr_t arg, int impl(int, int, ...)) {
if ((islock = cmd == F_GETLK || //
cmd == F_SETLK || //
cmd == F_SETLKW)) {
if ((!IsAsan() && !arg) ||
(IsAsan() &&
!__asan_is_valid((struct flock *)arg, sizeof(struct flock)))) {
if (!arg) {
return efault();
}
cosmo2flock(arg);

View file

@ -23,7 +23,6 @@
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/nt/files.h"
@ -51,11 +50,8 @@ bool32 fileexists(const char *path) {
struct ZiposUri zipname;
uint16_t path16[PATH_MAX];
e = errno;
if (IsAsan() && !__asan_is_valid_str(path)) {
efault();
res = false;
} else if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_stat)(&zipname, &st.cosmo) != -1) {
res = true;
} else {

View file

@ -20,7 +20,6 @@
#include "libc/calls/internal.h"
#include "libc/calls/struct/stat.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -42,9 +41,7 @@
*/
int fstat(int fd, struct stat *st) {
int rc;
if (IsAsan() && !__asan_is_valid(st, sizeof(*st))) {
rc = efault();
} else if (__isfdkind(fd, kFdZip)) {
if (__isfdkind(fd, kFdZip)) {
rc = _weaken(__zipos_fstat)(
(struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle, st);
} else if (IsLinux() || IsXnu() || IsFreebsd() || IsOpenbsd() || IsNetbsd()) {

View file

@ -23,7 +23,6 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -76,10 +75,7 @@ int fstatat(int dirfd, const char *path, struct stat *st, int flags) {
// execve() depends on this
int rc;
struct ZiposUri zipname;
if (IsAsan() && (!__asan_is_valid_str(path) || //
!__asan_is_valid(st, sizeof(*st)))) {
rc = efault();
} else if (flags & ~AT_SYMLINK_NOFOLLOW) {
if (flags & ~AT_SYMLINK_NOFOLLOW) {
return einval();
} else if (__isfdkind(dirfd, kFdZip)) {
STRACE("zipos dirfd not supported yet");

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/asan.internal.h"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timespec.internal.h"
#include "libc/calls/struct/timeval.h"

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h"
#include "libc/calls/groups.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/stdckdint.h"
@ -34,11 +33,7 @@
*/
int getgroups(int size, uint32_t list[]) {
int rc;
size_t n;
if (IsAsan() &&
(ckd_mul(&n, size, sizeof(list[0])) || !__asan_is_valid(list, n))) {
rc = efault();
} else if (IsLinux() || IsNetbsd() || IsOpenbsd() || IsFreebsd() || IsXnu()) {
if (IsLinux() || IsNetbsd() || IsOpenbsd() || IsFreebsd() || IsXnu()) {
rc = sys_getgroups(size, list);
} else {
rc = enosys();

View file

@ -29,7 +29,6 @@
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/asmflag.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -182,7 +181,7 @@ ssize_t __getrandom(void *p, size_t n, unsigned f) {
*/
ssize_t getrandom(void *p, size_t n, unsigned f) {
ssize_t rc;
if ((!p && n) || (IsAsan() && !__asan_is_valid(p, n))) {
if ((!p && n)) {
rc = efault();
} else if (f & ~(GRND_RANDOM | GRND_NONBLOCK)) {
rc = einval();

View file

@ -20,7 +20,6 @@
#include "libc/calls/struct/rlimit.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/runtime/runtime.h"
@ -41,7 +40,7 @@ int getrlimit(int resource, struct rlimit *rlim) {
int rc;
if (resource == 127) {
rc = einval();
} else if (!rlim || (IsAsan() && !__asan_is_valid(rlim, sizeof(*rlim)))) {
} else if (!rlim) {
rc = efault();
} else if (IsXnuSilicon()) {
rc = _sysret(__syslib->__getrlimit(resource, rlim));

View file

@ -23,7 +23,6 @@
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/nt/files.h"
@ -51,11 +50,8 @@ bool32 isdirectory(const char *path) {
union metastat st;
struct ZiposUri zipname;
e = errno;
if (IsAsan() && !__asan_is_valid_str(path)) {
efault();
res = false;
} else if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_stat)(&zipname, &st.cosmo) != -1) {
res = S_ISDIR(st.cosmo.st_mode);
} else {

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/zipos.internal.h"
@ -48,11 +47,8 @@ bool32 isregularfile(const char *path) {
union metastat st;
struct ZiposUri zipname;
e = errno;
if (IsAsan() && !__asan_is_valid_str(path)) {
efault();
res = false;
} else if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_stat)(&zipname, &st.cosmo) != -1) {
res = !!S_ISREG(st.cosmo.st_mode);
} else {

View file

@ -23,7 +23,6 @@
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/nt/files.h"
@ -51,11 +50,8 @@ bool32 issymlink(const char *path) {
union metastat st;
struct ZiposUri zipname;
e = errno;
if (IsAsan() && !__asan_is_valid_str(path)) {
efault();
res = false;
} else if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
if (_weaken(__zipos_open) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {
res = false;
} else if (IsMetal()) {
res = false;

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -40,12 +39,9 @@
int linkat(int olddirfd, const char *oldpath, int newdirfd, const char *newpath,
int flags) {
int rc;
if (IsAsan() &&
(!__asan_is_valid_str(oldpath) || !__asan_is_valid_str(newpath))) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
((rc = __zipos_notat(olddirfd, oldpath)) == -1 ||
(rc = __zipos_notat(newdirfd, newpath)) == -1)) {
if (_weaken(__zipos_notat) &&
((rc = __zipos_notat(olddirfd, oldpath)) == -1 ||
(rc = __zipos_notat(newdirfd, newpath)) == -1)) {
STRACE("zipos fchownat not supported yet");
} else if (!IsWindows()) {
rc = sys_linkat(olddirfd, oldpath, newdirfd, newpath, flags);

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
@ -38,9 +37,7 @@
*/
int madvise(void *addr, size_t length, int advice) {
int rc;
if (IsAsan() && !__asan_is_valid(addr, length)) {
rc = enomem();
} else if (!IsWindows()) {
if (!IsWindows()) {
rc = sys_madvise(addr, length, advice);
} else {
rc = sys_madvise_nt(addr, length, advice);

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -53,10 +52,7 @@
*/
int mkdirat(int dirfd, const char *path, unsigned mode) {
int rc;
if (IsAsan() && !__asan_is_valid_str(path)) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
(rc = __zipos_notat(dirfd, path)) == -1) {
if (_weaken(__zipos_notat) && (rc = __zipos_notat(dirfd, path)) == -1) {
STRACE("zipos mkdirat not supported yet");
} else if (!IsWindows()) {
rc = sys_mkdirat(dirfd, path, mode);

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/at.h"
#include "libc/sysv/consts/s.h"
@ -42,8 +41,6 @@
*/
int mknod(const char *path, uint32_t mode, uint64_t dev) {
int e, rc;
if (IsAsan() && !__asan_is_valid_str(path))
return efault();
if (mode & S_IFREG)
return creat(path, mode & ~S_IFREG);
if (mode & S_IFDIR)

View file

@ -18,7 +18,6 @@
*/
#include "libc/calls/syscall_support-nt.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/strace.internal.h"
#include "libc/macros.internal.h"
@ -96,7 +95,7 @@ textwindows int __mkntpath2(const char *path,
// 4. Need ≥13 for mkdir() i.e. 1+8+3+1, e.g. "\\ffffffff.xxx\0"
// which is an "8.3 filename" from the DOS days
if (!path || (IsAsan() && !__asan_is_valid_str(path))) {
if (!path) {
return efault();
}

View file

@ -26,7 +26,6 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -180,7 +179,7 @@ int openat(int dirfd, const char *path, int flags, ...) {
va_end(va);
BEGIN_CANCELATION_POINT;
if (!path || (IsAsan() && !__asan_is_valid_str(path))) {
if (!path) {
rc = efault();
} else if ((flags & O_UNLINK) &&
(flags & (O_CREAT | O_EXCL)) != (O_CREAT | O_EXCL)) {

View file

@ -27,7 +27,6 @@
#include "libc/calls/termios.h"
#include "libc/calls/termios.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/log/rop.internal.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/at.h"
@ -94,13 +93,6 @@ int openpty(int *mfd, int *sfd, char *name, //
if (IsWindows() || IsMetal()) {
return enosys();
}
if (IsAsan() && (!__asan_is_valid(mfd, sizeof(int)) ||
!__asan_is_valid(sfd, sizeof(int)) ||
(name && !__asan_is_valid(name, 16)) ||
(tio && !__asan_is_valid(tio, sizeof(*tio))) ||
(wsz && !__asan_is_valid(wsz, sizeof(*wsz))))) {
return efault();
}
BLOCK_CANCELATION;
rc = openpty_impl(mfd, sfd, name, tio, wsz);
ALLOW_CANCELATION;

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
@ -36,7 +35,7 @@
*/
int pipe(int pipefd[hasatleast 2]) {
int rc;
if (!pipefd || (IsAsan() && !__asan_is_valid(pipefd, sizeof(int) * 2))) {
if (!pipefd) {
// needed for windows which is polyfilled
// needed for xnu and netbsd which don't take an argument
rc = efault();

View file

@ -19,7 +19,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/errfuns.h"
@ -44,8 +43,7 @@ int pipe2(int pipefd[hasatleast 2], int flags) {
int rc;
if (flags & ~(O_CLOEXEC | O_NONBLOCK | (O_DIRECT != -1u ? O_DIRECT : 0))) {
return einval();
} else if (!pipefd ||
(IsAsan() && !__asan_is_valid(pipefd, sizeof(int) * 2))) {
} else if (!pipefd) {
rc = efault();
} else if (!IsWindows()) {
rc = sys_pipe2(pipefd, flags);

View file

@ -18,7 +18,6 @@
*/
#include "libc/calls/cp.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sock/struct/pollfd.h"
#include "libc/sock/struct/pollfd.internal.h"
@ -65,13 +64,9 @@
*/
int poll(struct pollfd *fds, size_t nfds, int timeout_ms) {
int rc;
size_t n;
BEGIN_CANCELATION_POINT;
if (IsAsan() &&
(ckd_mul(&n, nfds, sizeof(struct pollfd)) || !__asan_is_valid(fds, n))) {
rc = efault();
} else if (!IsWindows()) {
if (!IsWindows()) {
if (!IsMetal()) {
rc = sys_poll(fds, nfds, timeout_ms);
} else {

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/timespec.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sock/struct/pollfd.h"
#include "libc/sock/struct/pollfd.internal.h"
@ -60,18 +59,12 @@
*/
int ppoll(struct pollfd *fds, size_t nfds, const struct timespec *timeout,
const sigset_t *sigmask) {
size_t n;
int e, rc;
sigset_t oldmask;
struct timespec ts, *tsp;
BEGIN_CANCELATION_POINT;
if (IsAsan() &&
(ckd_mul(&n, nfds, sizeof(struct pollfd)) || !__asan_is_valid(fds, n) ||
(timeout && !__asan_is_valid(timeout, sizeof(timeout))) ||
(sigmask && !__asan_is_valid(sigmask, sizeof(sigmask))))) {
rc = efault();
} else if (!IsWindows()) {
if (!IsWindows()) {
e = errno;
if (timeout) {
ts = *timeout;

View file

@ -24,7 +24,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/macros.internal.h"
@ -67,8 +66,6 @@ ssize_t pread(int fd, void *buf, size_t size, int64_t offset) {
rc = einval();
} else if (fd < 0) {
rc = ebadf();
} else if (IsAsan() && !__asan_is_valid(buf, size)) {
rc = efault();
} else if (__isfdkind(fd, kFdZip)) {
rc = _weaken(__zipos_read)(
(struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle,

View file

@ -24,7 +24,6 @@
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/likely.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -52,8 +51,6 @@ static ssize_t Preadv(int fd, struct iovec *iov, int iovlen, int64_t off) {
return ebadf();
if (iovlen < 0)
return einval();
if (IsAsan() && !__asan_is_valid_iov(iov, iovlen))
return efault();
// XNU and BSDs will EINVAL if requested bytes exceeds INT_MAX
// this is inconsistent with Linux which ignores huge requests

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/timespec.internal.h"
#include "libc/calls/struct/timeval.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sock/internal.h"
@ -77,13 +76,6 @@ int pselect(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
BEGIN_CANCELATION_POINT;
if (nfds < 0) {
rc = einval();
} else if (IsAsan() &&
((readfds && !__asan_is_valid(readfds, FD_SIZE(nfds))) ||
(writefds && !__asan_is_valid(writefds, FD_SIZE(nfds))) ||
(exceptfds && !__asan_is_valid(exceptfds, FD_SIZE(nfds))) ||
(timeout && !__asan_is_valid(timeout, sizeof(*timeout))) ||
(sigmask && !__asan_is_valid(sigmask, sizeof(*sigmask))))) {
rc = efault();
} else {
if (readfds) {
old_readfds = *readfds;

View file

@ -25,7 +25,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/macros.internal.h"
#include "libc/stdio/sysparam.h"
@ -62,8 +61,6 @@ ssize_t pwrite(int fd, const void *buf, size_t size, int64_t offset) {
rc = einval();
} else if (fd == -1) {
rc = ebadf();
} else if (IsAsan() && !__asan_is_valid(buf, size)) {
rc = efault();
} else if (__isfdkind(fd, kFdZip)) {
rc = ebadf();
} else if (!IsWindows()) {

View file

@ -24,7 +24,6 @@
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/likely.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -52,8 +51,6 @@ static ssize_t Pwritev(int fd, const struct iovec *iov, int iovlen,
return ebadf();
if (iovlen < 0)
return einval();
if (IsAsan() && !__asan_is_valid_iov(iov, iovlen))
return efault();
if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip)
return ebadf();

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/zipos.internal.h"
@ -74,7 +73,7 @@ ssize_t read(int fd, void *buf, size_t size) {
if (fd < 0) {
rc = ebadf();
} else if ((!buf && size) || (IsAsan() && !__asan_is_valid(buf, size))) {
} else if ((!buf && size)) {
rc = efault();
} else if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
rc = _weaken(__zipos_read)(

View file

@ -19,12 +19,12 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/zipos.internal.h"
#include "libc/stdio/sysparam.h"
#include "libc/sysv/errfuns.h"
/**
@ -52,8 +52,7 @@
*/
ssize_t readlinkat(int dirfd, const char *path, char *buf, size_t bufsiz) {
ssize_t bytes;
if ((bufsiz && !buf) || (IsAsan() && (!__asan_is_valid_str(path) ||
!__asan_is_valid(buf, bufsiz)))) {
if ((bufsiz && !buf)) {
bytes = efault();
} else if (_weaken(__zipos_notat) &&
(bytes = __zipos_notat(dirfd, path)) == -1) {

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/likely.h"
#include "libc/intrin/strace.internal.h"
@ -49,8 +48,6 @@ static ssize_t readv_impl(int fd, const struct iovec *iov, int iovlen) {
return ebadf();
if (iovlen < 0)
return einval();
if (IsAsan() && !__asan_is_valid_iov(iov, iovlen))
return efault();
// XNU and BSDs will EINVAL if requested bytes exceeds INT_MAX
// this is inconsistent with Linux which ignores huge requests

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -46,12 +45,9 @@
int renameat(int olddirfd, const char *oldpath, int newdirfd,
const char *newpath) {
int rc;
if (IsAsan() &&
(!__asan_is_valid_str(oldpath) || !__asan_is_valid_str(newpath))) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
((rc = __zipos_notat(olddirfd, oldpath)) == -1 ||
(rc = __zipos_notat(newdirfd, newpath)) == -1)) {
if (_weaken(__zipos_notat) &&
((rc = __zipos_notat(olddirfd, oldpath)) == -1 ||
(rc = __zipos_notat(newdirfd, newpath)) == -1)) {
STRACE("zipos renameat not supported yet");
} else if (!IsWindows()) {
rc = sys_renameat(olddirfd, oldpath, newdirfd, newpath);

View file

@ -20,7 +20,6 @@
#include "libc/calls/struct/sched_param.h"
#include "libc/calls/struct/sched_param.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
@ -33,7 +32,7 @@
int sched_getparam(int pid, struct sched_param *param) {
int rc;
struct sched_param p;
if (!param || (IsAsan() && !__asan_is_valid(param, sizeof(*param)))) {
if (!param) {
rc = efault();
} else if (IsNetbsd()) {
if (!(rc = sys_sched_getscheduler_netbsd(pid, &p))) {

View file

@ -20,7 +20,6 @@
#include "libc/calls/struct/sched_param.h"
#include "libc/calls/struct/sched_param.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/errfuns.h"
@ -34,7 +33,7 @@
int sched_setparam(int pid, const struct sched_param *param) {
int rc, policy;
struct sched_param p;
if (!param || (IsAsan() && !__asan_is_valid(param, sizeof(*param)))) {
if (!param) {
rc = efault();
} else if (IsNetbsd()) {
if ((rc = policy = sys_sched_getscheduler_netbsd(pid, &p)) != -1) {

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/timeval.h"
#include "libc/calls/struct/timeval.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sock/internal.h"
@ -63,12 +62,6 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
BEGIN_CANCELATION_POINT;
if (nfds < 0) {
rc = einval();
} else if (IsAsan() &&
((readfds && !__asan_is_valid(readfds, FD_SIZE(nfds))) ||
(writefds && !__asan_is_valid(writefds, FD_SIZE(nfds))) ||
(exceptfds && !__asan_is_valid(exceptfds, FD_SIZE(nfds))) ||
(timeout && !__asan_is_valid(timeout, sizeof(*timeout))))) {
rc = efault();
} else {
if (readfds) {
old_readfds = *readfds;

View file

@ -19,7 +19,6 @@
#include "libc/calls/calls.h"
#include "libc/calls/groups.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/stdckdint.h"
@ -40,11 +39,7 @@
*/
int setgroups(size_t size, const uint32_t list[]) {
int rc;
size_t n;
if (IsAsan() &&
(ckd_mul(&n, size, sizeof(list[0])) || !__asan_is_valid(list, n))) {
rc = efault();
} else if (IsLinux() || IsNetbsd() || IsOpenbsd() || IsFreebsd() || IsXnu()) {
if (IsLinux() || IsNetbsd() || IsOpenbsd() || IsFreebsd() || IsXnu()) {
rc = sys_setgroups(size, list);
} else {
rc = enosys();

View file

@ -21,7 +21,6 @@
#include "libc/calls/struct/rlimit.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/macros.internal.h"
@ -80,7 +79,7 @@ int setrlimit(int resource, const struct rlimit *rlim) {
int rc;
if (resource == 127) {
rc = einval();
} else if (!rlim || (IsAsan() && !__asan_is_valid(rlim, sizeof(*rlim)))) {
} else if (!rlim) {
rc = efault();
} else if (IsXnuSilicon()) {
rc = _sysret(__syslib->__setrlimit(resource, rlim));

View file

@ -16,7 +16,6 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/asan.internal.h"
#include "libc/calls/struct/timeval.h"
#include "libc/calls/struct/timeval.internal.h"
#include "libc/dce.h"
@ -29,7 +28,7 @@
*/
int settimeofday(const struct timeval *tv, const struct timezone *tz) {
int rc;
if (!tv || (IsAsan() && !__asan_is_valid_timeval(tv))) {
if (!tv) {
rc = efault();
} else {
rc = sys_settimeofday(tv, 0);

View file

@ -30,7 +30,6 @@
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/calls/ucontext.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/dll.h"
#include "libc/intrin/strace.internal.h"
@ -167,10 +166,6 @@ static int __sigaction(int sig, const struct sigaction *act,
return einval();
if (sig == SIGKILL || sig == SIGSTOP)
return einval();
if (IsAsan() && ((act && !__asan_is_valid(act, sizeof(*act))) ||
(oldact && !__asan_is_valid(oldact, sizeof(*oldact))))) {
return efault();
}
if (!act) {
rva = (int32_t)(intptr_t)SIG_DFL;
} else if ((intptr_t)act->sa_handler < kSigactionMinRva) {

View file

@ -21,9 +21,9 @@
#include "libc/calls/struct/sigaltstack.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/macros.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/syslib.internal.h"
#include "libc/sysv/consts/ss.h"
@ -129,11 +129,8 @@ static int sigaltstack_bsd(const struct sigaltstack *neu,
*/
int sigaltstack(const struct sigaltstack *neu, struct sigaltstack *old) {
int rc;
if (IsAsan() && ((old && !__asan_is_valid(old, sizeof(*old))) ||
(neu && !__asan_is_valid(neu, sizeof(*neu))))) {
rc = efault();
} else if (neu && ((neu->ss_size >> 32) || //
(neu->ss_flags & ~(SS_ONSTACK | SS_DISABLE)))) {
if (neu && ((neu->ss_size >> 32) || //
(neu->ss_flags & ~(SS_ONSTACK | SS_DISABLE)))) {
rc = einval();
} else if (neu && neu->ss_size < __get_minsigstksz()) {
rc = enomem();

View file

@ -20,7 +20,6 @@
#include "libc/calls/struct/sigset.h"
#include "libc/calls/struct/sigset.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
@ -38,7 +37,7 @@
*/
int sigpending(sigset_t *pending) {
int rc;
if (!pending || (IsAsan() && !__asan_is_valid(pending, sizeof(*pending)))) {
if (!pending) {
rc = efault();
} else if (IsLinux() || IsNetbsd() || IsOpenbsd() || IsFreebsd() || IsXnu()) {
// 128 signals on NetBSD and FreeBSD, 64 on Linux, 32 on OpenBSD and XNU

View file

@ -23,7 +23,6 @@
#include "libc/calls/struct/sigset.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/strace.internal.h"
#include "libc/nt/synchronization.h"
@ -48,9 +47,7 @@ int sigsuspend(const sigset_t *ignore) {
int rc;
BEGIN_CANCELATION_POINT;
if (IsAsan() && ignore && !__asan_is_valid(ignore, sizeof(*ignore))) {
rc = efault();
} else if (IsXnu() || IsOpenbsd()) {
if (IsXnu() || IsOpenbsd()) {
// openbsd and xnu use a 32 signal register convention
rc = sys_sigsuspend(ignore ? (void *)(intptr_t)(uint32_t)*ignore : 0, 8);
} else {

View file

@ -17,14 +17,12 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/sigtimedwait.h"
#include "libc/calls/asan.internal.h"
#include "libc/calls/cp.internal.h"
#include "libc/calls/sigtimedwait.internal.h"
#include "libc/calls/struct/siginfo.internal.h"
#include "libc/calls/struct/sigset.internal.h"
#include "libc/calls/struct/timespec.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/str/str.h"
#include "libc/sysv/errfuns.h"
@ -52,11 +50,7 @@ int sigtimedwait(const sigset_t *set, siginfo_t *info,
union siginfo_meta si = {0};
BEGIN_CANCELATION_POINT;
if (IsAsan() && (!__asan_is_valid(set, sizeof(*set)) ||
(info && !__asan_is_valid(info, sizeof(*info))) ||
(timeout && !__asan_is_valid_timespec(timeout)))) {
rc = efault();
} else if (IsLinux() || IsFreebsd() || IsNetbsd()) {
if (IsLinux() || IsFreebsd() || IsNetbsd()) {
if (timeout) {
// 1. Linux needs its size parameter
// 2. NetBSD modifies timeout argument

View file

@ -23,7 +23,6 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/mem/alloca.h"
@ -82,11 +81,6 @@ ssize_t splice(int infd, int64_t *opt_in_out_inoffset, int outfd,
cosmo_once(&g_splice.once, splice_init);
if (!g_splice.ok) {
rc = enosys();
} else if (IsAsan() && ((opt_in_out_inoffset &&
!__asan_is_valid(opt_in_out_inoffset, 8)) ||
(opt_in_out_outoffset &&
!__asan_is_valid(opt_in_out_outoffset, 8)))) {
rc = efault();
} else if (__isfdkind(infd, kFdZip) || __isfdkind(outfd, kFdZip)) {
rc = enotsup();
} else {

View file

@ -20,7 +20,6 @@
#include "libc/calls/syscall-nt.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/at.h"
@ -41,10 +40,6 @@
*/
int symlinkat(const char *target, int newdirfd, const char *linkpath) {
int rc;
if (IsAsan() &&
(!__asan_is_valid_str(target) || !__asan_is_valid_str(linkpath))) {
rc = efault();
}
if (!IsWindows()) {
rc = sys_symlinkat(target, newdirfd, linkpath);
} else {

View file

@ -22,7 +22,6 @@
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/macros.internal.h"
#include "libc/str/str.h"
@ -94,9 +93,7 @@ static int sys_sysinfo_bsd(struct sysinfo *info) {
int sysinfo(struct sysinfo *info) {
int rc;
struct sysinfo x = {0};
if (IsAsan() && info && !__asan_is_valid(info, sizeof(*info))) {
rc = efault();
} else if (!IsWindows()) {
if (!IsWindows()) {
if (IsLinux()) {
rc = sys_sysinfo(&x);
} else {

View file

@ -24,7 +24,6 @@
#include "libc/calls/termios.internal.h"
#include "libc/calls/ttydefaults.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/str/str.h"
#include "libc/sysv/errfuns.h"
@ -91,7 +90,7 @@ int tcgetattr(int fd, struct termios *tio) {
int rc;
if (fd < 0) {
rc = einval();
} else if (!tio || (IsAsan() && !__asan_is_valid(tio, sizeof(*tio)))) {
} else if (!tio) {
rc = efault();
} else if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
rc = enotty();

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/calls/termios.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/termios.h"
#include "libc/sysv/errfuns.h"
@ -32,9 +31,7 @@
*/
int tcgetwinsize(int fd, struct winsize *ws) {
int rc;
if (IsAsan() && !__asan_is_valid(ws, sizeof(*ws))) {
rc = efault();
} else if (fd >= 0) {
if (fd >= 0) {
if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
rc = enotty();
} else if (IsWindows()) {

View file

@ -24,7 +24,6 @@
#include "libc/calls/termios.internal.h"
#include "libc/dce.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/mem/alloca.h"
@ -62,10 +61,6 @@ static int tcsetattr_impl(int fd, int opt, const struct termios *tio) {
}
}
if (IsAsan() && !__asan_is_valid(tio, sizeof(*tio))) {
return efault();
}
if (IsMetal()) {
return 0;
}

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/calls/termios.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/sysv/consts/termios.h"
#include "libc/sysv/errfuns.h"
@ -34,9 +33,7 @@ int tcsetwinsize_nt(int, const struct winsize *);
*/
int tcsetwinsize(int fd, const struct winsize *ws) {
int rc;
if (IsAsan() && !__asan_is_valid(ws, sizeof(*ws))) {
rc = efault();
} else if (fd >= 0) {
if (fd >= 0) {
if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
rc = enotty();
} else if (!IsWindows()) {

View file

@ -19,7 +19,6 @@
#include "libc/time.h"
#include "libc/calls/struct/timeval.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/sysv/errfuns.h"
/**
@ -32,10 +31,7 @@
int64_t time(int64_t *opt_out_ret) {
int64_t secs;
struct timeval tv;
if (IsAsan() && opt_out_ret &&
!__asan_is_valid(opt_out_ret, sizeof(*opt_out_ret))) {
secs = efault();
} else if (gettimeofday(&tv, 0) != -1) {
if (gettimeofday(&tv, 0) != -1) {
secs = tv.tv_sec;
if (opt_out_ret) {
*opt_out_ret = secs;

View file

@ -19,7 +19,6 @@
#include "libc/calls/blockcancel.internal.h"
#include "libc/calls/calls.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/runtime/runtime.h"
#define ASAN_ERROR "error: tinyprint() passed invalid memory, or missing NULL\n"
@ -59,10 +58,6 @@ ssize_t tinyprint(int fd, const char *s, ...) {
BLOCK_CANCELATION;
va_start(va, s);
for (toto = n = 0; s; s = va_arg(va, const char *)) {
if (IsAsan() && !__asan_is_valid_str(s)) {
write(2, ASAN_ERROR, sizeof(ASAN_ERROR) - 1);
abort();
}
while ((c = *s++)) {
buf[n++] = c;
if (n == sizeof(buf)) {

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/zipos.internal.h"
@ -69,7 +68,7 @@ int truncate(const char *path, int64_t length) {
if (IsMetal()) {
rc = enosys();
} else if (!path || (IsAsan() && !__asan_is_valid_str(path))) {
} else if (!path) {
rc = efault();
} else if (_weaken(__zipos_parseuri) &&
_weaken(__zipos_parseuri)(path, &zipname) != -1) {

View file

@ -25,7 +25,6 @@
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/fmt/itoa.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
@ -136,7 +135,7 @@ static const char *Str(int rc, const char *s) {
*/
int uname(struct utsname *uts) {
int rc;
if (!uts || (IsAsan() && !__asan_is_valid(uts, sizeof(*uts)))) {
if (!uts) {
rc = efault();
} else if (IsLinux()) {
struct utsname_linux linux;

View file

@ -22,7 +22,6 @@
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -44,10 +43,7 @@
int unlinkat(int dirfd, const char *path, int flags) {
int rc;
if (IsAsan() && !__asan_is_valid_str(path)) {
rc = efault();
} else if (_weaken(__zipos_notat) &&
(rc = __zipos_notat(dirfd, path)) == -1) {
if (_weaken(__zipos_notat) && (rc = __zipos_notat(dirfd, path)) == -1) {
STRACE("zipos unlinkat not supported yet");
} else if (!IsWindows()) {
rc = sys_unlinkat(dirfd, path, flags);

View file

@ -17,14 +17,12 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/assert.h"
#include "libc/calls/asan.internal.h"
#include "libc/calls/calls.h"
#include "libc/calls/internal.h"
#include "libc/calls/struct/timespec.internal.h"
#include "libc/calls/struct/timeval.internal.h"
#include "libc/calls/syscall_support-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
@ -38,10 +36,6 @@ int __utimens(int fd, const char *path, const struct timespec ts[2],
struct ZiposUri zipname;
if (IsMetal()) {
rc = enosys();
} else if (IsAsan() && ((fd == AT_FDCWD && !__asan_is_valid_str(path)) ||
(ts && (!__asan_is_valid_timespec(ts + 0) ||
!__asan_is_valid_timespec(ts + 1))))) {
rc = efault(); // bad memory
} else if ((flags & ~AT_SYMLINK_NOFOLLOW)) {
rc = einval(); // unsupported flag
} else if (__isfdkind(fd, kFdZip) ||

View file

@ -22,7 +22,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/intrin/weaken.h"
#include "libc/runtime/zipos.internal.h"
@ -76,8 +75,6 @@ ssize_t write(int fd, const void *buf, size_t size) {
if (fd < 0) {
rc = ebadf();
} else if (IsAsan() && !__asan_is_valid(buf, size)) {
rc = efault();
} else if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip) {
rc = ebadf(); // posix specifies this when not open()'d for writing
} else if (IsLinux() || IsXnu() || IsFreebsd() || IsOpenbsd() || IsNetbsd()) {

View file

@ -22,7 +22,6 @@
#include "libc/calls/struct/iovec.internal.h"
#include "libc/calls/syscall-sysv.internal.h"
#include "libc/errno.h"
#include "libc/intrin/asan.internal.h"
#include "libc/intrin/describeflags.internal.h"
#include "libc/intrin/likely.h"
#include "libc/intrin/strace.internal.h"
@ -47,8 +46,6 @@ static ssize_t writev_impl(int fd, const struct iovec *iov, int iovlen) {
return ebadf();
if (iovlen < 0)
return einval();
if (IsAsan() && !__asan_is_valid_iov(iov, iovlen))
return efault();
if (fd < g_fds.n && g_fds.p[fd].kind == kFdZip)
return ebadf(); // posix specifies this when not open()'d for writing