Strengthen the pledge() polyfill

This commit is contained in:
Justine Tunney 2022-06-27 13:01:58 -07:00
parent a6f65eea7c
commit 3c92adfd6e
79 changed files with 1457 additions and 357 deletions

View file

@ -32,6 +32,11 @@ STATIC_YOINK("apetest2.com");
char testlib_enable_tmp_setup_teardown_once;
__attribute__((__constructor__)) static void init(void) {
// TODO(jart): What's up with RHEL5 / RHEL7?
// pledge("stdio rpath wpath cpath tty proc exec", 0);
}
void Extract(const char *from, const char *to, int mode) {
ASSERT_SYS(0, 3, open(from, O_RDONLY));
ASSERT_SYS(0, 4, creat(to, mode));

View file

@ -21,6 +21,10 @@
#include "libc/dce.h"
#include "libc/testlib/testlib.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath", 0);
}
TEST(arch_prctl, fs) {
if (IsLinux() || IsOpenbsd()) {
uint64_t n, x;

View file

@ -42,6 +42,10 @@ char *stack, *tls;
int x, me, tid, *childetid;
_Atomic(int) thechilde;
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath thread", 0);
}
void SetUp(void) {
x = 0;
me = gettid();

View file

@ -29,6 +29,10 @@
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath proc", 0);
}
TEST(fork, testPipes) {
int a, b;
int ws, pid;

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/intrin/kprintf.h"
#include "libc/limits.h"
@ -30,6 +31,10 @@
#define I(x, y) \
{ x, y, 0, (y - x) * FRAMESIZE + FRAMESIZE }
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath", 0);
}
static bool AreMemoryIntervalsEqual(const struct MemoryIntervals *mm1,
const struct MemoryIntervals *mm2) {
if (mm1->i != mm2->i) return false;

View file

@ -48,6 +48,10 @@
char testlib_enable_tmp_setup_teardown;
__attribute__((__constructor__)) static void init(void) {
pledge("stdio rpath wpath cpath proc", 0);
}
TEST(mmap, zeroSize) {
ASSERT_SYS(EINVAL, MAP_FAILED,
mmap(NULL, 0, PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));