11 Commits
Author SHA1 Message Date
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
Konstantin BogomolovandgVisor bot fe66cae2ed Enumerate known systrap stub failures to exit process cleanly.
This helps to rectify a long standing problem of Systrap panicking
when encountering corrupted sysmsg stub memory.

These errors specifically are easier to notice and debug since we
check for them in the stub code and flag them to the sentry
explicitly. They are now very grep-able to make finding their origin
in the stub code easier.

PiperOrigin-RevId: 604743496
2024-02-06 13:19:26 -08:00
Andrei VaginandgVisor bot 226f5145b6 systrap: preempt long running contexts
A context is preempted if it is running longer than 10ms
and there are other contexts in the queue.

PiperOrigin-RevId: 533376587
2023-05-19 00:35:21 -07:00
Andrei VaginandgVisor bot bd0acf9da9 systrap: add wrappers for gcc atomic functions
It makes code a bit more readable.

PiperOrigin-RevId: 530758808
2023-05-09 17:39:33 -07:00
Konstantin BogomolovandgVisor bot d7f590dd00 Clean up context decoupling experiment.
This change removes code branches and variables only used in coupled-context
mode.

PiperOrigin-RevId: 529776383
2023-05-05 11:55:50 -07:00
Konstantin BogomolovandgVisor bot f727f06c81 Add debug logging to systrap futex waits.
In general it is probably a good idea to set a timeout on any futex waits that
the sentry is doing. For now just output some helpful logs about what the shared
memory looks like; in the future we may want to do something more useful on
ETIMEDOUT events.

PiperOrigin-RevId: 518919966
2023-03-23 11:44:22 -07:00
Konstantin BogomolovandgVisor bot 897c03039e Implement systrap context queue.
This is the initial implementation of the systrap context queue via a ringbuffer
in shared memory between stub threads and the sentry.

In this new model there is no longer a bound sysmsg thread for every context;
instead each subprocess starts with one initial sysmsg thread, which starts
polling the context queue for new contexts arriving from the sentry. If the
sentry detects that contexts are spending too much time in the context queue
without being processed, it will create new sysmsg threads or wake sleeping
ones. Tangentially, sysmsg threads will go to sleep if they spend too much time
busy looping without new context arrivals.

This model does not yet take into account the full load of the host system or
even multiple subprocesses in the same sandbox. Multiple overloaded subprocesses
are liable to make each other run slower by kicking sysmsg threads more often
than they need to; this will be remedied in follow up CLs.

PiperOrigin-RevId: 516680504
2023-03-14 17:48:13 -07:00
Konstantin BogomolovandgVisor bot 9ec69054f8 Map shared region for systrap thread contexts.
Introduces what a ThreadContext struct is in the context of systrap. It
makes the mappings of the region where the contexts will be stored into both the
sentry and the address space of stub processes.

PiperOrigin-RevId: 513913793
2023-03-04 00:42:24 -08:00
Adin ScannellandgVisor bot 1ceb814544 Add default_applicable_licenses rules to packages.
PiperOrigin-RevId: 513581243
2023-03-02 10:50:04 -08:00
Adin ScannellandAndrei Vagin e41e5bd3bd Add appropriate arch_genrule transitions. 2023-02-28 12:28:17 -08:00
Andrei VaginandgVisor bot 192bfb03fb Open-sourcing the systrap platform.
The systrap platform like the ptrace platform uses stub processes to manage
the user address space. The difference is how they intercept system calls and
other events like memory faults, exceptions, etc.

In case of systrap, all events that have to be handled by the Sentry trigger
signals that are handled by a custom signal handler installed on stub
processes. The signal handler switches control to the Sentry.

Here are a few other optimizations:
* On x86, system calls can be replaced with a function call to remove overhead
  of signals.
* For fast interactions of sentry and stub processes, futex wait/wake can
  be a bottle neck, so we use a polling mode.

The platform is launched for the purpose of testing and gathering initial
feedback. It is not yet ready for use in production.

PiperOrigin-RevId: 511650064
2023-02-22 18:22:49 -08:00