pub fn clear_stack_on_return<F, R>(pages: usize, f: F) -> R where
F: FnMut() -> R,
Calls a closure and overwrites its stack on return.
This function calls
clear_stack after calling the passed closure,
taking care to prevent either of them being inlined, so the stack
used by the closure will be overwritten with zeros (as long as a
large enough number of
pages is used).
For technical reasons, this function can be used only with
FnMut. If all you have is a
FnOnce, use the auxiliary function
let input = b"abc"; let result = clear_stack_on_return(1, || encrypt(input));