cosmopolitan/tool/net
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
..
demo Fix GitHub Actions build 2022-07-18 20:45:18 -07:00
tiny Fix bugs with recent change 2022-04-16 10:40:23 -07:00
.init.lua Add SSL to redbean 2021-06-24 13:20:50 -07:00
counters.inc Make some systemic improvements 2022-05-18 16:52:36 -07:00
dig.c Restart CI for New Technology and UBSAN hunting 2022-03-21 04:32:57 -07:00
echo.c Reduce makefile dependencies by 10% 2022-06-08 20:01:28 -07:00
favicon.ico Make major improvements to redbean and libraries 2021-04-18 12:34:15 -07:00
help.txt Make pledge() and unveil() work amazingly 2022-07-19 21:33:49 -07:00
largon2.c Make improvements 2022-05-28 00:28:09 -07:00
lfinger.c Add tcp syn packet fingerprinting to redbean 2022-07-17 02:43:49 -07:00
lfinger.h Add tcp syn packet fingerprinting to redbean 2022-07-17 02:43:49 -07:00
lfuncs.c Improve Lua and JSON serialization 2022-07-12 23:35:11 -07:00
lfuncs.h Add Deflate() / Inflate() to redbean and fix bugs 2022-07-08 09:47:04 -07:00
ljson.c Add utf-8 validation to ljson 2022-07-15 06:20:07 -07:00
ljson.h Further improve JSON serialization 2022-07-11 23:06:49 -07:00
lmaxmind.c Import C++ Standard Template Library 2022-03-22 06:41:54 -07:00
lre.c Write more redbean unit tests 2022-07-08 23:10:02 -07:00
lsqlite3.c Add fileio and sqlar SQLite extensions to redbean 2022-06-17 06:04:09 -07:00
luacheck.h Fix reporting of Lua stack items from various hook calls (#395) 2022-04-27 21:57:52 -07:00
net.mk Add tcp syn packet fingerprinting to redbean 2022-07-17 02:43:49 -07:00
redbean.c Add redbean OnLogLatency hook (#495) 2022-07-18 20:17:14 -07:00
redbean.png Make improvements 2020-09-14 00:02:34 -07:00
sandbox.h Strengthen the pledge() polyfill 2022-06-27 13:02:17 -07:00
wb.c Use re-entrant locks on stdio 2022-05-22 08:28:33 -07:00