From 5cdd3eb0114736a071b9430abe59ba76df339099 Mon Sep 17 00:00:00 2001 From: beck Date: Fri, 27 Jul 2018 01:38:02 +0000 Subject: [PATCH] Make the BYPASSUNVEIL test actually test BYPASSUNVEIL with tmppath --- regress/sys/kern/unveil/syscalls.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c index 1c859de2f1c..e3a5518ef1a 100644 --- a/regress/sys/kern/unveil/syscalls.c +++ b/regress/sys/kern/unveil/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.11 2018/07/20 10:47:37 robert Exp $ */ +/* $OpenBSD: syscalls.c,v 1.12 2018/07/27 01:38:02 beck Exp $ */ /* * Copyright (c) 2017-2018 Bob Beck @@ -705,6 +705,11 @@ test_exec(int do_uv) printf("testing execve with \"x\"\n"); if (unveil("/usr/bin/true", "x") == -1) err(1, "%s:%d - unveil", __FILE__, __LINE__); + /* dynamic linking requires this */ + if (unveil("/usr/lib", "r") == -1) + err(1, "%s:%d - unveil", __FILE__, __LINE__); + if (unveil("/usr/libexec/ld.so", "r") == -1) + err(1, "%s:%d - unveil", __FILE__, __LINE__); } UV_SHOULD_SUCCEED((pledge("unveil stdio fattr exec", NULL) == -1), "pledge"); UV_SHOULD_SUCCEED((execve(argv[0], argv, environ) == -1), "execve"); @@ -720,6 +725,11 @@ test_exec2(int do_uv) printf("testing execve with \"rw\"\n"); if (unveil("/usr/bin/true", "rw") == -1) err(1, "%s:%d - unveil", __FILE__, __LINE__); + /* dynamic linking requires this */ + if (unveil("/usr/lib", "r") == -1) + err(1, "%s:%d - unveil", __FILE__, __LINE__); + if (unveil("/usr/libexec/ld.so", "r") == -1) + err(1, "%s:%d - unveil", __FILE__, __LINE__); } UV_SHOULD_SUCCEED((pledge("unveil stdio fattr exec", NULL) == -1), "pledge"); UV_SHOULD_EACCES((execve(argv[0], argv, environ) == -1), "execve"); @@ -746,9 +756,10 @@ test_bypassunveil(int do_uv) printf("testing BYPASSUNVEIL\n"); do_unveil2(); } + char filename3[] = "/tmp/nukeme.XXXXXX"; - UV_SHOULD_SUCCEED((pledge("rpath stdio tmppath", NULL) == -1), "pledge"); - UV_SHOULD_SUCCEED((chdir(uv_dir2) == -1), "chdir"); + UV_SHOULD_SUCCEED((pledge("stdio tmppath", NULL) == -1), "pledge"); + UV_SHOULD_SUCCEED((mkstemp(filename3) == -1), "mkstemp"); return 0; } -- 2.20.1