Commit Graph
5010 Commits
Author SHA1 Message Date
Lucas ManningandgVisor bot aa4e302c75 Automated rollback of changelist 558922801
PiperOrigin-RevId: 566731014
2023-09-19 13:46:56 -07:00
Etienne PerotandgVisor bot d3ddef3e73 Add ABI for keyctl(2).
PiperOrigin-RevId: 566711348
2023-09-19 12:37:33 -07:00
Etienne PerotandgVisor bot b82e8e1eba KVM: Remove _ prefix from KVM ioctl constants.
This is useful to be able to refer to them from external packages, such as
to represent the `ioctl(2)` syscall profile that the Sentry has with the
KVM platform.

PiperOrigin-RevId: 566705114
2023-09-19 12:14:19 -07:00
Ayush RanjanandgVisor bot 3aa66befb2 Handle arbitrarily large Fuse Dirent Namelen.
If FUSEDirent.Namelen is larger than the remaining payload size, then the
dirent is probably invalid. We should skip it.

PiperOrigin-RevId: 566678679
2023-09-19 10:48:35 -07:00
Ayush RanjanandgVisor bot c4e72d9e0e Remove peer credential check from control server.
The peer credential check worked by querying the peer's UID using SO_PEERCRED.
However, when sandbox is configured with custom UID/GID mappings, which it is
in the following situations:
1. When not using directfs, sandbox has a mapping of only `65534:65534:1`. So
   all other non-65534 UIDs are unmmaped.
2. When using directfs with userns-remap. The sandbox has the same UID/GID
   mapping as the container.

In these cases, when the root user tries to connect, the host root user is not
mapped. Unmapped IDs are translated to overflowuid/gid, which happens to
default to 65534. This leads to unexpected results:
- Without directfs, this check allows any connection, because sandbox is also
  running as nobody/65534.
- In the directfs+userns-remap case, all connections are denied.

This check doesn't really enforce anything. Hence remove it.

The real enforcement mechanism is the file mode of the unix domain socket over
which the connection happens. The socket file's mode depends on umask, which
defaults to 022. Hence only the user which creates the sandbox via
`runsc create` has write permission on this socket. So only the sandbox creator
or root can connect to the sandbox, as intended.

Fixes #9356

PiperOrigin-RevId: 565836818
2023-09-15 19:44:22 -07:00
Ayush RanjanandgVisor bot bea6d33185 Add state:"nosave" annotation to nvproxy.objsMu.
With this, checkpoint command succeeds on nvproxy containers.

Updates #9363.

PiperOrigin-RevId: 565786118
2023-09-15 14:58:29 -07:00
guangwuandGitHub 0fdab343da fix: successfully typo 2023-09-15 14:47:10 +08:00
Ayush RanjanandgVisor bot 31084cca90 Handle large control socket paths.
UDS connect and bind fail when the socket path being used is more than 107 in
length. Shorten the path using procfs: "/proc/self/fd/{parentFD}/{sockName)"

This avoids falling back to using abstract sockets in some instances.

Suggested-by: Andrei Vagin <[email protected]>
PiperOrigin-RevId: 565557006
2023-09-14 20:56:26 -07:00
Lucas ManningandgVisor bot 98450b2895 Change namespace cloning so that it clones mounts depth-first.
This saves on allocations.

This change is a subset of the changes in cl/563529897 and cl/563752003.
Committing this change in more discrete parts will help narrow down the
causes of b/299603749.

PiperOrigin-RevId: 565484026
2023-09-14 14:53:26 -07:00
Jamie LiuandgVisor bot 21e36bacfc cgroupfs: do not return errors from strconv.ParseInt() to write()
Arbitrary errors are not convertible to errnos for syscall return and cause the
sentry to panic.

PiperOrigin-RevId: 564782206
2023-09-12 11:29:05 -07:00
Ayush RanjanandgVisor bot c5b6d99fff Rollback c8d23ad2a4 and f36ba56090.
Syzkaller is reporting crashes relating to changes made by these commits.
Rolling back for now. Should be rolled forward with fix.

Reported-by: [email protected]
PiperOrigin-RevId: 564000728
2023-09-09 06:50:38 -07:00
Ayush RanjanandgVisor bot 125b741d86 Return user_mss if user_mss is set and socket is unconnected.
Has the same effect as Linux commit 34dfde4ad87b ("tcp: Return user_mss for
TCP_MAXSEG in CLOSE/LISTEN state if user_mss set").

Updated test to accept both values (default and user set) so test works on
newer and older kernels.

PiperOrigin-RevId: 563844012
2023-09-08 13:57:42 -07:00
Lucas ManningandgVisor bot f36ba56090 Fix cwd/root update method during namespace cloning.
The previous implementation incorrectly assumed order would be preserved
in the map.

Reported-by: [email protected]
PiperOrigin-RevId: 563529897
2023-09-07 13:37:20 -07:00
Jing ChenandgVisor bot 6cbd7dbd93 Let devices cgroup add/remove rules via devices.allow and devices.deny.
PiperOrigin-RevId: 563261158
2023-09-06 17:27:02 -07:00
Lucas ManningandgVisor bot c8d23ad2a4 Abstract mount tree cloning into its own mount method.
When copying a mount tree, new child mounts are added to a mount's
pending list. Each of these mounts has its pending mountpoint already set
with setKey. Eventually this method will be used to enable recursive binds.

PiperOrigin-RevId: 563236298
2023-09-06 15:43:02 -07:00
gVisor bot a423565638 Merge pull request #9339 from kevinGC:tcsetsf2
PiperOrigin-RevId: 563207341
2023-09-06 13:58:08 -07:00
gVisor bot 3155f15acd Merge pull request #9336 from thundergolfer:jonathon/dev-pts-eof-handling
PiperOrigin-RevId: 563199056
2023-09-06 13:29:19 -07:00
Jing ChenandgVisor bot 090d92a726 Have lgetxattr return ENODATA.
It is a workaround to lgetxattr/lsetxattr working with security.capacity when running docker in gvisor.

PiperOrigin-RevId: 563194162
2023-09-06 13:13:19 -07:00
gVisor bot faebee65d0 Merge pull request #9327 from kevinGC:benchmarkxdp
PiperOrigin-RevId: 563182220
2023-09-06 12:30:10 -07:00
Lucas ManningandgVisor bot e7a86ddc32 Split the ring implementation into its own package.
The ring data structure's requires it's own implementation of Entry. With
the new version you can more easily be part of multiple rings at once. Also,
a user who wants to use ilist probably doesn't need ring as well, so it makes
sense to separate the two.

PiperOrigin-RevId: 563151782
2023-09-06 10:54:41 -07:00
Nicolas LacasseandgVisor bot fd8f39c53b Emit SentryTcpListenEvent when the application listens on a tcp port.
PiperOrigin-RevId: 562957239
2023-09-05 19:15:45 -07:00
Jonathon Belotti 7d9e612057 Fix EOF (^D) handling in devpts (partially addr #9333) 2023-09-06 01:18:18 +00:00
Kevin Krakauer dbbce69479 tty: enable TCSETSF
While there is a difference between flavors of this ioctl (`TCSETS`,
`TCSETSF`, `TCSETSW`), in practice it seems not to matter. We should let
users call `TCSETSF` and can implement those differences if necessary.
2023-09-05 09:53:50 -07:00
Kevin Krakauer 7c236fdb07 netstack: benchmark xdp endpoint
This just swaps out the fdbased endpoint for an XDP one. Some related
changes in here:

- Moved the AF_XDP BPF program into its own Go package so it can be
  shared.
- Added a flag to tcp_benchmark to disable user namespaces. This helps
  when running as root, which is required to install BPF programs.
2023-08-31 11:09:15 -07:00
Nicolas LacasseandgVisor bot 69e6fcb515 tmpfs: Allow non-standard xattr prefixes.
PiperOrigin-RevId: 561105602
2023-08-29 12:31:01 -07:00
Konstantin BogomolovandgVisor bot 832a40527a Add profiling metric flags to output metric data to local TSV file.
The idea behind conditionally compiled metrics originally was to use them in
hotpaths for profiling purposes. This CL makes that possible by outputting
declared metrics in TSV format, which can be used to track custom events at
runtime in relatively high resolution.

Usage:
    1. Optionally enable compilation of runsc conditionally-compiled metrics
       by passing in condmetric_profiling to the Go tags.
    2. Add these flags to runsc:
    - [Required] --profiling-metrics-log=/tmp/some.csv
    - [Optional] --profiling-metrics=/task/syscalls,/task/faults
      - If this flag is not specified it will monitor all
        conditionally-compiled metrics by default.
    - [Optional] --profiling-metrics-rate-us=10000

Some future improvements:
    - Flag to output a metric-difference between timestamps instead of
      constant accumulation.
    - Output a gnuplot command along with the data.
    - Current monitoring resolution is limited by what time.Sleep allows.
      This can be overcome by spinning/yielding when lower monitoring
      rates are requested.

PiperOrigin-RevId: 560849611
2023-08-28 16:28:09 -07:00
Jing ChenandgVisor bot e3f7443b9b Support MS_STRICTATIME flag for the syscall mount.
PiperOrigin-RevId: 560207305
2023-08-25 15:17:23 -07:00
Ayush RanjanandgVisor bot 9f33f6b80e Make vfs.PopDelayedDecRefs() clear vfs.toDecRef.
This issue was reported by Syzkaller. The stacktrace shows
forgetDeadMountpoint(..., skipDecRef=true) being called. But unlockMounts()
is still shown DecRef()-ing the objects. PopDelayedDecRefs() should be clearing
vfs.toDecRef.

Also make gofer.dentry.evictLocked() DecRef the returned objects. It was
ignoring the return value earlier.

Reported-by: [email protected]
PiperOrigin-RevId: 560164788
2023-08-25 12:25:40 -07:00
Shambhavi SrivastavaandgVisor bot 884e65cf41 Automated rollback of changelist 557871250
PiperOrigin-RevId: 560158129
2023-08-25 11:58:29 -07:00
Andrei VaginandgVisor bot 9cb9a05aee proc: add /proc/{bus,fs,irq,sysrq-trigger}
Docker fails starting a container without these paths. All of them are
enumerated in readonlyPaths of a container spec.

PiperOrigin-RevId: 559984658
2023-08-24 22:59:41 -07:00
Andrei VaginandgVisor bot e2fc34862a proc: add /proc/sys/kernel/cap_last_cap
PiperOrigin-RevId: 559932636
2023-08-24 18:29:31 -07:00
Kevin KrakauerandgVisor bot 64c7809b4d netstack: refactor IPv4 source address selection
This was in the wrong place. This CL just refactors it into package ipv4, just
as IPv6-specific logic is in package ipv6.

PiperOrigin-RevId: 558922801
2023-08-21 15:54:10 -07:00
Lucas ManningandgVisor bot caf6dab234 Add a method for automatically DecRef'ing objects outside of mountMu.
PiperOrigin-RevId: 558912220
2023-08-21 15:14:06 -07:00
gVisor bot 98dba7403a Merge pull request #9296 from 0o001:master
PiperOrigin-RevId: 558853603
2023-08-21 11:42:48 -07:00
Andrei VaginandgVisor bot 6c040e7bf1 nsfs: mark inodes as anonymous
They don't have parents.

Reported-by: [email protected]
PiperOrigin-RevId: 558534816
2023-08-20 02:29:13 -07:00
Jing ChenandgVisor bot 606462c738 Add device cgroup's devices.list, which defaults to allow all.
PiperOrigin-RevId: 558534572
2023-08-20 02:20:04 -07:00
Nicolas LacasseandgVisor bot 957ef2f885 Refactor fdimport.Import and read host fd flags before importing.
PiperOrigin-RevId: 558269013
2023-08-18 15:59:33 -07:00
Kevin KrakauerandgVisor bot 50dcf94fb0 netstack: fix test bug using wrong address family
TestPreflightBindsEndpoint was using an IPv6 destination address with an IPv4
endpoint. This starts causing a panic once we properly check the length of
addresses (see child CL).

PiperOrigin-RevId: 558267882
2023-08-18 15:51:17 -07:00
Andrei VaginandgVisor bot f556917137 vfs: MountNamespace.Root() has to return a top mount of /
A few mounts can be mounted on top of `/`.

PiperOrigin-RevId: 558264274
2023-08-18 15:35:47 -07:00
Mustafa Uzun a307331ec2 fix: rename dumpErrorMesage and dumpAckMessage functions 2023-08-18 10:46:02 +03:00
Lucas ManningandgVisor bot 94441a6e26 Fix small mount propagation bug.
The MS_PRIVATE flag was not being cleared in addPeer.

Reported-by: [email protected]
PiperOrigin-RevId: 557949154
2023-08-17 15:14:15 -07:00
Kevin KrakauerandgVisor bot e14c91efba netstack: use longest prefix match to choose IPs on a NIC
Once a NIC is chosen for a route, we currently just grab the first IP on the
NIC as the source address. We should choose the address with the longest
matching prefix instead.

This is a simple linear search of the route table. That's slow for large
tables, but large tables are exceedingly rare for use with gVisor and we can
always reimplement this with a trie if it becomes necessary.

PiperOrigin-RevId: 557941259
2023-08-17 14:45:53 -07:00
Jing ChenandgVisor bot 9a79dec6f1 Implement SO_SNDTIMEO and SO_RCVTIMEO for netlink's setsockopt and getsockopt.
PiperOrigin-RevId: 557933811
2023-08-17 14:18:15 -07:00
Nayana BidariandgVisor bot 3995928c06 Add GetMemoryUsage() API to the gVisor sandbox.
Adds GetMemoryUsage() API to get the memory usage of the containers.

PiperOrigin-RevId: 557923509
2023-08-17 13:43:56 -07:00
Shambhavi SrivastavaandgVisor bot 76b2713c08 Adding /proc/[pid]/task/[tid]/children
PiperOrigin-RevId: 557888186
2023-08-17 11:41:48 -07:00
Nicolas LacasseandgVisor bot 5dc1f9fa34 Automated rollback of changelist 554554034
PiperOrigin-RevId: 557871250
2023-08-17 10:50:10 -07:00
Andrei VaginandgVisor bot 2b9d893bab Mount has to follow symlinks when it resolves target
For example, docker specifies a directory descriptor via /proc/self/fd:
mount(/sys/fs/cgroup/...", "/proc/self/fd/6", MS_BIND, 0x502f, <null>)

PiperOrigin-RevId: 557312955
2023-08-15 18:26:45 -07:00
Lucas ManningandgVisor bot 14e0833da8 Refactor and simplify propagation logic.
This refactor changes the "shared list" from being a list pointer that's
shared among all the peers, to a circularly linked list that links all the
mounts together. This is generally safer (no shared pointer) and easier
to understand and work with. It's also closer to how linux implements this
feature.

The propagationType is also removed in favor of just using the propagation
flags from linux. This makes more sense as mounts can have two types at once
(shared+slave).

PiperOrigin-RevId: 556906544
2023-08-14 14:10:56 -07:00
Jing ChenandgVisor bot 6e7a49f314 Add missing device cgroups.
PiperOrigin-RevId: 556053561
2023-08-11 12:48:03 -07:00
gVisor bot 81068492ea Merge pull request #9146 from sitano:ivan_nocompressio
PiperOrigin-RevId: 555750100
2023-08-10 19:19:42 -07:00