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