diff options
author | Ayush Ranjan <ayushranjan@google.com> | 2021-06-10 00:58:14 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-06-10 01:00:24 -0700 |
commit | a51fcf22ebe522c028e99692bbedf04daf0436cc (patch) | |
tree | 6f4bf3b2c5d42a223ead2ce69fc5d9fc391fbd64 /pkg/abi/linux/signal.go | |
parent | 8d87a9418aacc175d7a2fa3583f40988e05946cc (diff) |
[op] Move SignalStack to abi/linux package.
Updates #214
PiperOrigin-RevId: 378594929
Diffstat (limited to 'pkg/abi/linux/signal.go')
-rw-r--r-- | pkg/abi/linux/signal.go | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/pkg/abi/linux/signal.go b/pkg/abi/linux/signal.go index cedae3014..bbf7f6580 100644 --- a/pkg/abi/linux/signal.go +++ b/pkg/abi/linux/signal.go @@ -16,6 +16,7 @@ package linux import ( "gvisor.dev/gvisor/pkg/bits" + "gvisor.dev/gvisor/pkg/hostarch" ) const ( @@ -165,7 +166,7 @@ const ( SIG_IGN = 1 ) -// Signal action flags for rt_sigaction(2), from uapi/asm-generic/signal.h +// Signal action flags for rt_sigaction(2), from uapi/asm-generic/signal.h. const ( SA_NOCLDSTOP = 0x00000001 SA_NOCLDWAIT = 0x00000002 @@ -179,6 +180,12 @@ const ( SA_ONESHOT = SA_RESETHAND ) +// Signal stack flags for signalstack(2), from include/uapi/linux/signal.h. +const ( + SS_ONSTACK = 1 + SS_DISABLE = 2 +) + // Signal info types. const ( SI_MASK = 0xffff0000 @@ -242,6 +249,33 @@ type SigAction struct { // LINT.ThenChange(../../safecopy/safecopy_unsafe.go) +// SignalStack represents information about a user stack, and is equivalent to +// stack_t. +// +// +marshal +// +stateify savable +type SignalStack struct { + Addr uint64 + Flags uint32 + _ uint32 + Size uint64 +} + +// Contains checks if the stack pointer is within this stack. +func (s *SignalStack) Contains(sp hostarch.Addr) bool { + return hostarch.Addr(s.Addr) < sp && sp <= hostarch.Addr(s.Addr+s.Size) +} + +// Top returns the stack's top address. +func (s *SignalStack) Top() hostarch.Addr { + return hostarch.Addr(s.Addr + s.Size) +} + +// IsEnabled returns true iff this signal stack is marked as enabled. +func (s *SignalStack) IsEnabled() bool { + return s.Flags&SS_DISABLE == 0 +} + // Possible values for Sigevent.Notify, aka struct sigevent::sigev_notify. const ( SIGEV_SIGNAL = 0 |