From 3dd75325aba331f14e7a1144d97b573b5fb8ae58 Mon Sep 17 00:00:00 2001 From: Bob Beck Date: Sun, 28 Oct 2018 22:42:34 +0000 Subject: Correctly deal with upper level unveil's by keeping track of the covering unveil for each unveil in the process at unveil() time, and refactoring the handling of current directory and ISDOTDOT to be much more sensible. Worked out at ns2k18 with guenther@. ok deraadt@ --- regress/sys/kern/unveil/syscalls.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'regress') diff --git a/regress/sys/kern/unveil/syscalls.c b/regress/sys/kern/unveil/syscalls.c index 4284ddf63d3..4410526553b 100644 --- a/regress/sys/kern/unveil/syscalls.c +++ b/regress/sys/kern/unveil/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.17 2018/08/28 02:49:47 beck Exp $ */ +/* $OpenBSD: syscalls.c,v 1.18 2018/10/28 22:42:33 beck Exp $ */ /* * Copyright (c) 2017-2018 Bob Beck @@ -456,7 +456,7 @@ test_parent_dir(int do_uv) { char filename[255]; if (do_uv) { - printf("testing chdir\n"); + printf("testing parent dir\n"); do_unveil2(); } else { (void) snprintf(filename, sizeof(filename), "/%s/doof", uv_dir1); @@ -466,23 +466,31 @@ test_parent_dir(int do_uv) (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1", uv_dir1); UV_SHOULD_SUCCEED((mkdir(filename, 0777) == -1), "mkdir"); (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1/poop", uv_dir1); - UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT) == -1), "open"); + UV_SHOULD_SUCCEED((open(filename, O_RDWR|O_CREAT, 0644) == -1), "open"); (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1/link", uv_dir1); UV_SHOULD_SUCCEED((symlink("../subdir1/poop", filename) == -1), "symlink"); } sleep(1); - (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1/poop", uv_dir1); - UV_SHOULD_SUCCEED((access(filename, R_OK) == -1), "access"); (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1/link", uv_dir1); UV_SHOULD_SUCCEED((access(filename, R_OK) == -1), "access"); - return 0; + (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1/poop", uv_dir1); + UV_SHOULD_SUCCEED((access(filename, R_OK) == -1), "access"); UV_SHOULD_SUCCEED((chdir(uv_dir1) == -1), "chdir"); (void) snprintf(filename, sizeof(filename), "/%s/doof/subdir1", uv_dir1); UV_SHOULD_SUCCEED((chdir(filename) == -1), "chdir"); + UV_SHOULD_SUCCEED((access("poop", R_OK) == -1), "access"); UV_SHOULD_SUCCEED((chdir("../subdir2") == -1), "chdir"); UV_SHOULD_SUCCEED((chdir("../subdir1") == -1), "chdir"); - - return 0; + UV_SHOULD_SUCCEED((chdir(filename) == -1), "chdir"); + UV_SHOULD_SUCCEED((chdir("../../doof/subdir2") == -1), "chdir"); + UV_SHOULD_SUCCEED((chdir("../../doof/subdir1") == -1), "chdir"); + UV_SHOULD_SUCCEED((chdir("../../doof/subdir2") == -1), "chdir"); + UV_SHOULD_SUCCEED((chdir("../../doof/subdir1") == -1), "chdir"); + UV_SHOULD_SUCCEED((access("poop", R_OK) == -1), "access"); + UV_SHOULD_SUCCEED((access("../subdir1/poop", R_OK) == -1), "access"); + UV_SHOULD_EACCES((chdir("../../../") == -1), "chdir"); + UV_SHOULD_ENOENT((chdir(uv_dir2) == -1), "chdir"); + return(0); } static int -- cgit v1.2.3