1 [[!meta title="Erase memory: the memtest86+ way"]]
6 Memory erasure on shutdown is currently buggy. Sdmem and linux memtest
7 implementation are failing. But a program exist that is actually dedicated at
8 memory testing, and that has thus access to most (if tot all) available memory:
9 [memtest86+](http://www.memtest.org/). This is a research using a modified
10 memtest86+ to erase memory.
15 We started from memtest86+ version 4.20 available at
16 <http://www.memtest.org/download/4.20/memtest86+-4.20.tar.gz>.
18 Executing a single test
19 -----------------------
21 We patched memtest86+ to execute a single test, and then reboot. We choosed
22 test #1 "Address test, own address" but quicker one could probably be choosen.
24 The corresponding patchset:
26 [0001-Do-only-one-test-and-hopefully-reboot.patch](https://labs.riseup.net/code/attachments/312/0001-Do-only-one-test-and-hopefully-reboot.patch)
31 We patched memtest86+ to only display "Memory wipe, please wait..." with a
32 progress bar, and then report success.
34 The corresponding patchset:
36 - [0002-Only-write-a-nice-title.patch](https://labs.riseup.net/code/attachments/314/0002-Only-write-a-nice-title.patch)
37 - [0003-Remove-most-colors.patch](https://labs.riseup.net/code/attachments/315/0003-Remove-most-colors.patch)
38 - [0004-Actually-writes-the-progress-bar-and-move-it-up.patch](https://labs.riseup.net/code/attachments/320/0004-Actually-writes-the-progress-bar-and-move-it-up.patch)
39 - [0005-Display-message-at-the-end.patch](https://labs.riseup.net/code/attachments/322/0005-Display-message-at-the-end.patch)
43 <img src="https://labs.riseup.net/code/attachments/323/memwipe.png">
45 Unfortunately, this is useless as when kexec launches memtest from Tails, the
46 video mode in not native and nothing is displayed.
51 - Actually halt the machine
52 - Choose or write a quicker test
53 - Disable keyboard shortcuts
56 Integreating into Tails
57 =======================
59 We patched tails experimental to kexec on our modified memtest86+ instead of on
60 linux on shutdown. The `memtest` binary built on Tails from upstream with our
61 patches applied is correctly recognised by kexec. Note that we didn't achive to
62 kexec on a memtest built on another OS.
64 The corresponding patchset:
66 - [0001-Test-memory-wipe-with-memtest86.patch](https://labs.riseup.net/code/attachments/313/0001-Test-memory-wipe-with-memtest86.patch)
71 We launched the system to test with qemu or virtualbox. We dumped the ram just
72 before shutdown, then after machine halt.
74 With qemu, one should start the system to test with `-no-shutdown`, e.g.:
76 qemu -enable-kvm -snapshot -m 2048 -no-shutdown -cdrom tails-i386-experimental-0.12.1-20120816.iso
78 We launched 4 `fillram` processes in parallel, whatching them with `top` and
79 waiting for them to be killed by oom killer. At least one terminated with
80 `MemoryError`. Fillram fills the RAM with the pattern `wipe_didnt_work\n`.
82 Then we dumped RAM with the following command in qemu console (CTRL+ALT+2). Note
83 that the end address must be adapted to the amount of RAM available in the VM:
85 pmemsave 0 0x80000000 before.dump
87 Then shutdown Tails pressing the red button, and once the machine halted, dump
90 pmemsave 0 0x80000000 after.dump
92 Then we count the occurences of the pattern in the memory dump:
94 grep -c wipe_didnt_work before.dump
95 grep -c wipe_didnt_work after.dump
100 Machine RAM Patterns %patterns %wipe
101 before wipe after wipe before wipe after wipe
103 Tails sdmem+kexec 2147483648 1772984624 17168336 82,561% 0,799% 99,032%
105 Tails memwipe+kexec 2147483648 1755221472 240 81,734% <0,001% >0,999%
107 Tails sdmem+kexec 8589934592 3243648688 1128607952 37,761% 13,139% 65,206%
109 Tails memwipe+kexec 8589934592 3372274816 240 39,258% <0,001% >0,999%
113 Resolution: 16 bytes accuacy
115 Memwipe erase memory better than current Tails implementation.
116 There is a remaining area of 240 bytes that does not get erased.
121 For the memory wipe approches we know about, this one is the most efficient we
126 - We have something that works better than any other methods we know about.
130 - There is still a small amount of memory not wiped.
131 - We have to maintain a patchset. However there is only one memtest86+ release
133 - There is no output on screen, and it may be difficult to fix.