88 Commits
Author SHA1 Message Date
Nicolas LacasseandgVisor bot 876de08e59 Fix strace logging for AF_UNIX sockets.
This was broken in commit 64268c8, which moved parsing of addresses for
AF_UNIX sockets to the socket/unix package.

While we're here, add strace support for AF_PACKET sockets, since
socket.AddressAndFamily can already decode their address.

PiperOrigin-RevId: 661391690
2024-08-09 13:54:10 -07:00
Jonathon Belotti e995c0934a add strace dbg processing for 'faccessat2' 2024-05-08 14:37:13 +00:00
Nicolas LacasseandgVisor bot b667130795 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
Kevin KrakauerandgVisor bot 64268c8483 netstack: make tcpip.Address an opaque type
The important change here is in tcpip/tcpip.go, where tcpip.Address is defined.
The rest is updating uses of tcpip.Address.

This is preparation for netip.Addr or []byte based addresses, which should save
us a bunch of allocations. Currently, we allocate every time we want to, say,
get a tcpip.Address from a header. This is because the header is a byte slice,
but Address is a string. Strings are immutable, so Go allocates and copies.

PiperOrigin-RevId: 532284732
2023-05-15 18:07:03 -07:00
Nicolas LacasseandgVisor bot f37b20c011 hostinet: Support ping and raw sockets.
PiperOrigin-RevId: 513902015
2023-03-04 00:40:01 -08:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Nicolas LacasseandgVisor bot 753fb9ac5e Fix (most of) tcp_socket_test on hostinet.
A few fixes in here:

* Linux does not transition the state of a non-blocking socket to SS_CONNECTED
  when the connect happens asynchronously. Instead, it leaves the state as
  SS_CONNECTING (seems like a Linux bug, but OK). This can introduce weird
  behavior for subsequent connect() calls. gVisor now forces the state to
  update to SS_CONNECTED by calling connect() twice.

* Socket shutdown events are slightly different between gVisor and linux. We
  already assert different behavior between the two environments, and now we
  also have to check for gVisor+hostinet instead of just gvisor.

* Handle send/recv timeouts, which fixes blocking for read()/write() syscalls.

* Handle cases like MSG_PEEK where the senderAddress is not returned.

* Pass through some more socketopts, and allow them in the syscall filters.

Something is still wrong with shutdown() and poll() calls, so those tests are
temporarily disabled. I'm looking at those next.

This also fixes a number of other syscall test suites, so those are enabled as
well.

PiperOrigin-RevId: 508397317
2023-02-09 09:39:26 -08:00
Ayush RanjanandgVisor bot 1fa3c06f1e Delete VFS1 completely.
- Delete pkg/sentry/fs/*.
- Move pkg/sentry/fs/fsutil out of VFS1 directory and remove VFS1 components.
- Remove remaining unused references to VFS1 from remaining codebase.
- Rename/refactor code to avoid even referencing VFS2, unless necessary.
- Rewrite VFS1-only tests to VFS2.

Updates #1624

PiperOrigin-RevId: 490064269
2022-11-21 13:57:52 -08:00
Kevin KrakauerandgVisor bot d8aa09e04c convert uses of interface{} to any
Done via:
  find . -name "*.go" | xargs sed -i -E 's/interface\{\}/any/g'

PiperOrigin-RevId: 487033228
2022-11-08 13:14:06 -08:00
Ayush RanjanandgVisor bot 020df37be7 Start cleaning up VFS1.
PiperOrigin-RevId: 486586072
2022-11-07 00:39:54 -08:00
Ayush RanjanandgVisor bot c1111baf6c Allow strace logs for symlinkat(2) to print FD.
Helps with debugging issues that involve symlinkat(2). FD also
prints the path file that the FD backs which is helpful.

PiperOrigin-RevId: 456849268
2022-06-23 13:34:31 -07:00
Ayush RanjanandgVisor bot c7690e05c1 Add option to hide application data in strace logs.
This is helpful in disabling printing sensitive application data when strace is
enabled.

PiperOrigin-RevId: 451946198
2022-05-30 19:52:27 -07:00
Konstantin BogomolovandgVisor bot 5c95e1d39c Implement close_range.
Fixes #5500

PiperOrigin-RevId: 431454836
2022-02-28 09:37:03 -08:00
Ayush RanjanandgVisor bot ce4f4283ba Make {Un}Marshal{Bytes/Unsafe} return remaining buffer.
Change marshal.Marshallable method signatures to return the remaining buffer.
This makes it easier to implement these method manually. Without this, we would
have to manually do buffer shifting which is error prone.

tools/go_marshal/test:benchmark test does not show change in performance.
Additionally fixed some marshalling bugs in fsimpl/fuse.

Updated multiple callpoints to get rid of redundant slice indexing work and
simplified code using this new signature.

Updates #6450

PiperOrigin-RevId: 407857019
2021-11-05 10:43:49 -07:00
Andrei VaginandgVisor bot 9fff9469a2 kernel: print PID in addition to TID in task log messages
For multithreads processes, it is hard to read logs without knowing task pids.

And let's print a decimal return codeo for syscalls. A hex return code are
usefull for system calls that return addresses. For other syscalls, the decimal
form is more readable.

PiperOrigin-RevId: 400035449
2021-09-30 15:07:28 -07:00
Jamie LiuandgVisor bot 1ad3822200 Add go:build directives as required by Go 1.17's gofmt.
PiperOrigin-RevId: 385894869
2021-07-20 16:28:45 -07:00
Fabricio VoznikaandgVisor bot 85a0a353ad Replace whitelist with allowlist
PiperOrigin-RevId: 384586164
2021-07-13 17:20:41 -07:00
Fabricio VoznikaandgVisor bot 3d4a8824f8 Strace: handle null paths
PiperOrigin-RevId: 382603592
2021-07-01 14:23:01 -07:00
Fabricio VoznikaandgVisor bot 8d426b7381 Parse mmap protection and flags in strace
PiperOrigin-RevId: 378712518
2021-06-10 12:51:43 -07:00
Ayush RanjanandgVisor bot 8d87a9418a [op] Move SignalAct to abi/linux package.
There were also other duplicate definitions of the same struct that I have now
removed.

Updates #214

PiperOrigin-RevId: 378579954
2021-06-09 22:53:41 -07:00
Jing ChenandgVisor bot eefa00f4ae Implement epoll_pwait2.
PiperOrigin-RevId: 371216407
2021-04-29 15:22:09 -07:00
Michael PrattandgVisor bot c03b380c2c Automated rollback of changelist 370733869
PiperOrigin-RevId: 371131985
2021-04-29 09:10:10 -07:00
Rahat MahmoodandgVisor bot f54d87b9ec Remove uses of the binary package from networking code.
Co-Author: ayushranjan
PiperOrigin-RevId: 370785009
2021-04-27 16:20:01 -07:00
Jing ChenandgVisor bot 9ec49aabd3 Fix SyscallInfo for epoll_pwait in strace.
PiperOrigin-RevId: 370733869
2021-04-27 12:08:19 -07:00
Zach KoopmansandgVisor bot 8a2f7e716d [syserror] Split usermem package
Split usermem package to help remove syserror dependency in go_marshal.
New hostarch package contains code not dependent on syserror.

PiperOrigin-RevId: 365651233
2021-03-29 13:30:21 -07:00