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 / omc / om2 / s5 / scrub-mem.om

62 lines · 1111 bytes Raw Blame History
1note S5 scrub: a callee leaves an 8-byte pattern (64 copies) in its dead frame; `scrub 4096` zeroes the
2note 4096 bytes below SP; the whole stack pool 0x10000000 .. 0x10800000 is then read through /proc/self/mem
3note and searched for the pattern. Exit 0: not found; 10: found; 2x: read failure. Negative control: scrub-ctl.om.
4om2
5global buf uchar 1048576
6text mem "/proc/self/mem"
7fn fill to ulong
8a = new ulong 64 0
9for i ulong 64
10put a i 9833440827789222417
11end
12s = ulong 0
13for i ulong 64
14s = add s get a i
15end
16ret s
17end
18fn main to int
19s = fill
20k = scrub 4096
21if ne k 0
22ret 30
23end
24fd = int fopen mem 0 len mem 0 0
25if lt fd 0
26ret 20
27end
28hits = ulong 0
29for c ulong 8
30pos = long add 268435456 mul c 1048576
31r = pread fd buf 0 1048576 pos
32if ne r 1048576
33ret 21
34end
35i = ulong 0
36while lt i 1048576
37if eq get buf i 17
38if eq get buf add i 1 34
39if eq get buf add i 2 51
40if eq get buf add i 3 68
41if eq get buf add i 4 85
42if eq get buf add i 5 102
43if eq get buf add i 6 119
44if eq get buf add i 7 136
45hits = add hits 1
46end
47end
48end
49end
50end
51end
52end
53end
54i = add i 8
55end
56end
57r = fclose fd
58if gt hits 0
59ret 10
60end
61ret 0
62end