Commit Graph
3108 Commits
Author SHA1 Message Date
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 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
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
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
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
Nicolas LacasseandgVisor bot 69e6fcb515 tmpfs: Allow non-standard xattr prefixes.
PiperOrigin-RevId: 561105602
2023-08-29 12:31:01 -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
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
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
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
Nicolas LacasseandgVisor bot 2ecc8d0f6e Create kernel.SendExternalSignalProcessGroup and use it in boot/loader.go
This will send a signal to all processes (ThreadGroups) in a ProcessGroup.

PiperOrigin-RevId: 555679773
2023-08-10 15:37:22 -07:00
Nayana BidariandgVisor bot eba9311640 Make changes for CgroupsReadControlFile method to get memory usage per cgroup.
- Adds methods to Enter, Leave and Migrate the tasks for memory controller.
- Update the memory cgroup id when the task enters and leaves the cgroups.

PiperOrigin-RevId: 555568875
2023-08-10 11:09:28 -07:00
Konstantin BogomolovandgVisor bot fb56496e82 systrap: Enable using xsaveopt.
PiperOrigin-RevId: 554906814
2023-08-08 12:33:59 -07:00
Shambhavi SrivastavaandgVisor bot f75fcdfa83 Implementing clone3
Updates #8585

PiperOrigin-RevId: 554554034
2023-08-07 12:19:32 -07:00
Jing ChenandgVisor bot 906efa4976 Implement setns CLONE_NEWUTS namespace type.
PiperOrigin-RevId: 554306089
2023-08-06 15:33:25 -07:00
Andrei VaginandgVisor bot c86b685f63 kernfs: set DenySpliceIn for DynamicBytesFD
DynamicBytesFD is used for cgroup and proc files. In Linux, these file systems
don't set splice_write callbacks.

Reported-by: [email protected]
PiperOrigin-RevId: 553818208
2023-08-04 08:45:42 -07:00
Andrei VaginandgVisor bot 988a2981dc kernel: GetMountNamespace has to check that mntns isn't nil
Reported-by: [email protected]
PiperOrigin-RevId: 553568085
2023-08-03 13:14:04 -07:00
Ayush RanjanandgVisor bot bdba8c6b69 Add NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS to nvproxy.
PiperOrigin-RevId: 553015606
2023-08-01 21:23:05 -07:00
Andrei VaginandgVisor bot 2d37d59eeb kernel: don't use atomic pointers for task.netns
task.netns is always changed from a task goroutine under task.mu.

It means that we can access it without any locks from a task goroutine
we don't need to increment a reference counter in such cases.

In all other cases, we need to take task.mu.

PiperOrigin-RevId: 552913323
2023-08-01 14:04:53 -07:00
Andrei VaginandgVisor bot 4af420d420 Implement setns for mount namespaces
PiperOrigin-RevId: 552859231
2023-08-01 11:12:29 -07:00
Jing ChenandgVisor bot 4e5d1c16a5 Add devices cgroups which is partially implemented. It could export the device cgroups to devices.deny and devices.allow, add/remove device cgroups rules will need to be implemented to fully support device cgroups.
PiperOrigin-RevId: 552673967
2023-07-31 21:22:07 -07:00
Andrei VaginandgVisor bot 4d39b66860 Implement mount namespaces
This change implements only the basic functions of mount namespaces.
All features that depends on user namespaces will be implemented separately.

PiperOrigin-RevId: 552673896
2023-07-31 21:12:21 -07:00
Lucas ManningandgVisor bot 08d4cc54a0 Issue a panic in the case of a failed mount promise.
Failing to resolve a mount promise is never expected behavior. The
sandbox should crash in this case, since something has gone
fatally wrong.

PiperOrigin-RevId: 552652799
2023-07-31 18:57:25 -07:00
Lucas ManningandgVisor bot bc842b0f12 Implement accel fd methods and gasket ioctls.
The implementation of memory mapping and interrupt registration is
very similar to what's already been done for nvproxy.

PiperOrigin-RevId: 552644264
2023-07-31 18:05:28 -07:00