cosmopolitan/tool/build
Justine Tunney 98254a7c1f 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-19 21:33:49 -07:00
..
emubin Improve synchronization 2022-04-15 15:31:55 -07:00
emucrt Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
lib Get redbean -X running in blinkenlights again 2022-07-16 11:52:45 -07:00
ar.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
assimilate.c Improve upon the new pledge command 2022-07-14 04:39:45 -07:00
bigmul.c Add SNI support to redbean and improve SSL perf 2021-07-23 13:56:13 -07:00
blinkenlights.c Improve redbean 2022-04-25 08:30:14 -07:00
build.mk Add assimilate.com command for APE binaries 2022-07-13 20:56:24 -07:00
calculator.c Strengthen the pledge() polyfill 2022-06-27 13:02:17 -07:00
calculator.ctest Add cpu / mem / fsz limits to build system 2021-08-13 23:40:53 -07:00
calculator.inc Add SSL to redbean 2021-06-24 13:20:50 -07:00
cocmd.c Add pipelining to cocmd 2022-07-15 20:47:20 -07:00
compile.c Improve upon the new pledge command 2022-07-14 04:39:45 -07:00
cp.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
deltaify.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
dis.c Restart CI for New Technology and UBSAN hunting 2022-03-21 04:32:57 -07:00
dropcache.c Change license 2020-12-27 17:18:44 -08:00
echo.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
gzip.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
helpop.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
lz4toasm.c Restart CI for New Technology and UBSAN hunting 2022-03-21 04:32:57 -07:00
mkdeps.c Make some minor fixups to bug reporting, etc. 2022-07-11 05:58:24 -07:00
mkdir.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
package.c Make more fixes and improvements 2022-04-21 09:18:45 -07:00
pledge.c Make pledge() and unveil() work amazingly 2022-07-19 21:33:49 -07:00
pstrace.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
pwd.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
refactor.c Remove garbage collector macro from header (#114) 2021-03-07 20:23:29 -08:00
rle.c Make improvements 2022-04-28 09:57:07 -07:00
rm.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
rollup.c Improve synchronization 2022-04-15 15:31:55 -07:00
runit.c Make more fixes and improvements 2022-06-13 11:02:13 -07:00
runit.h Fix bugs and add security features to redbean 2022-04-18 00:01:26 -07:00
runitd.c Make more fixes and improvements 2022-06-13 11:02:13 -07:00
strace.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
summy.c Fix build and delete superfluous files 2021-08-09 06:57:14 -07:00
symtab.c Add support for symbol table in .com files 2022-03-23 06:34:46 -07:00
tinyemu.c Fix our remarkable 184kb x86_64 emulator 2021-01-27 20:02:23 -08:00
touch.c Make build hermetic without shell scripts 2022-05-25 13:55:57 -07:00
unbundle.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
unveil.c Make unveil() improvements (#493) 2022-07-18 08:26:40 -07:00
x86combos.c Remove more nonstandard stuff from cosmopolitan.h 2021-03-01 00:18:23 -08:00
xlat.c Update experiment with tty audio 2022-07-15 23:07:32 -07:00
zipobj.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00