103 Commits
Author SHA1 Message Date
Jimmy TranandgVisor bot 8d5f3c982a Handle sighandling.KillItself() return error.
Call dumpAndPanicSyscallError for the rare case where we fail to kill the the
Sentry upon detecting an unexpected stub exit. This will provide enough
information determine if a panic occur due to failed SIGKILL attempt or an
unexpected event.

PiperOrigin-RevId: 737751257
2025-03-17 14:29:52 -07:00
Andrei VaginandgVisor bot d844c7bbb7 Allow Sentry to kill itself even when it is the init process
PiperOrigin-RevId: 733399678
2025-03-04 11:25:32 -08:00
Konstantin BogomolovandgVisor bot 17962e58c1 Replace unsafeSlice with unsafe.Slice.
reflect.SliceHeader has been deprecated.

PiperOrigin-RevId: 714222929
2025-01-10 15:11:53 -08:00
Konstantin BogomolovandgVisor bot f7875f90fd systrap: Unset fpstate_changed if ctx did not change.
For some reason we only cleared this flag in the sighandler, where it doesn't
make a difference.

PiperOrigin-RevId: 707690365
2024-12-18 15:45:14 -08:00
Andrei VaginandgVisor bot 03a28d158e platform/systrap: return memory access type based on a page fault error code
Now we don't need to trigger a second fault to figure out whether it was write
or read access.

Fixes #11008

Co-developed-by: Jamie Liu <jamieliu@google.com>
PiperOrigin-RevId: 697677262
2024-11-18 10:33:59 -08:00
Jamie LiuandgVisor bot cf5841ba66 mm: implement prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME)
PiperOrigin-RevId: 696727156
2024-11-14 19:06:07 -08:00
Andrei VaginandgVisor bot bd7d1a7388 platform/systrap: revise /proc/self/maps to find regions for the stub code
ASAN can create huge mappings and it can take too long to skip them just
incrementing offset.

PiperOrigin-RevId: 691812156
2024-10-31 08:32:16 -07:00
Jing Chen a093ad0450 Simplify and format gVisor codebase.
The changes are just output of `gofmt -s -w .`.
2024-10-13 00:50:32 -07:00
Andrei VaginandgVisor bot f9c7e51064 systrap/arm64: add the end header after FPSIMD state in signal frame
gVisor doesn't support other than FPSIMD extension, so we have to be sure that
only FPSIMD states are restored from signal frames. Stub processes are forked
from the sentry and so they can have other extensions such as SVE which shares
FPSR and FPCR registers with FPSIMD.

Fixes #10900

PiperOrigin-RevId: 684878144
2024-10-11 10:22:33 -07:00
Konstantin BogomolovandgVisor bot a94f5e598f systrap: Replace all instances of unix.RawSyscall with pkg/hostsyscall variants.
PiperOrigin-RevId: 681941600
2024-10-03 10:48:09 -07:00
Jamie LiuandgVisor bot a50fb5ded0 Add memmap.File.DataFD().
This is used in cl/674746696 to ensure that users of MemoryFile data wait until
that data has been loaded.

PiperOrigin-RevId: 679255898
2024-09-26 12:51:20 -07:00
Andrei VaginandgVisor bot cc1f5503f1 runsc: always run the sandbox process in a new pid namespace
The sandbox process was executed in the current pid namespace if a target
platform used ptrace. It was the workaround for the kernel issue that was
fixed by 8fb335e07837 ("kernel/exit.c: release ptraced tasks before
zap_pid_ns_processes"). This fix was back-ported to stable branches.

PiperOrigin-RevId: 668121544
2024-08-27 13:45:32 -07:00
Andrei VaginandgVisor bot 940cd91305 systrap: don't fail if seccomp_unotify isn't supported
Fixes #10633

PiperOrigin-RevId: 652717946
2024-07-15 23:54:37 -07:00
Etienne PerotandgVisor bot abde965590 Metrics: Refactor uint64 metric constructor, allow non-cumulative gauges.
This turns the uint64 metric constructor arguments into a struct, making it
more explicit as to what each part means. It also allows the creation of
non-cumulative uint64 (gauge) metrics, and adds methods to decrement or set
them.

PiperOrigin-RevId: 647134245
2024-06-26 17:41:24 -07:00
Jamie LiuandgVisor bot 56ab580ccb Automated rollback of changelist 633961720
PiperOrigin-RevId: 636602151
2024-05-23 10:50:10 -07:00
Konstantin BogomolovandgVisor bot 0bf4e9f6e5 Set limit on how big MemoryFile.Allocate calls can be.
Either TotalHostMem or TotalMem are good candidates for limits
because in case either of these is set we should not be going over
them.

The motivations of this is to help catch syscalls causing allocations
with size values that are blatantly bad.

PiperOrigin-RevId: 633961720
2024-05-15 08:23:50 -07:00
Konstantin BogomolovandgVisor bot 6ab1a21b0e Set fastPathContextLimit after maxSysmsgThreads has been initialized.
A recent change to the timing of initializing maxSysmsgThreads did not
account for fastPathContextLimit which depended on it.

Also set these globals only if they haven't been set already. We don't
expect there to be more than one instance of systrap, but just in case.

PiperOrigin-RevId: 633783350
2024-05-14 19:51:39 -07:00
Konstantin BogomolovandgVisor bot 211bb0f883 Replace usage of maxSystemThreads with maxSysmsgThreads.
Systrap will never create more stub-worker threads than
maxSysmsgThreads, so there's no need to allocate memory that
will never be used.

Also change initialization of maxSysmsgThreads to happen at
platform creation time, to account for the fact that gVisor
sets GOMAXPROCS at boot.

PiperOrigin-RevId: 633420808
2024-05-13 20:40:55 -07:00
Andrei VaginandgVisor bot d71608fc03 platform/systrap: never enable fast paths if only one cpu is avaliable
Fast paths here is when one process is spinning to wait for another one.
It definitely can't work on one cpu.

Before:
BM_GetpidOpt      28491 ns        28586 ns        24138
After:
BM_GetpidOpt       7578 ns         7600 ns       100000
PiperOrigin-RevId: 629518277
2024-04-30 13:53:23 -07:00
Andrei VaginandgVisor bot 38f63e832a systrap: don't restart the task after replacing a syscall with a function call
PiperOrigin-RevId: 627556852
2024-04-23 17:43:28 -07:00
Fabricio VoznikaandgVisor bot 5a559423c4 Standardize fd.FD usage across platform and restore
This makes the code in controller.go simple, especially
for multi-container restore that requires taking ownership
of files.

PiperOrigin-RevId: 627165958
2024-04-22 15:03:16 -07:00
Andrei VaginandgVisor bot 32bbb18823 systrap: use seccomp notifications to communicate with syscall threads
The new synchronous mode of seccomp-unotify (v6.6-rc1~205^2~6) reduces overhead
of context switches.

PiperOrigin-RevId: 622924980
2024-04-08 12:47:44 -07:00
gVisor bot 13ff778ec5 Merge pull request #10207 from worrycare:master
PiperOrigin-RevId: 622246120
2024-04-05 12:09:55 -07:00
Andrei VaginandgVisor bot 8c9cbf0d90 systrap: handle syscall errors
PiperOrigin-RevId: 620610190
2024-03-31 02:31:04 -07:00
dongjinlong ba02461e12 chore: remove repetitive words in comments
Signed-off-by: dongjinlong <dongjinlong@outlook.com>
2024-03-26 19:57:40 +08:00