mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
gvisor: change syscall.RawSyscall to syscall.RawSyscall6 where required
Before https://golang.org/cl/173160 syscall.RawSyscall would zero out the last three register arguments to the system call. That no longer happens. For system calls that take more than three arguments, use RawSyscall6 to ensure that we pass zero, not random data, for the additional arguments. PiperOrigin-RevId: 271062527
This commit is contained in:
@@ -35,7 +35,7 @@ type sockFprog struct {
|
||||
//go:nosplit
|
||||
func SetFilter(instrs []linux.BPFInstruction) syscall.Errno {
|
||||
// PR_SET_NO_NEW_PRIVS is required in order to enable seccomp. See seccomp(2) for details.
|
||||
if _, _, errno := syscall.RawSyscall(syscall.SYS_PRCTL, linux.PR_SET_NO_NEW_PRIVS, 1, 0); errno != 0 {
|
||||
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PRCTL, linux.PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0, 0); errno != 0 {
|
||||
return errno
|
||||
}
|
||||
|
||||
|
||||
@@ -267,7 +267,7 @@ func (s *subprocess) newThread() *thread {
|
||||
|
||||
// attach attaches to the thread.
|
||||
func (t *thread) attach() {
|
||||
if _, _, errno := syscall.RawSyscall(syscall.SYS_PTRACE, syscall.PTRACE_ATTACH, uintptr(t.tid), 0); errno != 0 {
|
||||
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, syscall.PTRACE_ATTACH, uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("unable to attach: %v", errno))
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ func (t *thread) syscall(regs *syscall.PtraceRegs) (uintptr, error) {
|
||||
|
||||
for {
|
||||
// Execute the syscall instruction.
|
||||
if _, _, errno := syscall.RawSyscall(syscall.SYS_PTRACE, syscall.PTRACE_SYSCALL, uintptr(t.tid), 0); errno != 0 {
|
||||
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, syscall.PTRACE_SYSCALL, uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("ptrace syscall-enter failed: %v", errno))
|
||||
}
|
||||
|
||||
@@ -435,7 +435,7 @@ func (t *thread) syscall(regs *syscall.PtraceRegs) (uintptr, error) {
|
||||
}
|
||||
|
||||
// Complete the actual system call.
|
||||
if _, _, errno := syscall.RawSyscall(syscall.SYS_PTRACE, syscall.PTRACE_SYSCALL, uintptr(t.tid), 0); errno != 0 {
|
||||
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, syscall.PTRACE_SYSCALL, uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("ptrace syscall-enter failed: %v", errno))
|
||||
}
|
||||
|
||||
@@ -526,17 +526,17 @@ func (s *subprocess) switchToApp(c *context, ac arch.Context) bool {
|
||||
for {
|
||||
// Start running until the next system call.
|
||||
if isSingleStepping(regs) {
|
||||
if _, _, errno := syscall.RawSyscall(
|
||||
if _, _, errno := syscall.RawSyscall6(
|
||||
syscall.SYS_PTRACE,
|
||||
syscall.PTRACE_SYSEMU_SINGLESTEP,
|
||||
uintptr(t.tid), 0); errno != 0 {
|
||||
uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("ptrace sysemu failed: %v", errno))
|
||||
}
|
||||
} else {
|
||||
if _, _, errno := syscall.RawSyscall(
|
||||
if _, _, errno := syscall.RawSyscall6(
|
||||
syscall.SYS_PTRACE,
|
||||
syscall.PTRACE_SYSEMU,
|
||||
uintptr(t.tid), 0); errno != 0 {
|
||||
uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("ptrace sysemu failed: %v", errno))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ func probeSeccomp() bool {
|
||||
|
||||
for {
|
||||
// Attempt an emulation.
|
||||
if _, _, errno := syscall.RawSyscall(syscall.SYS_PTRACE, syscall.PTRACE_SYSEMU, uintptr(t.tid), 0); errno != 0 {
|
||||
if _, _, errno := syscall.RawSyscall6(syscall.SYS_PTRACE, syscall.PTRACE_SYSEMU, uintptr(t.tid), 0, 0, 0, 0); errno != 0 {
|
||||
panic(fmt.Sprintf("ptrace syscall-enter failed: %v", errno))
|
||||
}
|
||||
|
||||
@@ -266,7 +266,7 @@ func attachedThread(flags uintptr, defaultAction linux.BPFAction) (*thread, erro
|
||||
|
||||
// Enable cpuid-faulting; this may fail on older kernels or hardware,
|
||||
// so we just disregard the result. Host CPUID will be enabled.
|
||||
syscall.RawSyscall(syscall.SYS_ARCH_PRCTL, linux.ARCH_SET_CPUID, 0, 0)
|
||||
syscall.RawSyscall6(syscall.SYS_ARCH_PRCTL, linux.ARCH_SET_CPUID, 0, 0, 0, 0, 0)
|
||||
|
||||
// Call the stub; should not return.
|
||||
stubCall(stubStart, ppid)
|
||||
|
||||
Reference in New Issue
Block a user