Christian Blichmann ca6ec4337d Add workaround for active Tomoyo LSM
Recenly, Debian based distribution kernels started activating the Tomoyo Linux
Security Module by default. Even if it is not used, this changes the behavior
of `/dev/fd` (pointing to `/proc/self/fd` by default), which Sandbox2 needs during
`execveat()`.

As a result, Sandbox2 and Sandboxed API always fail without one of the following
conditions
- `/proc` mounted within the sandboxee
- `/dev` mounted
- `/dev/fd` symlinked to `/proc/self/fd` in the sandboxee's mount namespace

Some code pointers to upstream Linux 5.12.2:
- https://elixir.bootlin.com/linux/v5.12.2/source/fs/exec.c#L1775
- https://elixir.bootlin.com/linux/v5.12.2/source/security/tomoyo/tomoyo.c#L107
- https://elixir.bootlin.com/linux/v5.12.2/source/security/tomoyo/domain.c#L729

To find out whether your system has Tomoyo enabled, use this command, similar to
what this change does in code:

```
$ cat /sys/kernel/security/lsm | grep tomoyo && echo "Tomoyo active"
capability,yama,apparmor,tomoyo
Tomoyo active
```

The config setting `CONFIG_DEFAULT_SECURITY` controls which LSMs are built into
the kernel by default.

PiperOrigin-RevId: 372919524
Change-Id: I2181819c04f15f57d96c44ea9977d0def4a1b623
2021-05-10 07:04:04 -07:00
..
2021-02-19 04:43:14 -08:00
2021-02-19 04:43:14 -08:00
2020-10-01 06:45:38 -07:00
2020-10-01 06:45:38 -07:00
2021-05-10 07:04:04 -07:00
2021-01-28 02:20:37 -08:00
2021-02-02 06:55:30 -08:00
2020-10-05 05:10:16 -07:00
2020-01-31 05:39:25 -08:00
2021-01-22 06:01:34 -08:00
2021-02-19 04:43:14 -08:00
2021-01-22 06:01:34 -08:00
2021-01-27 08:05:25 -08:00
2021-05-10 07:04:04 -07:00
2021-05-10 07:04:04 -07:00
2021-05-10 07:04:04 -07:00
2021-01-22 06:01:34 -08:00
2021-02-02 02:41:13 -08:00
2021-02-24 03:06:55 -08:00
2019-10-07 02:36:35 -07:00
2021-01-22 06:01:34 -08:00
2020-09-03 07:40:33 -07:00
2020-09-03 07:40:33 -07:00
2021-01-22 06:01:34 -08:00
2021-03-18 05:56:40 -07:00
2021-02-19 04:43:14 -08:00
2020-07-20 00:24:40 -07:00

Sandbox2

Sandbox2 is a C++ security sandbox for Linux which can be used to run untrusted programs or portions of programs in confined environments. The idea is that the runtime environment is so restricted that security bugs such as buffer overflows in the protected region cause no harm.

Documentation

Detailed developer documentation is available on the Google Developers site for Sandboxed API under Sandbox2.

There is also a Getting Started guide for Sandbox2.