So this isn't very robust, because it assumes that all sources of SIGBUS
are due to that memcpy() hitting -ENOSPC...
There are several failure modes:
- If mmap_jmp is not set yet and we get a SIGBUS is some other place,
then the longjmp() result will be undefined.
- If mmap_jmp environment is set, but we've returned from
do_mmap_output() already, then the result will be undefined - likely a
non-obvious crash.
So at minimum we need a flag that tells us whether the jump environment is
valid or not - i.e. whether we are executing inside the protected region
or not - and only do the longjmp() if that flag is set.
Is there really no other way to handle the -ENOSPC case robustly? I guess
not because the memcpy() really needs memory to write to, but I thought
I'd ask ...