cosmopolitan/libc/intrin/kerrnonames.S

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

124 lines
3.2 KiB
ArmAsm
Raw Normal View History

2021-05-03 08:21:50 +00:00
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set noet ft=asm ts=8 sw=8 fenc=utf-8 :vi
Copyright 2021 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/fmt/magnumstrs.internal.h"
2021-05-03 08:21:50 +00:00
#include "libc/macros.internal.h"
.macro .e e
.long \e - kErrnoNames
.long .L\@ - kErrnoNames
.rodata.str1.1
.L\@: .string "\e"
2021-05-03 08:21:50 +00:00
.previous
.endm
.section .rodata
2023-05-02 02:43:59 +00:00
.balign 4
.underrun
kErrnoNames:
.e EINVAL
2021-05-03 08:21:50 +00:00
.e ENOSYS
.e EPERM
.e ENOENT
.e ESRCH
.e EINTR
.e EIO
.e ENXIO
.e E2BIG
.e ENOEXEC
.e EBADF
.e ECHILD
.e EAGAIN
.e ENOMEM
.e EACCES
.e EFAULT
.e ENOTBLK
.e EBUSY
.e EEXIST
.e EXDEV
.e ENODEV
.e ENOTDIR
.e EISDIR
.e ENFILE
.e EMFILE
.e ENOTTY
.e ETXTBSY
.e EFBIG
.e ENOSPC
.e EDQUOT
.e ESPIPE
.e EROFS
.e EMLINK
.e EPIPE
.e EDOM
.e ERANGE
.e EDEADLK
.e ENAMETOOLONG
.e ENOLCK
.e ENOTEMPTY
.e ELOOP
.e ENOMSG
.e EIDRM
.e EPROTO
.e EOVERFLOW
.e EILSEQ
.e EUSERS
.e ENOTSOCK
.e EDESTADDRREQ
.e EMSGSIZE
.e EPROTOTYPE
.e ENOPROTOOPT
.e EPROTONOSUPPORT
.e ESOCKTNOSUPPORT
.e ENOTSUP
.e EOPNOTSUPP
.e EPFNOSUPPORT
.e EAFNOSUPPORT
.e EADDRINUSE
.e EADDRNOTAVAIL
.e ENETDOWN
.e ENETUNREACH
.e ENETRESET
.e ECONNABORTED
.e ECONNRESET
.e ENOBUFS
.e EISCONN
.e ENOTCONN
.e ESHUTDOWN
.e ETOOMANYREFS
.e ETIMEDOUT
.e ETIME
2021-05-03 08:21:50 +00:00
.e ECONNREFUSED
.e EHOSTDOWN
.e EHOSTUNREACH
.e EALREADY
.e EINPROGRESS
.e ESTALE
.e EREMOTE
.e EBADMSG
.e ECANCELED
.e EOWNERDEAD
.e ENOTRECOVERABLE
.e ENONET
.e ERESTART
.e ENODATA
Make pledge() and unveil() work amazingly This change reconciles our pledge() implementation with the OpenBSD kernel source code. We now a polyfill that's much closer to OpenBSD's behavior. For example, it was discovered that "stdio" permits threads. There were a bunch of Linux system calls that needed to be added, like sched_yield(). The exec / execnative category division is now dropped. We're instead using OpenBSD's "prot_exec" promise for launching APE binaries and dynamic shared objects. We also now filter clone() flags. The pledge.com command has been greatly improved. It now does unveiling by default when Landlock is available. It's now smart enough to unveil a superset of paths that OpenBSD automatically unveils with pledge(), such as /etc/localtime. pledge.com also now checks if the executable being launched is a dynamic shared object, in which case it unveils libraries. These changes now make it possible to pledge curl on ubuntu 20.04 glibc: pledge.com -p 'stdio rpath prot_exec inet dns tty sendfd recvfd' \ curl -s https://justine.lol/hello.txt Here's what pledging curl on Alpine 3.16 with Musl Libc looks like: pledge.com -p 'stdio rpath prot_exec dns inet' \ curl -s https://justine.lol/hello.txt Here's what pledging curl.com w/ ape loader looks like: pledge.com -p 'stdio rpath prot_exec dns inet' \ o//examples/curl.com https://justine.lol/hello.txt The most secure sandbox, is curl.com converted to static ELF: o//tool/build/assimilate.com o//examples/curl.com pledge.com -p 'stdio rpath dns inet' \ o//examples/curl.com https://justine.lol/hello.txt A weird corner case needed to be handled when resolving symbolic links during the unveiling process, that's arguably a Landlock bug. It's not surprising since Musl and Glibc are also inconsistent here too.
2022-07-20 04:18:33 +00:00
.e EBADFD
.long MAGNUM_TERMINATOR
.endobj kErrnoNames,globl,hidden
.overrun