107 Commits
Author SHA1 Message Date
DonsonandHanzo Dev 80aad0dee6 docs(seccomp): correct syscall compatibility status
Mark seccomp as partially supported on amd64 and arm64 and document the accepted operation and flags.

Fixes #14627

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-08 11:01:05 +08:00
gVisor bot 84e2a9076c Merge pull request #14103 from relkochta:relkochta/openat2
PiperOrigin-RevId: 974743571
2026-09-01 15:37:45 -07:00
Derek MurrayandgVisor bot bf38f77dc7 Implement the copy_file_range(2) syscall.
gVisor returned `ENOSYS` for `copy_file_range(2)`, causing toolchains and
runtimes without fallback paths (such as Zig during linker output generation)
to fail inside sandboxes.

Implement `copy_file_range` as a generic buffered copy in the Sentry to
maintain backing filesystem independence and avoid widening the Sentry seccomp
filter. Argument validation and error handling mirror Linux kernel
`fs/read_write.c` semantics, including offset range checks, cross-device copy
support, and same-file overlap detection.

Add `copy_file_range_test` covering offset handling, short copies, overlap
detection, and Linux errno parity across runsc platforms.

PiperOrigin-RevId: 973465473
2026-08-30 08:41:32 -07:00
Ryan El Kochta efb3bcd85f Implement openat2(2) in gVisor
Seems that GNU tar extraction has been broken in gVisor since 75b03fd
(11/15/2025), which started using openat2(2) to address CVE-2025-45582.

tar uses openat2(2) for the RESOLVE_BENEATH flag which allows scoping
the path resolution underneath the specified dirfd.

This commit implements openat2(2) in gVisor, with support for all flags
supported by Linux: RESOLVE_BENEATH, RESOLVE_IN_ROOT, RESOLVE_CACHED,
RESOLVE_NO_MAGICLINKS, RESOLVE_NO_SYMLINKS, and RESOLVE_NO_XDEV.

This commit also introduces VirtualFilesystem.renameSeq, a global
sequence counter that along with mountSeq detects mount or rename
operations that race with scoped traversals.

A final "resolved-path-is-under-dirfd" check is performed after
the traversal. This is for two reasons: (1) in case of a bug in
any of the above logic, or (2) in case of an (extremely unlikely)
attack where mountSeq overflows by exactly 2^32 during a path
resolution. Unfortunately, due to the way path traversal in gVisor
is tightly coupled to the operation being performed by a VFS method,
using scoped traversals in an operation that *mutates* anything will
be difficult, since without major refactoring, the check must happen
after the side effect has taken place.

Currently, Linux only exposes scoped traversals through openat2(2),
so destroying the created fd is all we need to do if the final check
fails. (As a result of this limitation, most VFS functions have been
modified to reject scoped traversals "just-in-case".)

The RESOLVE_NO_XDEV implementation has a slight divergence from
Linux. It is a bit looser, permitting absolute symlinks in any case
where the root dentry's mount matches the mount the traversal is
locked to. Linux's behavior here is likely a bug, and since we can
safely be *more* permissive, there's not much reason to match it.

This commit also adds syscall tests and an strace formatter for
openat2(2).
2026-08-21 10:34:56 -07:00
Ayush RanjanandAlessio Ricci Toniolo be94182107 Add AWS EFA support to rdmaproxy
Add an efaproxy driver plug-in for AWS Elastic Fabric Adapter (EFA) devices
bound to the host `efa` driver. EFA's driver-private uverbs ABI carries no
userspace buffer pointers on CQ/QP CREATE: queue memory is kernel-allocated
and handed back via mmap keys in the CREATE response, which the core already
forwards to the host FD verbatim. PrepareCreateDMA is therefore a no-op; the
plug-in exists to register the "efa" driver name and to model EFA's MR_QUERY
driver-namespace method (used by libfabric to fetch RDMA read/write
interconnect IDs).

Model the standard AH object's destroy method (UVERBS_OBJECT_AH): EFA (SRD)
creates address handles via the legacy write path and destroys them through
the modern object, which the core must allow.

Extend the virtual RDMA sysfs for libfabric/hwloc topology discovery:
  - device/driver symlink and /sys/bus/pci/drivers/<driver> tree, which
    libfabric's EFA provider resolves during device discovery.
  - Mirror each PCI node's raw config space ("config" file). hwloc (used by
    aws-ofi-nccl to build the NCCL topology) reads it to recover the PCI
    bridge bus-number registers; without it hwloc cannot reconstruct the
    bridge hierarchy and aws-ofi-nccl aborts its topology write.
  - Serve the per-port lid_mask_count attribute alongside the other port
    attributes libibverbs reads from sysfs; ib_core creates it on every
    port.
The sysfs integration tests cover the new driver tree and config mirroring.

Advertise a >= 5.12 kernel release in RDMA-enabled sandboxes so aws-ofi-nccl
enables dmabuf-based GPU memory registration (ibv_reg_dmabuf_mr), which the
proxy handles via the existing REG_DMABUF_MR path. Sandboxes without RDMA
keep the current 4.19 release to limit the bump's blast radius; a later
change can make the newer release the default.

Co-authored-by: Alessio Ricci Toniolo <[email protected]>
2026-08-15 01:24:30 +00:00
Ryan El Kochta 00d76e630f Add stub for the bpf(2) syscall and cgroup eBPF programs.
Adds initial scaffolding for eBPF in gVisor. It implements the bpf(2) syscall
with support for BPF_PROG_LOAD, BPF_PROG_QUERY, and BPF_PROG_ATTACH.

Necessary for the cgroups v2 flag to be enabled by default, as this fixes
Docker-in-gVisor with cgroups v2.
2026-07-31 15:55:57 -07:00
Xin ZhongandgVisor bot c35a9ff00a seccheck: support ptrace request extraction via syscall points
PiperOrigin-RevId: 953109282
2026-07-23 20:43:59 -07:00
Xin ZhongandgVisor bot ed5e3a44cd seccheck: Add trace point for the listen(2) syscall.
This change implements the PointListen trace point to capture details of the
listen syscall, including the file descriptor, backlog, socket family,
socket type, and bound address. It also updates the seccheck metadata for
amd64 and arm64, adds the Listen protobuf message, and includes test coverage.

PiperOrigin-RevId: 952916092
2026-07-23 13:13:25 -07:00
Shailend ChandandgVisor bot e3b85191b4 Support cgroup namespaces
cgroup namespaces are non hierarchical and they are defined primarily by a
"root" cgroup node. The init cgroup namespaces's root node is the true root of
the (only) cgroup2fs tree. The root node of other cgroup namespaces is the
cgroup node of the task at the time of namespace creation.

Residing in a cgroup namespace affects tasks this way:

1) The views into /proc/[pid]/cgroup and the "root" field under
   /proc/[pid]/mountinfo are virtualized: they are rendered relative to the
   reading task's cgroupns.

2) mount()ing a cgroup2 fs furnishes only a subtree of the full cgroup2fs
   tree, rooted at the "root" cgroup of the hosting cgroupns.

Fixes #11989

PiperOrigin-RevId: 948882249
2026-07-16 04:04:38 -07:00
Xin ZhongandgVisor bot 164b417225 Add seccheck point for mmap(2).
This change introduces a seccheck point for the mmap syscall on both amd64 and
arm64. A new proto message `Mmap` is defined to capture the syscall arguments,
including the file descriptor path when requested. The example seccheck server
is updated to handle the new message type, and a basic test case is added to
the trace tests.

PiperOrigin-RevId: 947914706
2026-07-14 14:45:56 -07:00
Ryan El KochtaandgVisor bot 6d0da34f53 stub implementations for schedattr and ioprio syscalls
Adds stub implementations for:
- sched_setattr(2)
- sched_getattr(2)
- ioprio_set(2)
- ioprio_get(2)

"Support" (with no effect) is included for SCHED_OTHER (referred to in Linux
as SCHED_NORMAL), SCHED_BATCH, and SCHED_IDLE. sched_getscheduler(2) and
sched_setscheduler(2) are updated to support all three as well.

For ioprio_set, the configured I/O priority has no effect.

PiperOrigin-RevId: 938270335
2026-06-25 17:07:37 -07:00
gVisor bot f33984e40e Merge pull request #13388 from relkochta:relkochta/opentreeimpl
PiperOrigin-RevId: 931380869
2026-06-12 16:06:09 -07:00
Ryan El KochtaandgVisor bot 595d7505da New mount API: implement fsopen(2), fsconfig(2), fsmount(2), move_mount(2).
The first step in implementing the new file-descriptor based mount API in
gVisor. A "filesystem creation context" is created using fsopen(). The context
is then configured using fsconfig(), and the FSCONFIG_CMD_CREATE command is
used to create a filesystem. A "mount object" can be obtained using fsmount(),
which can be operated on directly using the *at() functions or mounted onto the
real directory tree using move_mount().

The current implementation has the following limitations:
- Linux passes configuration options to filesystems on-the-fly as fsopen() and
  fsconfig() are called, allowing per-parameter error handling. gVisor
  currently queues up all options and passes them to the filesystem all-at-once
  when FSCONFIG_CMD_CREATE occurs. Lifting this will require refactoring the
  option parsing for all existing filesystems.
- Only flag and string arguments to fsconfig() are supported.
- FSCONFIG_CMD_RECONFIGURE is not supported.
- move_mount(): flags MOVE_MOUNT_SET_GROUP and MOVE_MOUNT_BENEATH are not
  supported.
- The filesystem context message retrieval interface is not supported.

In the interest of review size, there is no implementation yet for
mount_setattr(2), open_tree(2), or fspick(2).

PiperOrigin-RevId: 931245256
2026-06-12 11:28:09 -07:00
Etienne PerotandgVisor bot 6b795d59fe Implement personality(2) for no-op personality bits.
PiperOrigin-RevId: 928825123
2026-06-08 16:13:59 -07:00
Ryan El Kochta 227a89ead0 Implement open_tree(2) 2026-06-08 12:37:33 -07:00
Ryan El KochtaandgVisor bot 36feca5ce1 New mount API: implement fsopen(2), fsconfig(2), fsmount(2), move_mount(2).
The first step in implementing the new file-descriptor based mount API in
gVisor. A "filesystem creation context" is created using fsopen(). The context
is then configured using fsconfig(), and the FSCONFIG_CMD_CREATE command is
used to create a filesystem. A "mount object" can be obtained using fsmount(),
which can be operated on directly using the *at() functions or mounted onto the
real directory tree using move_mount().

For compatibility reasons, the new mount API is gated behind the runtime flag
`--new-mount-api`, which is disabled by default.

The current implementation has the following limitations:
- Linux passes configuration options to filesystems on-the-fly as fsopen() and
  fsconfig() are called, allowing per-parameter error handling. gVisor
  currently queues up all options and passes them to the filesystem all-at-once
  when FSCONFIG_CMD_CREATE occurs. Lifting this will require refactoring the
  option parsing for all existing filesystems.
- Only flag and string arguments to fsconfig() are supported.
- FSCONFIG_CMD_RECONFIGURE is not supported.
- move_mount(): flags MOVE_MOUNT_SET_GROUP and MOVE_MOUNT_BENEATH are not
  supported.
- The filesystem context message retrieval interface is not supported.

In the interest of review size, there is no implementation yet for
mount_setattr(2), open_tree(2), or fspick(2).

PiperOrigin-RevId: 923640824
2026-06-08 10:14:39 -07:00
Shailend ChandandgVisor bot 416a279cf2 clone: Honor CLONE_PARENT
Thus far we were silently ignoring this flag.

While writing the syscall test for this change I realized that we were
using the async-signal-unsafe `FileDescriptor.reset()` (It's unsafe because
it eventually calls `getenv()`) and `exit()`
in various `fork()` contexts, so I fixed the affected syscall tests.

PiperOrigin-RevId: 925064507
2026-06-01 20:13:23 -07:00
Ryan El KochtaandgVisor bot 7d9743c4a0 clone: support CLONE_CLEAR_SIGHAND
Clears all non-SIG_IGN signal handlers when clone() is called with
CLONE_CLEAR_SIGHAND, just like Linux.

PiperOrigin-RevId: 922974581
2026-05-28 14:25:40 -07:00
Shailend ChandandgVisor bot 329cdabbf5 Implement pidfds
This patch introduces pidfd support roughly up to Linux 6.8. Linux selftests
at this version pass, and are now run as an //image_test target. Some features,
like PIDFD_THREAD, that occur later than 6.8 in Linux, are included.

It includes:
- These new syscalls:
  - pidfd_open()
  - pidfd_getfd()
  - pidfd_send_signal()
- New aspects to these existing syscalls:
  - waitid() in its support of P_PIDFD
  - clone()/clone3() in their support of CLONE_PIDFD
  - poll()/epoll()/select() in their support for pidfds
  - setns() in its support for pidfds
  - pid introspection via /proc/[pid]/fdinfo/[pidfd]

It excludes:
- pidfdfs: pidfds are backed by the anon inode right now
- ioctls to retrieve namespace fds using a pidfd
- process_madvise()

Updates #5839.

PiperOrigin-RevId: 908341658
2026-04-30 13:22:58 -07:00
Champ-Goblem 429f3b1b8a Sentry: Add support for sysfs osrelease, ostype, version
The linux kernel outputs the current release version to `/proc/sys/kernel/osrelease`. Some libraries read this file to determine which features to enable. Implement the `osrelease`, `ostype`, `version` files to match what is returned for uname.

Fixes: #12487
2026-01-15 11:20:03 +00:00
Jing ChenandgVisor bot cb9d778912 Update docs for preadv2/pwritev2 unsupported RWF flags.
PiperOrigin-RevId: 837016247
2025-11-26 01:54:08 -08:00
Andrei VaginandgVisor bot a23e1de847 sentry/syscalls: update docs for the unshare syscall
Mount and network namespace are supported.

PiperOrigin-RevId: 663442921
2024-08-15 14:04:15 -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 3f85ee26ac Implement a subset of keyctl(2) and keyrings(7) for better Docker support.
The intention of this change is to cover a sufficient surface to accommodate
the use of running Docker within gVisor, rather than a full implementation.

This implements the following features:

  - Keys as a first-class concept in the kernel.
  - Tracking keys in user namespaces.
  - Task session keyrings: possession, inheritance.
  - Key permission enforcement.
  - The following `keyctl(2)` operations:
    - `KEYCTL_GET_KEYRING_ID`
    - `KEYCTL_DESCRIBE`
    - `KEYCTL_JOIN_SESSION_KEYRING`
    - `KEYCTL_SETPERM`

Notably, this does not implement:

  - The ability to actually add any keys other than the session keyring
    (which does not hold any cryptographic key data).
  - Other special keyrings (thread keyring, process keyring, user session
    keyring, etc.).
  - Lots of `keyctl(2)` operations.
  - Key expiration.
  - Key garbage collection. Keys live until their user namespace is destroyed.
    However, each user namespace is limited to 200 keys, so memory growth is
    bounded.
  - `add_key(2)`
  - `request_key(2)`

... However, this makes design choices that seem odd given the limited scope
of this change, but make sense when taking into account the desire to
eventually accommodate them in the future. For example, there are many
`switch` statements with only one option for session keyrings, which would get
more options when adding support for other special keyrings. Similarly, the
signature of `PossessedKeys` takes in all 3 special "possessed" keyrings, but
currently only ever gets the session keyring as non-nil.

PiperOrigin-RevId: 567047896
2023-09-20 12:38:39 -07:00
Shambhavi SrivastavaandgVisor bot 884e65cf41 Automated rollback of changelist 557871250
PiperOrigin-RevId: 560158129
2023-08-25 11:58:29 -07:00
Nicolas LacasseandgVisor bot 5dc1f9fa34 Automated rollback of changelist 554554034
PiperOrigin-RevId: 557871250
2023-08-17 10:50:10 -07:00
Shambhavi SrivastavaandgVisor bot f75fcdfa83 Implementing clone3
Updates #8585

PiperOrigin-RevId: 554554034
2023-08-07 12:19:32 -07:00
Andrei VaginandgVisor bot c5493106c6 Implement the setns syscall
This change introduces the nsfs file system. Each new namespace allocates
a new nsfs inode.

Here are reasons why we need these inodes:
* each namespace has to have an unique id.
* proc/pid/ns/ contains one entry for each namespace. Bind mounting one of
  the files in this directory to somewhere else in the filesystem keeps the
  corresponding namespace alive even if all processes currently in
  the namespace terminate.
* setns() allows the calling process to join an existing namespace specified
  by a file descriptor.

PiperOrigin-RevId: 550694515
2023-07-24 15:45:08 -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
Konstantin BogomolovandgVisor bot 0416d0a2d3 Add TESTONLY sentry panic trigger through afs_syscall.
This flag is added for tests that need to trigger a panic in the sentry
kernel. Only done for x86_64 which does have a dedicated syscall number for
afs_syscall; ARM does not.

PiperOrigin-RevId: 512731631
2023-02-27 14:28:30 -08:00
Fabricio VoznikaandgVisor bot 4d3d2741d3 Rename pselect to pselect6
The actual syscall name is pselect6. This name is used in Docker's
default seccomp profile.

PiperOrigin-RevId: 503297316
2023-01-19 16:38:48 -08:00
Zach KoopmansandgVisor bot c7dc8294b3 Disable process_vm_(read|write)v.
Syzkaller has found several issues with the two syscalls and a rework is
required. Disable tests and the syscall until issues can be fixed.

PiperOrigin-RevId: 491716795
2022-11-29 13:14:29 -08:00
Zach KoopmansandgVisor bot abe3813b7f Re-enable process_vm_(read|write)v
PiperOrigin-RevId: 489298284
2022-11-17 13:50:43 -08:00
Fabricio VoznikaandgVisor bot 22de242ebf Add read/write syscalls to trace points
Closes #8092

PiperOrigin-RevId: 488719448
2022-11-15 11:54:23 -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
Shambhavi SrivastavaandgVisor bot b160b2ad2a Add Points to some syscalls
Added a raw syscall points to all syscalls. Added schematized syscall
points to the following syscalls:

  - timerfd_create
  - timerfd_settime
  - timerfd_gettime
  - fork, vfork
  - inotify_init, inotify_init1
  - inotify_add_watch
  - inotify_rm_watch
  - socketpair

Updates #4805

PiperOrigin-RevId: 459596784
2022-07-07 14:10:36 -07:00
Shambhavi SrivastavaandgVisor bot 6a894725e6 Add Points to some syscalls
Added a raw syscall points to all syscalls. Added schematized syscall
points to the following syscalls:

  - chroot
  - dup, dup2, dup3
  - prlimit64
  - eventfd, eventfd2
  - signalfd, signalfd4
  - bind
  - accept, accept4
  - fcntl
  - pipe, pipe2

Updates #4805

PiperOrigin-RevId: 457139504
2022-06-24 19:37:41 -07:00
Shambhavi SrivastavaandgVisor bot 2adbcf780f Add Points to some syscalls
Added a raw syscall points to all syscalls. Added schematized syscall
points to the following syscalls:

- Chdir
- Fchdir
- Setgid
- Setuid
- Setsid
- Setresuid
- Setresgid

PiperOrigin-RevId: 451001973
2022-05-25 13:34:03 -07:00
Fabricio VoznikaandgVisor bot 974fc32a4d Add Points to some syscalls
Added a raw syscall points to all syscalls. Added schematized syscall
points to the following syscalls:

  - read
  - close
  - socket
  - connect
  - execve
  - creat
  - openat
  - execveat

Updates #4805

PiperOrigin-RevId: 446008358
2022-05-02 13:03:04 -07:00
Konstantin BogomolovandgVisor bot 03113543e2 Implement close_range.
Fixes #5500

PiperOrigin-RevId: 431454836
2022-02-28 09:37:03 -08:00
gVisor bot d3db71d3b1 Merge pull request #6262 from sudo-sturbia:msgqueue/syscalls3
PiperOrigin-RevId: 391416650
2021-08-17 17:44:26 -07:00
Zyad A. Ali 4ba2317532 Implement stub for msgctl(2).
Add support for msgctl and enable tests.

Fixes #135
2021-08-17 20:34:51 +02:00
Zach KoopmansandgVisor bot f26a93e634 [syserror] Convert remaining syserror definitions to linuxerr.
Convert remaining public errors (e.g. EINTR) from syserror to linuxerr.

PiperOrigin-RevId: 390471763
2021-08-12 15:19:12 -07:00
Zyad A. Ali f517422db2 Implement MSG_COPY option for msgrcv(2).
Implement Queue.Copy and add more tests for it.

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali 5eb71ba8ed Implement stubs for msgsnd(2) and msgrcv(2).
Add support for msgsnd and msgrcv and enable syscall tests.

Updates #135
2021-08-03 18:13:24 +02:00
Zyad A. Ali 0683ff858f Implement stubs for msgget(2) and msgctl(IPC_RMID).
Add support for msgget, and msgctl(IPC_RMID), and enable msgqueue
syscall tests.

Updates #135
2021-07-13 22:12:02 +02:00
Zach KoopmansandgVisor bot 5e6d494c2f [syserror] Update syserror to linuxerr for more errors.
Update the following from syserror to the linuxerr equivalent:
EEXIST
EFAULT
ENOTDIR
ENOTTY
EOPNOTSUPP
ERANGE
ESRCH

PiperOrigin-RevId: 384329869
2021-07-12 15:26:20 -07:00
Zach KoopmansandgVisor bot f033577349 [syserror] Update several syserror errors to linuxerr equivalents.
Update/remove most syserror errors to linuxerr equivalents. For list
of removed errors, see //pkg/syserror/syserror.go.

PiperOrigin-RevId: 382574582
2021-07-01 12:05:19 -07:00
Zach KoopmansandgVisor bot 895c2eaa09 [syserror] Update syserror to linuxerr for EACCES, EBADF, and EPERM.
Update all instances of the above errors to the faster linuxerr implementation.
With the temporary linuxerr.Equals(), no logical changes are made.

PiperOrigin-RevId: 382306655
2021-06-30 08:18:59 -07:00
Zach KoopmansandgVisor bot cd84634cc0 [syserror] Change syserror to linuxerr for E2BIG, EADDRINUSE, and EINVAL
Remove three syserror entries duplicated in linuxerr. Because of the
linuxerr.Equals method, this is a mere change of return values from
syserror to linuxerr definitions.

Done with only these three errnos as CLs removing all grow to a significantly
large size.

PiperOrigin-RevId: 382173835
2021-06-29 15:08:46 -07:00