Commit Graph

13 Commits

Author SHA1 Message Date
borysp bb6206822a [Makefile] Use MAKEFILE_LIST before any includes
`Scripts/Makefile.rules` used MAKEFILE_LIST to obtain the current
makefile path, but it did so after including some other file, so it got
the included file path instead.

Signed-off-by: borysp <borysp@invisiblethingslab.com>
2021-02-09 00:26:42 +01:00
borysp c24bddd5aa [LibOS] Rework signal handling and syscall emulation
Change log (most important only):
- unify CPU context structures - now we have only one version -
  `PAL_CONTEXT` - which is shared between LibOS and PALs and it should
  depend only on the host architecture (not OS),
- syscalls emulation changed:
  - dedicated LibOS stack is now used for syscalls emulation,
  - removed one indirection level in syscalls table - now it stores
    `shim_do_*` functions directly,
- signal handling - completely rewritten:
  - all signal queues use proper locking schemes now,
  - signals are handled *only* when returning to the user app from LibOS
    or PAL,
  - nested signals are now possible,
  - the app is allowed to jump out of signal handler with the same
    sematics as on normal Linux,
  - signal altstack is now fully supported,
  - syscall restarting is now supported,
  - doing a backtrace from the signal handler works properly,
- disallow injecting host-level signals, with one exception, see
  `sys.enable_sigterm_injection` manifest option for more details.
2021-02-05 14:11:21 +01:00
Paweł Marczewski cf0bfdf67a [Make] Use proper dependencies for generated-offsets
The generated-offsets headers have to depend on the code that
defines the relevant data structures. Otherwise, when the data
structures change, the code will get compiled with wrong offsets
and will crash.
2021-01-29 13:10:45 -08:00
Michał Kowalczyk 3d31f2d18d Introduce one, central manifest, zero-config children and constant MRENCLAVE
This is the next part of the great loader rework, with a lot of breaking changes:

- Complete removal of the "trusted children" thing - now children
  processes can be spawned arbitrarily and from arbitrary mountpoint
  types, without any additional configuration needed.

- There's a new, required option in the manifest: `libos.entrypoint` - it
  specifies the URI to the entry binary in the first process. There's no
  need anymore to name the manifest and the first binary identically.

- On SGX, the main binary is not measured in MRENCLAVE anymore - only
  PAL, LibOS and the manifest are measured. This is enough to bind
  MRENCLAVE to a specific entrypoint user executable if wanted - it
  just has to be mounted as a trusted file.

- All Graphene SGX enclaves have now exactly the same MRENCLAVE. This is
  a hash of a "Graphene stub", which can "fork" into one of two states
  in runtime: initial process or child. The initial process creates a
  new "Graphene namespace" with a clean state, it can also be attested
  remotely (contrary to child processes). The initial process can spawn
  children processes by spawning a Graphene stub and directing it to
  start in the child mode. It then attests it locally, and if
  successful, establishes an encrypted pipe, "connects" to its own
  namespace and treats as trusted (including sending protected files
  key).

- Now, there's only one, central manifest describing the initial state
  of a Graphene instance which can be spawned from it (previously, each
  process required a separate manifest which could have different
  configuration - which wasn't actually supported and didn't make sense
  design-wise). One downside of central manifests is that all processes
  require the same enclave configuration (e.g. size), but that was
  already the case so far because of broken checkpointing code. Also,
  this is only a temporary problem, which will cease to exist after the
  introduction of EDMM.

- `sgx.static_address` was renamed to `sgx.nonpie_binary` and now has to
  be inserted manually by users (`sgx_sign` tools doesn't know about the
  binaries run inside, which can be even provided or generated in
  runtime by the user's workload).

- Caveat: the memory gap for non-PIE executables was removed because it
  requires adding a new option to the manifest to be cleanly
  implemented. This is left for some future loader rework PR.
2021-01-12 19:53:24 +01:00
Michał Kowalczyk 55aea29d50 [Pal] Disallow starting without an executable
Previously, it was possible to use Graphene without the main executable
(e.g. having only preloaded libraries). We aren't aware of anyone using
this weird option, but worse, it led to a very bad UX when the user made
mistakes - e.g. having a typo in the manifest or executable name could
lead to Graphene starting without errors, but doing nothing.
2020-10-27 04:21:30 -07:00
Michał Kowalczyk e587869e13 [LibOS+Pal] manifest: Remove support for loader.exec and sgx.sigfile
Supporting these options complicates the design of Graphene and loading
logic significantly, providing little useful functionality:
- loader.exec:
    - the main user of it were our tests
    - worked only for the first process spawned inside Graphene, as it
      was a unidirectional manifest->binary mapping, so the child
      process didn't know about the corresponding manifest.
- sgx.sigfile:
    - probably all existing usages of it were completely redundant
    - was resolved relatively to CWD instead of the executable location,
      which made it mostly useless

From now on, the correct location of the files is:
- either place the manifest and sigfile next to the binary, with a
  matching name, or
- create a symlink to the binary in the folder where manifests are
  stored and launch it through this symlink
2020-10-23 00:06:46 +02:00
Paweł Marczewski 7b73f0e086 [Pal,LibOS] Make the offset generation compatible with clang 2020-09-10 16:27:45 +02:00
borysp 420a56b402 Make symlinks in Runtime directory relative 2020-07-29 20:45:01 +02:00
Michał Kowalczyk fcf0a01d7d Remove shebangs from autogenerated manifests
We don't use it in tests, plus it didn't work on SGX - there was a
warning about autogeneration inserted before the autogenerated shebang.

Also, test_106_manifest_with_shebang didn't actually test the shebang
but ran the binary through the loader, so it was meaningless. We'll need
to fix it and implement again after cleaning up Graphene invocation.
2020-06-18 00:44:30 +02:00
Isaku Yamahata 86afe662f3 [Pal/Linux-SGX] Add rule cmulti to build executable from multiple .o files 2020-02-05 23:21:05 -08:00
Isaku Yamahata dd086816b5 [LibOS,Pal] Define AR and ARFLAGS properly 2020-02-05 23:21:05 -08:00
Isaku Yamahata 9ef2251d66 [LibOS,Pal,Scripts] Add and use recipe to create manifest from template 2020-02-05 23:21:05 -08:00
Isaku Yamahata 732712e23e [LibOS,Pal] Move makefile libraries under Scripts/
This commit moves Makefile.configs, Makefile.rules, and Makefile.Test
under Scripts/ and adjusts their includes.
2020-02-05 23:21:04 -08:00