Harden witness against reasonable tunable settings causing boot panics
or scribblers. For now, don't bother to harden this completely. Panics
are still achievable by setting the tunables to negative or very large
values.
The recent change to respect the setting of debug.witness.witness_count
(08180f1b613b) exposed that there are no guard rails on that setting,
setting it to large but plausible values can cause integer overflow or
cause attempted use of memory beyond what is actually available. Add
some guard rails, fall back to default configuration if the tuned values
are too large, and fall back to a minimum memory allocation if even the
defaults are too large. Also don't allow witness to use over half of
the memory segment, as there are other early allocators after witness
too.
Reported by: asomers
Fixes: 08180f1b613b ("witness: actually set read-only tunables in time for witness_startup")
Sponsored by: Dell Inc.