13 Commits
Author SHA1 Message Date
Jamie LiuandgVisor bot d7996a5d9b Remove "AddressSpace activation".
PiperOrigin-RevId: 869302553
2026-02-12 14:55:06 -08:00
Nicolas LacasseandgVisor bot 98ef0b53fb pread/writev: Copy in iovecs outside of task.mu.
Copying in the iovecs requires acquiring mm.mappingRWMutex, which is above
task.mu in the lock ordering.

Instead of copying with task.CopyContext, we perform the copy with
MemoryManager.Copy{In,Out}. The MemoryManagers are 'pinned' with IncUser()
for the duration of the copy operations.

PiperOrigin-RevId: 725325325
2025-02-10 13:25:06 -08:00
Andrei VaginandgVisor bot 7488d2212e process_vm_{read,write}v returns EFAILT if iov-s describe inaccessible memory
PiperOrigin-RevId: 607482542
2024-02-15 15:58:29 -08:00
Andrei VaginandgVisor bot dc558ff6f9 Don't return EINTR from process_vm_{write,read}v syscalls
Just repeat the Linux behavior here.

PiperOrigin-RevId: 607463895
2024-02-15 14:54:13 -08:00
Jamie LiuandgVisor bot 0122c309aa Allow process_vm_{readv,writev} to target non-group-leader threads.
Also allow it to target exiting threads, which is consistently observable via
e.g. PTRACE_EVENT_EXIT; check remoteTask.MemoryManager() with remoteTask.mu
locked instead, which is consistent with Linux's
mm/process_vm_access.c:process_vm_rw_core() => kernel/fork.c:mm_access() and
avoids racing with remote task exit.

PiperOrigin-RevId: 599943619
2024-01-19 14:51:42 -08:00
Andrei VaginandgVisor bot b28cb3391c syscall: process_vm_* copies data by chunks
First, it avoids allocating a large buffer that can be costly.
Second, it allows to interrupt a system call in case of any signals.

PiperOrigin-RevId: 580721720
2023-11-08 17:59:08 -08:00
Nicolas LacasseandgVisor bot 9df8573281 The local task in process_vm_read|writev is just the calling task.
We were using t.ThreadGroup.Leader() as the local task, which led to data races
reading fields that are owned by the task goroutine. But there's no need to use
the Leader, so we just use the calling task everywhere.

PiperOrigin-RevId: 570826256
2023-10-04 15:25:09 -07:00
Nicolas LacasseandgVisor bot 58938f0051 Clean up and re-enable process_vm_readv/writev
Some fixes:

* First argument of Task.CopyContext should always be the context.Context
  derived from the currently running task, because it is used to get a
  CopyScratchBuffer, which must be from the current task. This solved a bunch
  of data races.

* Fix logic around which process is remote and which is local. These were
  getting mixed up.

* Always read iovec structs (local and remote) from the local process's address
  space, since they are syscall arguments. Only use the remote process address
  space to read the memory pointed to by the remote iovecs.

* Added ptrace permissions check, per linux.

* Delete unused code from kernel/task_usermem.go

* Rewrote tests so that we read to (write from) a subprocess, rather than the
  other way around. So we don't need CAP_PTRACE to run the tests.

* Also make tests async-signal-safe after call to fork(). I think this was the
  source of the flakyness on linux previously.

PiperOrigin-RevId: 570506366
2023-10-03 15:01:49 -07:00
Etienne PerotandgVisor bot da6948a692 gVisor: Refactor SyscallFn to take in the syscall number as argument.
This will be used to plumb the syscall number through to a counter metric that
exports the number of times an unimplemented syscall has been called.

Plenty of syscall implementations call `EmitUnimplementedEvent` for flags and
settings that are not implemented. With `sysno` available, they will be able
to plumb that bit of information through.

PiperOrigin-RevId: 518635831
2023-03-22 12:06:26 -07:00
Zach KoopmansandgVisor bot b2bdf961a6 Don't use other process's scratch buffer.
If we use the remote process's scratch buffer in process_vm_readv|writev
calls, we will get data races. Use the local task's scratch buffer always.

PiperOrigin-RevId: 491468904
2022-11-28 16:14:02 -08:00
Zach KoopmansandgVisor bot d40a81f27d Fix circular lock in process_vm_(read|write)v
PiperOrigin-RevId: 489582978
2022-11-18 16:11:21 -08:00
Zach KoopmansandgVisor bot abe3813b7f Re-enable process_vm_(read|write)v
PiperOrigin-RevId: 489298284
2022-11-17 13:50:43 -08:00
Ayush RanjanandgVisor bot d90d0743d3 Delete VFS1 syscall handlers.
Directly use VFS2 syscall handlers. No need to override VFS2 handlers.
Updates #1624

PiperOrigin-RevId: 488448348
2022-11-14 13:11:22 -08:00