Skip to content

Commit

Permalink
Deprecate GSC_PAL and use instead GRAMINE_BINARY
Browse files Browse the repository at this point in the history
Previously, to run `gramine-direct`, one had to specify `docker run ...
--env GSC_PAL=Linux`. This was cumbersome because (1) Gramine users
don't need to know the meaning of word "PAL", (2) the value "Linux"
doesn't correspond to known-to-users `gramine-direct`, (3) it requires
special logic in apploader code.

This commit introduces instead `GRAMINE_BINARY` envvar with easier
semantics: the value is the binary which user wants to invoke.

Signed-off-by: Dmitrii Kuvaiskii <dmitrii.kuvaiskii@intel.com>
  • Loading branch information
Dmitrii Kuvaiskii committed May 14, 2024
1 parent 45eeba0 commit e746435
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
34 changes: 21 additions & 13 deletions Documentation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,26 +396,28 @@ executable arguments may be supplied to the :command:`docker run` command.
:command:`gsc build`.


Execute with Linux PAL (:program:`gramine-direct`)
--------------------------------------------------
Execute with :program:`gramine-direct`
--------------------------------------

You may select the Linux PAL (:program:`gramine-direct`) at Docker run time
instead of the Linux-SGX PAL (:program:`gramine-sgx`) by specifying the
environment variable :envvar:`GSC_PAL` as an option to the
:command:`docker run` command. When using the Linux PAL, it is not necessary
to sign the image via a :command:`gsc sign-image` command.
By default, the Docker container starts :program:`gramine-sgx`.

.. envvar:: GSC_PAL
You may choose to start :program:`gramine-direct` in the Docker container by
specifying the environment variable :envvar:`GRAMINE_BINARY` as a command-line
option to :command:`docker run`.

This environment variable specifies the pal loader.
.. envvar:: GRAMINE_BINARY

GSC requires a custom seccomp profile while running with Linux PAL, which has to be
specified at Docker run time. There are two options:
This environment variable specifies the Gramine binary to run. Currently
supported values are ``gramine-direct`` and ``gramine-sgx``. Default is
``gramine-sgx``.

GSC requires a custom seccomp profile for :program:`gramine-direct`. There are
two options:

#. Pass `unconfined` to run the container without the default seccomp profile.
This option is generally considered insecure, since this results in containers
running with unrestricted system calls (all system calls are allowed which
increases the attack surface of the Linux Kernel).
increases the attack surface of the Linux kernel).

#. Pass the custom seccomp profile
https://github.com/gramineproject/gramine/blob/master/scripts/docker_seccomp.json.
Expand All @@ -426,7 +428,13 @@ specified at Docker run time. There are two options:

.. code-block:: sh
docker run ... --env GSC_PAL=Linux --security-opt seccomp=<profile> gsc-<image-name> ...
docker run ... --env GRAMINE_BINARY=gramine-direct \
--security-opt seccomp=<profile> \
gsc-<image-name> ...
.. note::
Previously, to run :program:`gramine-direct`, one specified ``--env
GSC_PAL=Linux``. This is deprecated in GSC v1.8 and will be removed in v1.9.

Example
=======
Expand Down
14 changes: 4 additions & 10 deletions templates/apploader.common.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@ set -e
# Export distro-specific paths (typically `PYTHONPATH` and `PKG_CONFIG_PATH`)
{% block path %}{% endblock %}

# Default to Linux-SGX if no PAL was specified
if [ -z "$GSC_PAL" ] || [ "$GSC_PAL" == "Linux-SGX" ]
then
exec gramine-sgx /gramine/app_files/entrypoint \
{% if insecure_args %}{{ binary_arguments | map('shlex_quote') | join(' ') }} \
"${@}"{% endif %}
else
exec gramine-direct /gramine/app_files/entrypoint \
{{ binary_arguments | map('shlex_quote') | join(' ') }} "${@}"
fi
# Note: default to SGX if Gramine binary wasn't specified
exec ${GRAMINE_BINARY:-gramine-sgx} /gramine/app_files/entrypoint \
{% if insecure_args %}{{ binary_arguments | map('shlex_quote') | join(' ') }} \
"${@}"{% endif %}

0 comments on commit e746435

Please sign in to comment.