mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
[op] Move SignalInfo to abi/linux package.
Fixes #214 PiperOrigin-RevId: 378680466
This commit is contained in:
+283
-20
@@ -186,21 +186,11 @@ const (
|
||||
SS_DISABLE = 2
|
||||
)
|
||||
|
||||
// Signal info types.
|
||||
const (
|
||||
SI_MASK = 0xffff0000
|
||||
SI_KILL = 0 << 16
|
||||
SI_TIMER = 1 << 16
|
||||
SI_POLL = 2 << 16
|
||||
SI_FAULT = 3 << 16
|
||||
SI_CHLD = 4 << 16
|
||||
SI_RT = 5 << 16
|
||||
SI_MESGQ = 6 << 16
|
||||
SI_SYS = 7 << 16
|
||||
)
|
||||
|
||||
// SIGPOLL si_codes.
|
||||
const (
|
||||
// SI_POLL is defined as __SI_POLL in Linux 2.6.
|
||||
SI_POLL = 2 << 16
|
||||
|
||||
// POLL_IN indicates that data input available.
|
||||
POLL_IN = SI_POLL | 1
|
||||
|
||||
@@ -220,6 +210,75 @@ const (
|
||||
POLL_HUP = SI_POLL | 6
|
||||
)
|
||||
|
||||
// Possible values for si_code.
|
||||
const (
|
||||
// SI_USER is sent by kill, sigsend, raise.
|
||||
SI_USER = 0
|
||||
|
||||
// SI_KERNEL is sent by the kernel from somewhere.
|
||||
SI_KERNEL = 0x80
|
||||
|
||||
// SI_QUEUE is sent by sigqueue.
|
||||
SI_QUEUE = -1
|
||||
|
||||
// SI_TIMER is sent by timer expiration.
|
||||
SI_TIMER = -2
|
||||
|
||||
// SI_MESGQ is sent by real time mesq state change.
|
||||
SI_MESGQ = -3
|
||||
|
||||
// SI_ASYNCIO is sent by AIO completion.
|
||||
SI_ASYNCIO = -4
|
||||
|
||||
// SI_SIGIO is sent by queued SIGIO.
|
||||
SI_SIGIO = -5
|
||||
|
||||
// SI_TKILL is sent by tkill system call.
|
||||
SI_TKILL = -6
|
||||
|
||||
// SI_DETHREAD is sent by execve() killing subsidiary threads.
|
||||
SI_DETHREAD = -7
|
||||
|
||||
// SI_ASYNCNL is sent by glibc async name lookup completion.
|
||||
SI_ASYNCNL = -60
|
||||
)
|
||||
|
||||
// CLD_* codes are only meaningful for SIGCHLD.
|
||||
const (
|
||||
// CLD_EXITED indicates that a task exited.
|
||||
CLD_EXITED = 1
|
||||
|
||||
// CLD_KILLED indicates that a task was killed by a signal.
|
||||
CLD_KILLED = 2
|
||||
|
||||
// CLD_DUMPED indicates that a task was killed by a signal and then dumped
|
||||
// core.
|
||||
CLD_DUMPED = 3
|
||||
|
||||
// CLD_TRAPPED indicates that a task was stopped by ptrace.
|
||||
CLD_TRAPPED = 4
|
||||
|
||||
// CLD_STOPPED indicates that a thread group completed a group stop.
|
||||
CLD_STOPPED = 5
|
||||
|
||||
// CLD_CONTINUED indicates that a group-stopped thread group was continued.
|
||||
CLD_CONTINUED = 6
|
||||
)
|
||||
|
||||
// SYS_* codes are only meaningful for SIGSYS.
|
||||
const (
|
||||
// SYS_SECCOMP indicates that a signal originates from seccomp.
|
||||
SYS_SECCOMP = 1
|
||||
)
|
||||
|
||||
// Possible values for Sigevent.Notify, aka struct sigevent::sigev_notify.
|
||||
const (
|
||||
SIGEV_SIGNAL = 0
|
||||
SIGEV_NONE = 1
|
||||
SIGEV_THREAD = 2
|
||||
SIGEV_THREAD_ID = 4
|
||||
)
|
||||
|
||||
// Sigevent represents struct sigevent.
|
||||
//
|
||||
// +marshal
|
||||
@@ -276,10 +335,214 @@ 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
|
||||
SIGEV_NONE = 1
|
||||
SIGEV_THREAD = 2
|
||||
SIGEV_THREAD_ID = 4
|
||||
)
|
||||
// SignalInfo represents information about a signal being delivered, and is
|
||||
// equivalent to struct siginfo in linux kernel(linux/include/uapi/asm-generic/siginfo.h).
|
||||
//
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type SignalInfo struct {
|
||||
Signo int32 // Signal number
|
||||
Errno int32 // Errno value
|
||||
Code int32 // Signal code
|
||||
_ uint32
|
||||
|
||||
// struct siginfo::_sifields is a union. In SignalInfo, fields in the union
|
||||
// are accessed through methods.
|
||||
//
|
||||
// For reference, here is the definition of _sifields: (_sigfault._trapno,
|
||||
// which does not exist on x86, omitted for clarity)
|
||||
//
|
||||
// union {
|
||||
// int _pad[SI_PAD_SIZE];
|
||||
//
|
||||
// /* kill() */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* sender's pid */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// } _kill;
|
||||
//
|
||||
// /* POSIX.1b timers */
|
||||
// struct {
|
||||
// __kernel_timer_t _tid; /* timer id */
|
||||
// int _overrun; /* overrun count */
|
||||
// char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
|
||||
// sigval_t _sigval; /* same as below */
|
||||
// int _sys_private; /* not to be passed to user */
|
||||
// } _timer;
|
||||
//
|
||||
// /* POSIX.1b signals */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* sender's pid */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// sigval_t _sigval;
|
||||
// } _rt;
|
||||
//
|
||||
// /* SIGCHLD */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* which child */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// int _status; /* exit code */
|
||||
// __ARCH_SI_CLOCK_T _utime;
|
||||
// __ARCH_SI_CLOCK_T _stime;
|
||||
// } _sigchld;
|
||||
//
|
||||
// /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
||||
// struct {
|
||||
// void *_addr; /* faulting insn/memory ref. */
|
||||
// short _addr_lsb; /* LSB of the reported address */
|
||||
// } _sigfault;
|
||||
//
|
||||
// /* SIGPOLL */
|
||||
// struct {
|
||||
// __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
|
||||
// int _fd;
|
||||
// } _sigpoll;
|
||||
//
|
||||
// /* SIGSYS */
|
||||
// struct {
|
||||
// void *_call_addr; /* calling user insn */
|
||||
// int _syscall; /* triggering system call number */
|
||||
// unsigned int _arch; /* AUDIT_ARCH_* of syscall */
|
||||
// } _sigsys;
|
||||
// } _sifields;
|
||||
//
|
||||
// _sifields is padded so that the size of siginfo is SI_MAX_SIZE = 128
|
||||
// bytes.
|
||||
Fields [128 - 16]byte
|
||||
}
|
||||
|
||||
// FixSignalCodeForUser fixes up si_code.
|
||||
//
|
||||
// The si_code we get from Linux may contain the kernel-specific code in the
|
||||
// top 16 bits if it's positive (e.g., from ptrace). Linux's
|
||||
// copy_siginfo_to_user does
|
||||
// err |= __put_user((short)from->si_code, &to->si_code);
|
||||
// to mask out those bits and we need to do the same.
|
||||
func (s *SignalInfo) FixSignalCodeForUser() {
|
||||
if s.Code > 0 {
|
||||
s.Code &= 0x0000ffff
|
||||
}
|
||||
}
|
||||
|
||||
// PID returns the si_pid field.
|
||||
func (s *SignalInfo) PID() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[0:4]))
|
||||
}
|
||||
|
||||
// SetPID mutates the si_pid field.
|
||||
func (s *SignalInfo) SetPID(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[0:4], uint32(val))
|
||||
}
|
||||
|
||||
// UID returns the si_uid field.
|
||||
func (s *SignalInfo) UID() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[4:8]))
|
||||
}
|
||||
|
||||
// SetUID mutates the si_uid field.
|
||||
func (s *SignalInfo) SetUID(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[4:8], uint32(val))
|
||||
}
|
||||
|
||||
// Sigval returns the sigval field, which is aliased to both si_int and si_ptr.
|
||||
func (s *SignalInfo) Sigval() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[8:16])
|
||||
}
|
||||
|
||||
// SetSigval mutates the sigval field.
|
||||
func (s *SignalInfo) SetSigval(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[8:16], val)
|
||||
}
|
||||
|
||||
// TimerID returns the si_timerid field.
|
||||
func (s *SignalInfo) TimerID() TimerID {
|
||||
return TimerID(hostarch.ByteOrder.Uint32(s.Fields[0:4]))
|
||||
}
|
||||
|
||||
// SetTimerID sets the si_timerid field.
|
||||
func (s *SignalInfo) SetTimerID(val TimerID) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[0:4], uint32(val))
|
||||
}
|
||||
|
||||
// Overrun returns the si_overrun field.
|
||||
func (s *SignalInfo) Overrun() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[4:8]))
|
||||
}
|
||||
|
||||
// SetOverrun sets the si_overrun field.
|
||||
func (s *SignalInfo) SetOverrun(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[4:8], uint32(val))
|
||||
}
|
||||
|
||||
// Addr returns the si_addr field.
|
||||
func (s *SignalInfo) Addr() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[0:8])
|
||||
}
|
||||
|
||||
// SetAddr sets the si_addr field.
|
||||
func (s *SignalInfo) SetAddr(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], val)
|
||||
}
|
||||
|
||||
// Status returns the si_status field.
|
||||
func (s *SignalInfo) Status() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[8:12]))
|
||||
}
|
||||
|
||||
// SetStatus mutates the si_status field.
|
||||
func (s *SignalInfo) SetStatus(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], uint32(val))
|
||||
}
|
||||
|
||||
// CallAddr returns the si_call_addr field.
|
||||
func (s *SignalInfo) CallAddr() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[0:8])
|
||||
}
|
||||
|
||||
// SetCallAddr mutates the si_call_addr field.
|
||||
func (s *SignalInfo) SetCallAddr(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], val)
|
||||
}
|
||||
|
||||
// Syscall returns the si_syscall field.
|
||||
func (s *SignalInfo) Syscall() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[8:12]))
|
||||
}
|
||||
|
||||
// SetSyscall mutates the si_syscall field.
|
||||
func (s *SignalInfo) SetSyscall(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], uint32(val))
|
||||
}
|
||||
|
||||
// Arch returns the si_arch field.
|
||||
func (s *SignalInfo) Arch() uint32 {
|
||||
return hostarch.ByteOrder.Uint32(s.Fields[12:16])
|
||||
}
|
||||
|
||||
// SetArch mutates the si_arch field.
|
||||
func (s *SignalInfo) SetArch(val uint32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[12:16], val)
|
||||
}
|
||||
|
||||
// Band returns the si_band field.
|
||||
func (s *SignalInfo) Band() int64 {
|
||||
return int64(hostarch.ByteOrder.Uint64(s.Fields[0:8]))
|
||||
}
|
||||
|
||||
// SetBand mutates the si_band field.
|
||||
func (s *SignalInfo) SetBand(val int64) {
|
||||
// Note: this assumes the platform uses `long` as `__ARCH_SI_BAND_T`.
|
||||
// On some platforms, which gVisor doesn't support, `__ARCH_SI_BAND_T` is
|
||||
// `int`. See siginfo.h.
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], uint64(val))
|
||||
}
|
||||
|
||||
// FD returns the si_fd field.
|
||||
func (s *SignalInfo) FD() uint32 {
|
||||
return hostarch.ByteOrder.Uint32(s.Fields[8:12])
|
||||
}
|
||||
|
||||
// SetFD mutates the si_fd field.
|
||||
func (s *SignalInfo) SetFD(val uint32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], val)
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ go_library(
|
||||
"arch_x86.go",
|
||||
"arch_x86_impl.go",
|
||||
"auxv.go",
|
||||
"signal.go",
|
||||
"signal_amd64.go",
|
||||
"signal_arm64.go",
|
||||
"signal_info.go",
|
||||
"stack.go",
|
||||
"stack_unsafe.go",
|
||||
"syscalls_amd64.go",
|
||||
|
||||
@@ -149,7 +149,7 @@ type Context interface {
|
||||
// stack is not going to be used).
|
||||
//
|
||||
// sigset is the signal mask before entering the signal handler.
|
||||
SignalSetup(st *Stack, act *linux.SigAction, info *SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error
|
||||
SignalSetup(st *Stack, act *linux.SigAction, info *linux.SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error
|
||||
|
||||
// SignalRestore restores context after returning from a signal
|
||||
// handler.
|
||||
|
||||
@@ -1,232 +0,0 @@
|
||||
// Copyright 2020 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package arch
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
|
||||
// SignalInfo represents information about a signal being delivered, and is
|
||||
// equivalent to struct siginfo in linux kernel(linux/include/uapi/asm-generic/siginfo.h).
|
||||
//
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type SignalInfo struct {
|
||||
Signo int32 // Signal number
|
||||
Errno int32 // Errno value
|
||||
Code int32 // Signal code
|
||||
_ uint32
|
||||
|
||||
// struct siginfo::_sifields is a union. In SignalInfo, fields in the union
|
||||
// are accessed through methods.
|
||||
//
|
||||
// For reference, here is the definition of _sifields: (_sigfault._trapno,
|
||||
// which does not exist on x86, omitted for clarity)
|
||||
//
|
||||
// union {
|
||||
// int _pad[SI_PAD_SIZE];
|
||||
//
|
||||
// /* kill() */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* sender's pid */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// } _kill;
|
||||
//
|
||||
// /* POSIX.1b timers */
|
||||
// struct {
|
||||
// __kernel_timer_t _tid; /* timer id */
|
||||
// int _overrun; /* overrun count */
|
||||
// char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)];
|
||||
// sigval_t _sigval; /* same as below */
|
||||
// int _sys_private; /* not to be passed to user */
|
||||
// } _timer;
|
||||
//
|
||||
// /* POSIX.1b signals */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* sender's pid */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// sigval_t _sigval;
|
||||
// } _rt;
|
||||
//
|
||||
// /* SIGCHLD */
|
||||
// struct {
|
||||
// __kernel_pid_t _pid; /* which child */
|
||||
// __ARCH_SI_UID_T _uid; /* sender's uid */
|
||||
// int _status; /* exit code */
|
||||
// __ARCH_SI_CLOCK_T _utime;
|
||||
// __ARCH_SI_CLOCK_T _stime;
|
||||
// } _sigchld;
|
||||
//
|
||||
// /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
||||
// struct {
|
||||
// void *_addr; /* faulting insn/memory ref. */
|
||||
// short _addr_lsb; /* LSB of the reported address */
|
||||
// } _sigfault;
|
||||
//
|
||||
// /* SIGPOLL */
|
||||
// struct {
|
||||
// __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
|
||||
// int _fd;
|
||||
// } _sigpoll;
|
||||
//
|
||||
// /* SIGSYS */
|
||||
// struct {
|
||||
// void *_call_addr; /* calling user insn */
|
||||
// int _syscall; /* triggering system call number */
|
||||
// unsigned int _arch; /* AUDIT_ARCH_* of syscall */
|
||||
// } _sigsys;
|
||||
// } _sifields;
|
||||
//
|
||||
// _sifields is padded so that the size of siginfo is SI_MAX_SIZE = 128
|
||||
// bytes.
|
||||
Fields [128 - 16]byte
|
||||
}
|
||||
|
||||
// FixSignalCodeForUser fixes up si_code.
|
||||
//
|
||||
// The si_code we get from Linux may contain the kernel-specific code in the
|
||||
// top 16 bits if it's positive (e.g., from ptrace). Linux's
|
||||
// copy_siginfo_to_user does
|
||||
// err |= __put_user((short)from->si_code, &to->si_code);
|
||||
// to mask out those bits and we need to do the same.
|
||||
func (s *SignalInfo) FixSignalCodeForUser() {
|
||||
if s.Code > 0 {
|
||||
s.Code &= 0x0000ffff
|
||||
}
|
||||
}
|
||||
|
||||
// PID returns the si_pid field.
|
||||
func (s *SignalInfo) PID() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[0:4]))
|
||||
}
|
||||
|
||||
// SetPID mutates the si_pid field.
|
||||
func (s *SignalInfo) SetPID(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[0:4], uint32(val))
|
||||
}
|
||||
|
||||
// UID returns the si_uid field.
|
||||
func (s *SignalInfo) UID() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[4:8]))
|
||||
}
|
||||
|
||||
// SetUID mutates the si_uid field.
|
||||
func (s *SignalInfo) SetUID(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[4:8], uint32(val))
|
||||
}
|
||||
|
||||
// Sigval returns the sigval field, which is aliased to both si_int and si_ptr.
|
||||
func (s *SignalInfo) Sigval() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[8:16])
|
||||
}
|
||||
|
||||
// SetSigval mutates the sigval field.
|
||||
func (s *SignalInfo) SetSigval(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[8:16], val)
|
||||
}
|
||||
|
||||
// TimerID returns the si_timerid field.
|
||||
func (s *SignalInfo) TimerID() linux.TimerID {
|
||||
return linux.TimerID(hostarch.ByteOrder.Uint32(s.Fields[0:4]))
|
||||
}
|
||||
|
||||
// SetTimerID sets the si_timerid field.
|
||||
func (s *SignalInfo) SetTimerID(val linux.TimerID) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[0:4], uint32(val))
|
||||
}
|
||||
|
||||
// Overrun returns the si_overrun field.
|
||||
func (s *SignalInfo) Overrun() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[4:8]))
|
||||
}
|
||||
|
||||
// SetOverrun sets the si_overrun field.
|
||||
func (s *SignalInfo) SetOverrun(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[4:8], uint32(val))
|
||||
}
|
||||
|
||||
// Addr returns the si_addr field.
|
||||
func (s *SignalInfo) Addr() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[0:8])
|
||||
}
|
||||
|
||||
// SetAddr sets the si_addr field.
|
||||
func (s *SignalInfo) SetAddr(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], val)
|
||||
}
|
||||
|
||||
// Status returns the si_status field.
|
||||
func (s *SignalInfo) Status() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[8:12]))
|
||||
}
|
||||
|
||||
// SetStatus mutates the si_status field.
|
||||
func (s *SignalInfo) SetStatus(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], uint32(val))
|
||||
}
|
||||
|
||||
// CallAddr returns the si_call_addr field.
|
||||
func (s *SignalInfo) CallAddr() uint64 {
|
||||
return hostarch.ByteOrder.Uint64(s.Fields[0:8])
|
||||
}
|
||||
|
||||
// SetCallAddr mutates the si_call_addr field.
|
||||
func (s *SignalInfo) SetCallAddr(val uint64) {
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], val)
|
||||
}
|
||||
|
||||
// Syscall returns the si_syscall field.
|
||||
func (s *SignalInfo) Syscall() int32 {
|
||||
return int32(hostarch.ByteOrder.Uint32(s.Fields[8:12]))
|
||||
}
|
||||
|
||||
// SetSyscall mutates the si_syscall field.
|
||||
func (s *SignalInfo) SetSyscall(val int32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], uint32(val))
|
||||
}
|
||||
|
||||
// Arch returns the si_arch field.
|
||||
func (s *SignalInfo) Arch() uint32 {
|
||||
return hostarch.ByteOrder.Uint32(s.Fields[12:16])
|
||||
}
|
||||
|
||||
// SetArch mutates the si_arch field.
|
||||
func (s *SignalInfo) SetArch(val uint32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[12:16], val)
|
||||
}
|
||||
|
||||
// Band returns the si_band field.
|
||||
func (s *SignalInfo) Band() int64 {
|
||||
return int64(hostarch.ByteOrder.Uint64(s.Fields[0:8]))
|
||||
}
|
||||
|
||||
// SetBand mutates the si_band field.
|
||||
func (s *SignalInfo) SetBand(val int64) {
|
||||
// Note: this assumes the platform uses `long` as `__ARCH_SI_BAND_T`.
|
||||
// On some platforms, which gVisor doesn't support, `__ARCH_SI_BAND_T` is
|
||||
// `int`. See siginfo.h.
|
||||
hostarch.ByteOrder.PutUint64(s.Fields[0:8], uint64(val))
|
||||
}
|
||||
|
||||
// FD returns the si_fd field.
|
||||
func (s *SignalInfo) FD() uint32 {
|
||||
return hostarch.ByteOrder.Uint32(s.Fields[8:12])
|
||||
}
|
||||
|
||||
// SetFD mutates the si_fd field.
|
||||
func (s *SignalInfo) SetFD(val uint32) {
|
||||
hostarch.ByteOrder.PutUint32(s.Fields[8:12], val)
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (c *context64) fpuFrameSize() (size int, useXsave bool) {
|
||||
|
||||
// SignalSetup implements Context.SignalSetup. (Compare to Linux's
|
||||
// arch/x86/kernel/signal.c:__setup_rt_frame().)
|
||||
func (c *context64) SignalSetup(st *Stack, act *linux.SigAction, info *SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error {
|
||||
func (c *context64) SignalSetup(st *Stack, act *linux.SigAction, info *linux.SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error {
|
||||
sp := st.Bottom
|
||||
|
||||
// "The 128-byte area beyond the location pointed to by %rsp is considered
|
||||
@@ -233,7 +233,7 @@ func (c *context64) SignalRestore(st *Stack, rt bool) (linux.SignalSet, linux.Si
|
||||
if _, err := uc.CopyIn(st, StackBottomMagic); err != nil {
|
||||
return 0, linux.SignalStack{}, err
|
||||
}
|
||||
var info SignalInfo
|
||||
var info linux.SignalInfo
|
||||
if _, err := info.CopyIn(st, StackBottomMagic); err != nil {
|
||||
return 0, linux.SignalStack{}, err
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ type UContext64 struct {
|
||||
}
|
||||
|
||||
// SignalSetup implements Context.SignalSetup.
|
||||
func (c *context64) SignalSetup(st *Stack, act *linux.SigAction, info *SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error {
|
||||
func (c *context64) SignalSetup(st *Stack, act *linux.SigAction, info *linux.SignalInfo, alt *linux.SignalStack, sigset linux.SignalSet) error {
|
||||
sp := st.Bottom
|
||||
|
||||
// Construct the UContext64 now since we need its size.
|
||||
@@ -143,7 +143,7 @@ func (c *context64) SignalRestore(st *Stack, rt bool) (linux.SignalSet, linux.Si
|
||||
if _, err := uc.CopyIn(st, StackBottomMagic); err != nil {
|
||||
return 0, linux.SignalStack{}, err
|
||||
}
|
||||
var info SignalInfo
|
||||
var info linux.SignalInfo
|
||||
if _, err := info.CopyIn(st, StackBottomMagic); err != nil {
|
||||
return 0, linux.SignalStack{}, err
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
// Copyright 2018 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package arch
|
||||
|
||||
// Possible values for SignalInfo.Code. These values originate from the Linux
|
||||
// kernel's include/uapi/asm-generic/siginfo.h.
|
||||
const (
|
||||
// SignalInfoUser (properly SI_USER) indicates that a signal was sent from
|
||||
// a kill() or raise() syscall.
|
||||
SignalInfoUser = 0
|
||||
|
||||
// SignalInfoKernel (properly SI_KERNEL) indicates that the signal was sent
|
||||
// by the kernel.
|
||||
SignalInfoKernel = 0x80
|
||||
|
||||
// SignalInfoTimer (properly SI_TIMER) indicates that the signal was sent
|
||||
// by an expired timer.
|
||||
SignalInfoTimer = -2
|
||||
|
||||
// SignalInfoTkill (properly SI_TKILL) indicates that the signal was sent
|
||||
// from a tkill() or tgkill() syscall.
|
||||
SignalInfoTkill = -6
|
||||
|
||||
// CLD_* codes are only meaningful for SIGCHLD.
|
||||
|
||||
// CLD_EXITED indicates that a task exited.
|
||||
CLD_EXITED = 1
|
||||
|
||||
// CLD_KILLED indicates that a task was killed by a signal.
|
||||
CLD_KILLED = 2
|
||||
|
||||
// CLD_DUMPED indicates that a task was killed by a signal and then dumped
|
||||
// core.
|
||||
CLD_DUMPED = 3
|
||||
|
||||
// CLD_TRAPPED indicates that a task was stopped by ptrace.
|
||||
CLD_TRAPPED = 4
|
||||
|
||||
// CLD_STOPPED indicates that a thread group completed a group stop.
|
||||
CLD_STOPPED = 5
|
||||
|
||||
// CLD_CONTINUED indicates that a group-stopped thread group was continued.
|
||||
CLD_CONTINUED = 6
|
||||
|
||||
// SYS_* codes are only meaningful for SIGSYS.
|
||||
|
||||
// SYS_SECCOMP indicates that a signal originates from seccomp.
|
||||
SYS_SECCOMP = 1
|
||||
|
||||
// TRAP_* codes are only meaningful for SIGTRAP.
|
||||
|
||||
// TRAP_BRKPT indicates a breakpoint trap.
|
||||
TRAP_BRKPT = 1
|
||||
)
|
||||
@@ -45,7 +45,7 @@ type Stack struct {
|
||||
}
|
||||
|
||||
// scratchBufLen is the default length of Stack.scratchBuf. The
|
||||
// largest structs the stack regularly serializes are arch.SignalInfo
|
||||
// largest structs the stack regularly serializes are linux.SignalInfo
|
||||
// and arch.UContext64. We'll set the default size as the larger of
|
||||
// the two, arch.UContext64.
|
||||
var scratchBufLen = (*UContext64)(nil).SizeBytes()
|
||||
|
||||
@@ -8,7 +8,6 @@ go_library(
|
||||
visibility = ["//:sandbox"],
|
||||
deps = [
|
||||
"//pkg/abi/linux",
|
||||
"//pkg/sentry/arch",
|
||||
"//pkg/sentry/fs",
|
||||
"//pkg/sentry/kernel",
|
||||
"//pkg/sentry/kernel/auth",
|
||||
|
||||
@@ -17,7 +17,6 @@ package fasync
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/fs"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
||||
@@ -125,9 +124,9 @@ func (a *FileAsync) Callback(e *waiter.Entry, mask waiter.EventMask) {
|
||||
if !permCheck {
|
||||
return
|
||||
}
|
||||
signalInfo := &arch.SignalInfo{
|
||||
signalInfo := &linux.SignalInfo{
|
||||
Signo: int32(linux.SIGIO),
|
||||
Code: arch.SignalInfoKernel,
|
||||
Code: linux.SI_KERNEL,
|
||||
}
|
||||
if a.signal != 0 {
|
||||
signalInfo.Signo = int32(a.signal)
|
||||
|
||||
@@ -1341,7 +1341,7 @@ func (k *Kernel) Unpause() {
|
||||
// context is used only for debugging to describe how the signal was received.
|
||||
//
|
||||
// Preconditions: Kernel must have an init process.
|
||||
func (k *Kernel) SendExternalSignal(info *arch.SignalInfo, context string) {
|
||||
func (k *Kernel) SendExternalSignal(info *linux.SignalInfo, context string) {
|
||||
k.extMu.Lock()
|
||||
defer k.extMu.Unlock()
|
||||
k.sendExternalSignal(info, context)
|
||||
@@ -1349,7 +1349,7 @@ func (k *Kernel) SendExternalSignal(info *arch.SignalInfo, context string) {
|
||||
|
||||
// SendExternalSignalThreadGroup injects a signal into an specific ThreadGroup.
|
||||
// This function doesn't skip signals like SendExternalSignal does.
|
||||
func (k *Kernel) SendExternalSignalThreadGroup(tg *ThreadGroup, info *arch.SignalInfo) error {
|
||||
func (k *Kernel) SendExternalSignalThreadGroup(tg *ThreadGroup, info *linux.SignalInfo) error {
|
||||
k.extMu.Lock()
|
||||
defer k.extMu.Unlock()
|
||||
return tg.SendSignal(info)
|
||||
@@ -1357,7 +1357,7 @@ func (k *Kernel) SendExternalSignalThreadGroup(tg *ThreadGroup, info *arch.Signa
|
||||
|
||||
// SendContainerSignal sends the given signal to all processes inside the
|
||||
// namespace that match the given container ID.
|
||||
func (k *Kernel) SendContainerSignal(cid string, info *arch.SignalInfo) error {
|
||||
func (k *Kernel) SendContainerSignal(cid string, info *linux.SignalInfo) error {
|
||||
k.extMu.Lock()
|
||||
defer k.extMu.Unlock()
|
||||
k.tasks.mu.RLock()
|
||||
|
||||
@@ -17,7 +17,6 @@ package kernel
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/bits"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -65,7 +64,7 @@ type pendingSignalQueue struct {
|
||||
type pendingSignal struct {
|
||||
// pendingSignalEntry links into a pendingSignalList.
|
||||
pendingSignalEntry
|
||||
*arch.SignalInfo
|
||||
*linux.SignalInfo
|
||||
|
||||
// If timer is not nil, it is the IntervalTimer which sent this signal.
|
||||
timer *IntervalTimer
|
||||
@@ -75,7 +74,7 @@ type pendingSignal struct {
|
||||
// on failure (if the given signal's queue is full).
|
||||
//
|
||||
// Preconditions: info represents a valid signal.
|
||||
func (p *pendingSignals) enqueue(info *arch.SignalInfo, timer *IntervalTimer) bool {
|
||||
func (p *pendingSignals) enqueue(info *linux.SignalInfo, timer *IntervalTimer) bool {
|
||||
sig := linux.Signal(info.Signo)
|
||||
q := &p.signals[sig.Index()]
|
||||
if sig.IsStandard() {
|
||||
@@ -93,7 +92,7 @@ func (p *pendingSignals) enqueue(info *arch.SignalInfo, timer *IntervalTimer) bo
|
||||
|
||||
// dequeue dequeues and returns any pending signal not masked by mask. If no
|
||||
// unmasked signals are pending, dequeue returns nil.
|
||||
func (p *pendingSignals) dequeue(mask linux.SignalSet) *arch.SignalInfo {
|
||||
func (p *pendingSignals) dequeue(mask linux.SignalSet) *linux.SignalInfo {
|
||||
// "Real-time signals are delivered in a guaranteed order. Multiple
|
||||
// real-time signals of the same type are delivered in the order they were
|
||||
// sent. If different real-time signals are sent to a process, they are
|
||||
@@ -111,7 +110,7 @@ func (p *pendingSignals) dequeue(mask linux.SignalSet) *arch.SignalInfo {
|
||||
return p.dequeueSpecific(linux.Signal(lowestPendingUnblockedBit + 1))
|
||||
}
|
||||
|
||||
func (p *pendingSignals) dequeueSpecific(sig linux.Signal) *arch.SignalInfo {
|
||||
func (p *pendingSignals) dequeueSpecific(sig linux.Signal) *linux.SignalInfo {
|
||||
q := &p.signals[sig.Index()]
|
||||
ps := q.pendingSignalList.Front()
|
||||
if ps == nil {
|
||||
|
||||
@@ -14,13 +14,11 @@
|
||||
|
||||
package kernel
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
)
|
||||
import "gvisor.dev/gvisor/pkg/abi/linux"
|
||||
|
||||
// +stateify savable
|
||||
type savedPendingSignal struct {
|
||||
si *arch.SignalInfo
|
||||
si *linux.SignalInfo
|
||||
timer *IntervalTimer
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"math"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
ktime "gvisor.dev/gvisor/pkg/sentry/kernel/time"
|
||||
"gvisor.dev/gvisor/pkg/syserror"
|
||||
)
|
||||
@@ -97,7 +96,7 @@ func (it *IntervalTimer) ResumeTimer() {
|
||||
}
|
||||
|
||||
// Preconditions: it.target's signal mutex must be locked.
|
||||
func (it *IntervalTimer) updateDequeuedSignalLocked(si *arch.SignalInfo) {
|
||||
func (it *IntervalTimer) updateDequeuedSignalLocked(si *linux.SignalInfo) {
|
||||
it.sigpending = false
|
||||
if it.sigorphan {
|
||||
return
|
||||
@@ -138,9 +137,9 @@ func (it *IntervalTimer) Notify(exp uint64, setting ktime.Setting) (ktime.Settin
|
||||
it.sigpending = true
|
||||
it.sigorphan = false
|
||||
it.overrunCur += exp - 1
|
||||
si := &arch.SignalInfo{
|
||||
si := &linux.SignalInfo{
|
||||
Signo: int32(it.signo),
|
||||
Code: arch.SignalInfoTimer,
|
||||
Code: linux.SI_TIMER,
|
||||
}
|
||||
si.SetTimerID(it.id)
|
||||
si.SetSigval(it.sigval)
|
||||
|
||||
+11
-12
@@ -21,7 +21,6 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
"gvisor.dev/gvisor/pkg/marshal/primitive"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/mm"
|
||||
"gvisor.dev/gvisor/pkg/syserror"
|
||||
"gvisor.dev/gvisor/pkg/usermem"
|
||||
@@ -394,7 +393,7 @@ func (t *Task) ptraceTrapLocked(code int32) {
|
||||
t.trapStopPending = false
|
||||
t.tg.signalHandlers.mu.Unlock()
|
||||
t.ptraceCode = code
|
||||
t.ptraceSiginfo = &arch.SignalInfo{
|
||||
t.ptraceSiginfo = &linux.SignalInfo{
|
||||
Signo: int32(linux.SIGTRAP),
|
||||
Code: code,
|
||||
}
|
||||
@@ -402,7 +401,7 @@ func (t *Task) ptraceTrapLocked(code int32) {
|
||||
t.ptraceSiginfo.SetUID(int32(t.Credentials().RealKUID.In(t.UserNamespace()).OrOverflow()))
|
||||
if t.beginPtraceStopLocked() {
|
||||
tracer := t.Tracer()
|
||||
tracer.signalStop(t, arch.CLD_TRAPPED, int32(linux.SIGTRAP))
|
||||
tracer.signalStop(t, linux.CLD_TRAPPED, int32(linux.SIGTRAP))
|
||||
tracer.tg.eventQueue.Notify(EventTraceeStop)
|
||||
}
|
||||
}
|
||||
@@ -542,9 +541,9 @@ func (t *Task) ptraceAttach(target *Task, seize bool, opts uintptr) error {
|
||||
// "Unlike PTRACE_ATTACH, PTRACE_SEIZE does not stop the process." -
|
||||
// ptrace(2)
|
||||
if !seize {
|
||||
target.sendSignalLocked(&arch.SignalInfo{
|
||||
target.sendSignalLocked(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGSTOP),
|
||||
Code: arch.SignalInfoUser,
|
||||
Code: linux.SI_USER,
|
||||
}, false /* group */)
|
||||
}
|
||||
// Undocumented Linux feature: If the tracee is already group-stopped (and
|
||||
@@ -586,7 +585,7 @@ func (t *Task) exitPtrace() {
|
||||
for target := range t.ptraceTracees {
|
||||
if target.ptraceOpts.ExitKill {
|
||||
target.tg.signalHandlers.mu.Lock()
|
||||
target.sendSignalLocked(&arch.SignalInfo{
|
||||
target.sendSignalLocked(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGKILL),
|
||||
}, false /* group */)
|
||||
target.tg.signalHandlers.mu.Unlock()
|
||||
@@ -652,7 +651,7 @@ func (t *Task) forgetTracerLocked() {
|
||||
// Preconditions:
|
||||
// * The signal mutex must be locked.
|
||||
// * The caller must be running on the task goroutine.
|
||||
func (t *Task) ptraceSignalLocked(info *arch.SignalInfo) bool {
|
||||
func (t *Task) ptraceSignalLocked(info *linux.SignalInfo) bool {
|
||||
if linux.Signal(info.Signo) == linux.SIGKILL {
|
||||
return false
|
||||
}
|
||||
@@ -678,7 +677,7 @@ func (t *Task) ptraceSignalLocked(info *arch.SignalInfo) bool {
|
||||
t.ptraceSiginfo = info
|
||||
t.Debugf("Entering signal-delivery-stop for signal %d", info.Signo)
|
||||
if t.beginPtraceStopLocked() {
|
||||
tracer.signalStop(t, arch.CLD_TRAPPED, info.Signo)
|
||||
tracer.signalStop(t, linux.CLD_TRAPPED, info.Signo)
|
||||
tracer.tg.eventQueue.Notify(EventTraceeStop)
|
||||
}
|
||||
return true
|
||||
@@ -829,7 +828,7 @@ func (t *Task) ptraceClone(kind ptraceCloneKind, child *Task, opts *CloneOptions
|
||||
if child.ptraceSeized {
|
||||
child.trapStopPending = true
|
||||
} else {
|
||||
child.pendingSignals.enqueue(&arch.SignalInfo{
|
||||
child.pendingSignals.enqueue(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGSTOP),
|
||||
}, nil)
|
||||
}
|
||||
@@ -893,9 +892,9 @@ func (t *Task) ptraceExec(oldTID ThreadID) {
|
||||
}
|
||||
t.tg.signalHandlers.mu.Lock()
|
||||
defer t.tg.signalHandlers.mu.Unlock()
|
||||
t.sendSignalLocked(&arch.SignalInfo{
|
||||
t.sendSignalLocked(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGTRAP),
|
||||
Code: arch.SignalInfoUser,
|
||||
Code: linux.SI_USER,
|
||||
}, false /* group */)
|
||||
}
|
||||
|
||||
@@ -1228,7 +1227,7 @@ func (t *Task) Ptrace(req int64, pid ThreadID, addr, data hostarch.Addr) error {
|
||||
return err
|
||||
|
||||
case linux.PTRACE_SETSIGINFO:
|
||||
var info arch.SignalInfo
|
||||
var info linux.SignalInfo
|
||||
if _, err := info.CopyIn(t, data); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ func dataAsBPFInput(t *Task, d *linux.SeccompData) bpf.Input {
|
||||
}
|
||||
}
|
||||
|
||||
func seccompSiginfo(t *Task, errno, sysno int32, ip hostarch.Addr) *arch.SignalInfo {
|
||||
si := &arch.SignalInfo{
|
||||
func seccompSiginfo(t *Task, errno, sysno int32, ip hostarch.Addr) *linux.SignalInfo {
|
||||
si := &linux.SignalInfo{
|
||||
Signo: int32(linux.SIGSYS),
|
||||
Errno: errno,
|
||||
Code: arch.SYS_SECCOMP,
|
||||
Code: linux.SYS_SECCOMP,
|
||||
}
|
||||
si.SetCallAddr(uint64(ip))
|
||||
si.SetSyscall(sysno)
|
||||
|
||||
@@ -16,7 +16,6 @@ package kernel
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/syserror"
|
||||
)
|
||||
|
||||
@@ -233,7 +232,7 @@ func (pg *ProcessGroup) Session() *Session {
|
||||
|
||||
// SendSignal sends a signal to all processes inside the process group. It is
|
||||
// analagous to kernel/signal.c:kill_pgrp.
|
||||
func (pg *ProcessGroup) SendSignal(info *arch.SignalInfo) error {
|
||||
func (pg *ProcessGroup) SendSignal(info *linux.SignalInfo) error {
|
||||
tasks := pg.originator.TaskSet()
|
||||
tasks.mu.RLock()
|
||||
defer tasks.mu.RUnlock()
|
||||
|
||||
@@ -19,7 +19,6 @@ import (
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/log"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/platform"
|
||||
)
|
||||
|
||||
@@ -36,7 +35,7 @@ const SignalPanic = linux.SIGUSR2
|
||||
// context is used only for debugging to differentiate these cases.
|
||||
//
|
||||
// Preconditions: Kernel must have an init process.
|
||||
func (k *Kernel) sendExternalSignal(info *arch.SignalInfo, context string) {
|
||||
func (k *Kernel) sendExternalSignal(info *linux.SignalInfo, context string) {
|
||||
switch linux.Signal(info.Signo) {
|
||||
case linux.SIGURG:
|
||||
// Sent by the Go 1.14+ runtime for asynchronous goroutine preemption.
|
||||
@@ -60,18 +59,18 @@ func (k *Kernel) sendExternalSignal(info *arch.SignalInfo, context string) {
|
||||
}
|
||||
|
||||
// SignalInfoPriv returns a SignalInfo equivalent to Linux's SEND_SIG_PRIV.
|
||||
func SignalInfoPriv(sig linux.Signal) *arch.SignalInfo {
|
||||
return &arch.SignalInfo{
|
||||
func SignalInfoPriv(sig linux.Signal) *linux.SignalInfo {
|
||||
return &linux.SignalInfo{
|
||||
Signo: int32(sig),
|
||||
Code: arch.SignalInfoKernel,
|
||||
Code: linux.SI_KERNEL,
|
||||
}
|
||||
}
|
||||
|
||||
// SignalInfoNoInfo returns a SignalInfo equivalent to Linux's SEND_SIG_NOINFO.
|
||||
func SignalInfoNoInfo(sig linux.Signal, sender, receiver *Task) *arch.SignalInfo {
|
||||
info := &arch.SignalInfo{
|
||||
func SignalInfoNoInfo(sig linux.Signal, sender, receiver *Task) *linux.SignalInfo {
|
||||
info := &linux.SignalInfo{
|
||||
Signo: int32(sig),
|
||||
Code: arch.SignalInfoUser,
|
||||
Code: linux.SI_USER,
|
||||
}
|
||||
info.SetPID(int32(receiver.tg.pidns.IDOfThreadGroup(sender.tg)))
|
||||
info.SetUID(int32(sender.Credentials().RealKUID.In(receiver.UserNamespace()).OrOverflow()))
|
||||
|
||||
@@ -22,7 +22,6 @@ import (
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/bpf"
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/fs"
|
||||
"gvisor.dev/gvisor/pkg/sentry/inet"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
||||
@@ -395,7 +394,7 @@ type Task struct {
|
||||
// ptraceSiginfo is analogous to Linux's task_struct::last_siginfo.
|
||||
//
|
||||
// ptraceSiginfo is protected by the TaskSet mutex.
|
||||
ptraceSiginfo *arch.SignalInfo
|
||||
ptraceSiginfo *linux.SignalInfo
|
||||
|
||||
// ptraceEventMsg is the value set by PTRACE_EVENT stops and returned to
|
||||
// the tracer by ptrace(PTRACE_GETEVENTMSG).
|
||||
|
||||
@@ -31,7 +31,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
"gvisor.dev/gvisor/pkg/sentry/arch"
|
||||
"gvisor.dev/gvisor/pkg/sentry/kernel/auth"
|
||||
"gvisor.dev/gvisor/pkg/syserror"
|
||||
"gvisor.dev/gvisor/pkg/waiter"
|
||||
@@ -140,12 +139,12 @@ func (t *Task) killLocked() {
|
||||
if t.stop != nil && t.stop.Killable() {
|
||||
t.endInternalStopLocked()
|
||||
}
|
||||
t.pendingSignals.enqueue(&arch.SignalInfo{
|
||||
t.pendingSignals.enqueue(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGKILL),
|
||||
// Linux just sets SIGKILL in the pending signal bitmask without
|
||||
// enqueueing an actual siginfo, such that
|
||||
// kernel/signal.c:collect_signal() initializes si_code to SI_USER.
|
||||
Code: arch.SignalInfoUser,
|
||||
Code: linux.SI_USER,
|
||||
}, nil)
|
||||
t.interrupt()
|
||||
}
|
||||
@@ -350,7 +349,7 @@ func (t *Task) exitThreadGroup() bool {
|
||||
// signalStop must be called with t's signal mutex unlocked.
|
||||
t.tg.signalHandlers.mu.Unlock()
|
||||
if notifyParent && t.tg.leader.parent != nil {
|
||||
t.tg.leader.parent.signalStop(t, arch.CLD_STOPPED, int32(sig))
|
||||
t.tg.leader.parent.signalStop(t, linux.CLD_STOPPED, int32(sig))
|
||||
t.tg.leader.parent.tg.eventQueue.Notify(EventChildGroupStop)
|
||||
}
|
||||
return last
|
||||
@@ -371,7 +370,7 @@ func (t *Task) exitChildren() {
|
||||
continue
|
||||
}
|
||||
other.signalHandlers.mu.Lock()
|
||||
other.leader.sendSignalLocked(&arch.SignalInfo{
|
||||
other.leader.sendSignalLocked(&linux.SignalInfo{
|
||||
Signo: int32(linux.SIGKILL),
|
||||
}, true /* group */)
|
||||
other.signalHandlers.mu.Unlock()
|
||||
@@ -386,9 +385,9 @@ func (t *Task) exitChildren() {
|
||||
// wait for a parent to reap them.)
|
||||
for c := range t.children {
|
||||
if sig := c.ParentDeathSignal(); sig != 0 {
|
||||
siginfo := &arch.SignalInfo{
|
||||
siginfo := &linux.SignalInfo{
|
||||
Signo: int32(sig),
|
||||
Code: arch.SignalInfoUser,
|
||||
Code: linux.SI_USER,
|
||||
}
|
||||
siginfo.SetPID(int32(c.tg.pidns.tids[t]))
|
||||
siginfo.SetUID(int32(t.Credentials().RealKUID.In(c.UserNamespace()).OrOverflow()))
|
||||
@@ -723,17 +722,17 @@ func (t *Task) exitNotifyLocked(fromPtraceDetach bool) {
|
||||
}
|
||||
|
||||
// Preconditions: The TaskSet mutex must be locked.
|
||||
func (t *Task) exitNotificationSignal(sig linux.Signal, receiver *Task) *arch.SignalInfo {
|
||||
info := &arch.SignalInfo{
|
||||
func (t *Task) exitNotificationSignal(sig linux.Signal, receiver *Task) *linux.SignalInfo {
|
||||
info := &linux.SignalInfo{
|
||||
Signo: int32(sig),
|
||||
}
|
||||
info.SetPID(int32(receiver.tg.pidns.tids[t]))
|
||||
info.SetUID(int32(t.Credentials().RealKUID.In(receiver.UserNamespace()).OrOverflow()))
|
||||
if t.exitStatus.Signaled() {
|
||||
info.Code = arch.CLD_KILLED
|
||||
info.Code = linux.CLD_KILLED
|
||||
info.SetStatus(int32(t.exitStatus.Signo))
|
||||
} else {
|
||||
info.Code = arch.CLD_EXITED
|
||||
info.Code = linux.CLD_EXITED
|
||||
info.SetStatus(int32(t.exitStatus.Code))
|
||||
}
|
||||
// TODO(b/72102453): Set utime, stime.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user