diff options
author | Adin Scannell <ascannell@google.com> | 2018-06-08 15:00:29 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-06-08 15:01:21 -0700 |
commit | 6728f09910bd9f7633f277fafe6945cfaa2abf42 (patch) | |
tree | 3f753ec51b176934e8eef6d56522d6dddb3c10f7 /pkg/sentry/arch/signal_stack.go | |
parent | de8dba205f66a07c793619a3896f2376b41a4b55 (diff) |
Fix sigaltstack semantics.
Walking off the bottom of the sigaltstack, for example with recursive faults,
results in forced signal delivery, not resetting the stack or pushing signal
stack to whatever happens to lie below the signal stack.
PiperOrigin-RevId: 199856085
Change-Id: I0004d2523f0df35d18714de2685b3eaa147837e0
Diffstat (limited to 'pkg/sentry/arch/signal_stack.go')
-rw-r--r-- | pkg/sentry/arch/signal_stack.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/sentry/arch/signal_stack.go b/pkg/sentry/arch/signal_stack.go index 7c6531d79..ba43dd1d4 100644 --- a/pkg/sentry/arch/signal_stack.go +++ b/pkg/sentry/arch/signal_stack.go @@ -39,12 +39,19 @@ func (s SignalStack) Top() usermem.Addr { return usermem.Addr(s.Addr + s.Size) } -// SetOnStack marks this signal stack as in use. (This is only called on copies -// sent to user applications, so there's no corresponding ClearOnStack.) +// SetOnStack marks this signal stack as in use. +// +// Note that there is no corresponding ClearOnStack, and that this should only +// be called on copies that are serialized to userspace. func (s *SignalStack) SetOnStack() { s.Flags |= SignalStackFlagOnStack } +// Contains checks if the stack pointer is within this stack. +func (s *SignalStack) Contains(sp usermem.Addr) bool { + return usermem.Addr(s.Addr) < sp && sp <= usermem.Addr(s.Addr+s.Size) +} + // NativeSignalStack is a type that is equivalent to stack_t in the guest // architecture. type NativeSignalStack interface { |