blob: 76c91a60130f9f91c31420fb430465f58edd7dd4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# $OpenBSD: Makefile,v 1.1.1.1 2019/08/01 15:20:51 bluhm Exp $
# Call unveil(2) in combination with unlink(2) and chroot(2).
# Use umount(8) to check that the mountpoint leaks no vnode.
# There were vnode reference counting bugs in the kernel.
PROGS= unveil-unlink unveil-chroot unveil-perm
CLEANFILES= diskimage
.PHONY: mount unconfig clean
diskimage: unconfig
${SUDO} dd if=/dev/zero of=diskimage bs=512 count=4k
${SUDO} vnconfig vnd0 diskimage
${SUDO} newfs vnd0c
mount: diskimage
@echo '\n======== $@ ========'
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} mount /dev/vnd0c /mnt/regress-unveil
unconfig:
@echo '\n======== $@ ========'
-${SUDO} umount -f /dev/vnd0c 2>/dev/null || true
-${SUDO} rmdir /mnt/regress-unveil 2>/dev/null || true
-${SUDO} vnconfig -u vnd0 2>/dev/null || true
-${SUDO} rm -f stamp-setup
REGRESS_SETUP = ${PROGS} mount
REGRESS_CLEANUP = unconfig
REGRESS_TARGETS =
REGRESS_TARGETS += run-unlink
run-unlink:
@echo '\n======== $@ ========'
# unlink a file in an unveiled directory
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} ./unveil-unlink /mnt/regress-unveil/foo bar
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot
run-chroot:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} ./unveil-chroot /mnt/regress-unveil /
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-dir
run-chroot-dir:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} ./unveil-chroot /mnt/regress-unveil/foo /
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-unveil-dir
run-chroot-unveil-dir:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} ./unveil-chroot /mnt/regress-unveil /foo
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-dir-unveil-dir
run-chroot-dir-unveil-dir:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo/bar
${SUDO} ./unveil-chroot /mnt/regress-unveil/foo /bar
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-open
run-chroot-open:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} touch /mnt/regress-unveil/baz
${SUDO} ./unveil-chroot /mnt/regress-unveil / /baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-dir-open
run-chroot-dir-open:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} touch /mnt/regress-unveil/foo/baz
${SUDO} ./unveil-chroot /mnt/regress-unveil/foo / /baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-unveil-dir-open
run-chroot-unveil-dir-open:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} touch /mnt/regress-unveil/foo/baz
${SUDO} ./unveil-chroot /mnt/regress-unveil /foo /baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-chroot-dir-unveil-dir-open
run-chroot-dir-unveil-dir-open:
@echo '\n======== $@ ========'
# unveil in a chroot environment
${SUDO} mkdir -p /mnt/regress-unveil/foo/bar
${SUDO} touch /mnt/regress-unveil/foo/bar/baz
${SUDO} ./unveil-chroot /mnt/regress-unveil/foo /bar /baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm
run-perm:
@echo '\n======== $@ ========'
# unveil in a perm environment
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} ./unveil-perm "" /mnt/regress-unveil
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-dir
run-perm-dir:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} ./unveil-perm "" /mnt/regress-unveil/foo
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-open
run-perm-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} touch /mnt/regress-unveil/baz
${SUDO} ./unveil-perm "" /mnt/regress-unveil baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-dir-open
run-perm-dir-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} touch /mnt/regress-unveil/foo/baz
${SUDO} ./unveil-perm "" /mnt/regress-unveil/foo baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-create-open
run-perm-create-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} touch /mnt/regress-unveil/baz
${SUDO} ./unveil-perm "c" /mnt/regress-unveil baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-dir-create-open
run-perm-dir-create-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} touch /mnt/regress-unveil/foo/baz
${SUDO} ./unveil-perm "c" /mnt/regress-unveil/foo baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-write-open
run-perm-write-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil
${SUDO} touch /mnt/regress-unveil/baz
${SUDO} ./unveil-perm "w" /mnt/regress-unveil baz
${SUDO} umount /mnt/regress-unveil
REGRESS_TARGETS += run-perm-dir-write-open
run-perm-dir-write-open:
@echo '\n======== $@ ========'
# unveil with permission
${SUDO} mkdir -p /mnt/regress-unveil/foo
${SUDO} touch /mnt/regress-unveil/foo/baz
${SUDO} ./unveil-perm "w" /mnt/regress-unveil/foo baz
${SUDO} umount /mnt/regress-unveil
REGRESS_ROOT_TARGETS = ${REGRESS_TARGETS}
.include <bsd.regress.mk>
|