1433 Commits

Author SHA1 Message Date
gVisor bot 25d30ccc2c Merge pull request #11529 from tianyuzhou95:albert/mmap-test
PiperOrigin-RevId: 738050948
2025-03-18 10:13:53 -07:00
Nicolas Lacasse 6b0a0af862 Implement basic packet mode support for ptys.
From man TIOCPKT:
"""
In packet mode, each subsequent read(2) will return a packet that either
contains a single nonzero control byte, or has a single byte containing zero
('\0') followed by data written on the slave side of the pseudoterminal."
"""

This CL implements only the data portion of packet mode, not the control bytes,
but that seems to be enough to get xfce4-terminal to work.

PiperOrigin-RevId: 737175092
2025-03-15 09:26:56 -07:00
Tianyu Zhou 970259d162 test/syscalls: fix the duplicate test case
Currently, the NoSigBusOnPagesBeforeEOF and NoSigBusOnPageContainingEOF
test cases are identical. This patch corrects the addr accessed in the
former test to match the corresponding comment.

Signed-off-by: Tianyu Zhou <albert.zty@antgroup.com>
2025-03-07 17:43:07 +08:00
Ayush Ranjan f06d4e7ebe goferfs: Add S/R support for open FDs to deleted files.
This support is only needed when the gofer mount in question is writable.
By default, the rootfs has an overlayfs applied, so the gofer lower layer is
not writabled. But if you are using --overlay2=none, then this change should
allow you to save sandbox with open FDs to deleted files in rootfs.

Updates #11425

PiperOrigin-RevId: 733021267
2025-03-03 12:38:10 -08:00
gVisor bot 86abc85f37 Merge pull request #11473 from Champ-Goblem:shim-add-cgroup-v2-metrics-support
PiperOrigin-RevId: 730560110
2025-02-25 14:52:09 -08:00
Jimmy Tran 17563a8af9 Return EACCES when calling setpgid() after execve()
From setpgid manpage,

EACCES - An attempt was made to change the process group ID of one
of the children of the calling process and the child had
already performed an execve(2) (setpgid(), setpgrp()).

This CL makes gVisor implement this rule and updates the exec test
suite accordingly.

TESTED: http://sponge2/7f364e8a-4f82-463e-ba62-79234c4d054d
PiperOrigin-RevId: 727095560
2025-02-14 16:14:14 -08:00
Lucas Manning faac8f36cd Add support for PACKET_STATISTICS.
PiperOrigin-RevId: 725271073
2025-02-10 10:46:54 -08:00
Lucas Manning 9c490f813d Implement GetSockOpt PACKET_HDRLEN and add a test for tcpdump.
PiperOrigin-RevId: 724445536
2025-02-07 13:06:14 -08:00
Jimmy Tran de6637c27c Recompute max variable after setting FD in the bitmap.
`fdBitmap.FirstZero()` could return `max` value; if it does, then
recompute the max value to avoid reusing the old max value twice.

The default bitmap size for file descriptors in gVisor is 65535.

Add a pipe test that attempts to create more than 65535 FDs to hit the edge
case where fdBitmap.FirstZero() returns the default bitmap max value of 65535.

TESTED:
http://sponge2/4c12ce75-3763-4773-ad62-87c6b8fe0446
http://sponge2/9c9d6ea0-b69c-432c-a16b-9446214109ba
PiperOrigin-RevId: 724410846
2025-02-07 11:22:54 -08:00
Lucas Manning 213917f3ea Don't switch to using the packet mmap endpoint for zero length requests.
This matches linux's behavior.

Reported-by: syzbot+31f4b63198c23c53c6e2@syzkaller.appspotmail.com
Reported-by: syzbot+e19f276e27cccbbecd0e@syzkaller.appspotmail.com
PiperOrigin-RevId: 724032784
2025-02-06 12:34:46 -08:00
Lucas Manning 6194338723 Add support for setting PACKET_VERSION for PACKET_MMAP.
tcpdump requires TPACKET_V2 to work properly.

PiperOrigin-RevId: 723670574
2025-02-05 15:19:34 -08:00
Lucas Manning 83a4caf2a7 Implement MappablePacketEndpoint for PACKET_MMAP and add tests.
PiperOrigin-RevId: 723590936
2025-02-05 11:39:27 -08:00
Andrei Vagin 3754522ab7 test: don't check SO_REUSEPORT for non-inet sockets
AllSocketPairTest.SetAndGetBooleanSocketOptions fails on the upstream linux
kernel. The behaviour has been changed by 5b0af621c3f6 ("net: restrict
SO_REUSEPORT to inet sockets").

PiperOrigin-RevId: 722774180
2025-02-03 13:26:03 -08:00
gVisor bot e0435b9a53 Merge pull request #11415 from avagin:codespell
PiperOrigin-RevId: 721421397
2025-01-30 09:44:28 -08:00
Andrei Vagin f010ae01ac Fix a few typos 2025-01-29 21:16:51 -08:00
gVisor bot ddebbe53f2 Merge pull request #11358 from Snowflake-Labs:xuzhoyin-mmap-fix
PiperOrigin-RevId: 720973349
2025-01-29 07:51:36 -08:00
Yhinner 191b53da2a Fix EXEC permission of the volume mount when calling mmap with PROT_EXEC 2025-01-27 18:59:59 +00:00
Nicolas Lacasse c238e15234 Fix validation of close_range last fd argument.
The `last` fd argument can be up to max uint32, and some applications call it
with this maximum:
https://github.com/GNOME/glib/blob/26bc1d08ec574b387ff4bcd919a020a586727bbf/glib/glib-unix.c#L890

PiperOrigin-RevId: 718526878
2025-01-22 14:25:24 -08:00
gVisor bot 0b03f8a414 Internal change.
PiperOrigin-RevId: 718094722
2025-01-21 15:29:53 -08:00
Andrei Vagin ca3c23db50 tests: Deflake socket_inet_loopback_isolated_test
This test case creates one connection, then it closes one end of it. After that
it waits for a linger timeout and tries to create the second connection with
the same client source port. The test is flaky if the second half of the fist
connection isn't closed before creating the second connection.

PiperOrigin-RevId: 715924851
2025-01-15 13:38:00 -08:00
Andrei Vagin 1864d9d091 Untag user addresses before handling them in the Sentry
Top-Byte-Ignore (TBI) is a feature on all ARMv8.0 CPUs that causes the top byte
of virtual addresses to be ignored on loads and stores. Instead, bit 55 is
extended over bits 56-63 before address translation. This feature allows use of
the (ignored) top byte as a tag or for other in-band metadata.

In Linux, brk()/mmap()/mremap() syscalls don't untag addresses. More details
are in dcde237319e6 ("mm: Avoid creating virtual address aliases in
brk()/mmap()/mremap()")

PiperOrigin-RevId: 715885990
2025-01-15 11:52:40 -08:00
Nayana Bidari cd31d0522a Enable netstack save/restore in cloud/gvisor by default.
PiperOrigin-RevId: 712978128
2025-01-07 11:19:26 -08:00
Jamie Liu 0f8db9fa28 Deflake process_vm_read_write test.
Passing an uninitialized iovec can cause process_vm_readv/writev to fail for
reasons other than the intended one.

PiperOrigin-RevId: 708414541
2024-12-20 13:38:37 -08:00
gVisor bot 4971756d8d Internal change.
PiperOrigin-RevId: 702177156
2024-12-02 20:23:18 -08:00
Kevin Krakauer 973e1032b4 Automated rollback of changelist 699333953
PiperOrigin-RevId: 702084502
2024-12-02 14:24:26 -08:00