interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / qualification / security673 / exec-parent.om

176 lines · 2871 bytes Raw Blame History
1note Disposable integration parent. No private input, network, devices, or external service.
2note Modes0 success,1 missing executable,2 isolate high-descriptor leak,3 unavailable-kernel mutant.
3note Parent retains its own descriptor table; this is not a sandbox or resource-fencing test.
4text secret "synthetic-secret"
5text public "public-input"
6text answer "public-output"
7text name "synthetic-secret.data"
8text child "./exec-child"
9text absent "./no-such-executable"
10global packet uchar 4096
11global bytes uchar 64
12global fds uchar 8
13global status uchar 4
14global mode uchar 1
15fn fdword off ulong to int
16x = ulong 0
17for i ulong 4
18x = or x shl ulong get fds add off i mul i 8
19end
20ret int x
21end
22fn addpath missing bool to ulong
23put packet 0 1
24if missing
25put packet 2 uchar len absent
26for i ulong len absent
27put packet add i 4 get absent i
28end
29ret add 4 len absent
30end
31put packet 2 uchar len child
32for i ulong len child
33put packet add i 4 get child i
34end
35ret add 4 len child
36end
37fn childrun rd int wr int missing bool to int
38if ne dupfd rd 0 0 0
39ret 51
40end
41if ne dupfd wr 1 0 1
42ret 52
43end
44if eq get mode 0 2
45if ne fclose 3 0
46ret 57
47end
48end
49n = addpath missing
50r = execprog packet 0 n
51if eq get mode 0 3
52if ne r neg long 38
53ret 58
54end
55ret 0
56end
57if not missing
58ret 53
59end
60if ne r neg long 2
61ret 54
62end
63if ne read 3 bytes 0 1 neg long 9
64ret 55
65end
66if ne read 65537 bytes 0 1 neg long 9
67ret 56
68end
69ret 0
70end
71fn parent pid long inputfd int outputfd int fd int missing bool to int
72if ne fclose inputfd 0
73ret 61
74end
75if ne fclose outputfd 0
76ret 62
77end
78if ne waitpid int pid status 0 len status 0 pid
79ret 63
80end
81if ne get status 0 0
82ret 64
83end
84if ne get status 1 0
85ret int get status 1
86end
87if ne fseek fd 0 0 0
88ret 65
89end
90if ne read fd bytes 0 len secret long len secret
91ret 66
92end
93for i ulong len secret
94if ne get bytes i get secret i
95ret 67
96end
97end
98ret 0
99end
100fn main to int
101if ne read 0 mode 0 1 1
102ret 90
103end
104if gt get mode 0 3
105ret 90
106end
107missing = eq get mode 0 1
108fd = fopen name 0 len name 194 384
109if lt fd 0
110ret 1
111end
112if ne fd 3
113ret 2
114end
115if ne write int fd secret 0 len secret long len secret
116ret 3
117end
118if ne fseek int fd 0 0 0
119ret 4
120end
121if ne dupfd int fd 65537 0 65537
122ret 5
123end
124if ne pipefds fds 0 len fds 0 0
125ret 6
126end
127rd = fdword 0
128wr = fdword 4
129if ne write wr public 0 len public long len public
130ret 7
131end
132if ne fclose wr 0
133ret 8
134end
135if ne pipefds fds 0 len fds 0 0
136ret 9
137end
138outread = fdword 0
139outwrite = fdword 4
140pid = fork
141if lt pid 0
142ret 10
143end
144if eq pid 0
145ret childrun rd outwrite missing
146end
147rc = parent pid rd outwrite int fd missing
148if ne rc 0
149ret rc
150end
151n = read outread bytes 0 len bytes
152if or missing eq get mode 0 3
153if ne n 0
154ret 70
155end
156else
157if ne n long len answer
158ret 71
159end
160for i ulong len answer
161if ne get bytes i get answer i
162ret 72
163end
164end
165end
166if ne fclose outread 0
167ret 73
168end
169if ne fclose 65537 0
170ret 74
171end
172if ne fclose int fd 0
173ret 75
174end
175ret 0
176end