All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roberto Sassu <roberto.sassu@huaweicloud.com>
To: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com
Cc: linux-integrity@vger.kernel.org, vt@altlinux.org, pvorel@suse.cz,
	stefanb@linux.ibm.com, Roberto Sassu <roberto.sassu@huawei.com>
Subject: [PATCH ima-evm-utils v3 00/11] Support testing in new enviroments
Date: Wed, 25 Jan 2023 09:50:19 +0100	[thread overview]
Message-ID: <20230125085030.1568256-1-roberto.sassu@huaweicloud.com> (raw)

From: Roberto Sassu <roberto.sassu@huawei.com>

One of the main limitations of running tests in the current environment is
that features/bug fixes to be tested need to be already included in the
running kernel, which is not always the case.

User Mode Linux (UML) and virtual machines can be used to overcome this
limitation. They allow to create a new environment and run a custom kernel
built by a CI or by the user. The tests can then check the features/bug
fixes of the custom kernel.

Running tests in a new environment also gives the ability to control the
configuration, and to have a clean state for each test by creating new
environments as necessary. The current environment might not allow that,
e.g. for security reasons.

Introduce a mechanism for creating and managing new environments. Expose an
API that allow to transparently create one or multiple environments in a
test script, and to reexecute that script in the new one. Using that API
requires minimal changes to the existing scripts.

The API is generic enough to support different types of enviroments. The
environment can be selected with the TST_ENV environment variable. At the
moment, only UML is supported. QEMU will be added at a later stage.

With the ability to test custom kernels, ima-evm-utils might introduce
specific tests for that, separated from the tests to verify the
ima-evm-utils user space functionality. At the moment, there is no such
distinction, existing tests verify both.

First, fix error messages and a variable in evmctl. Then, add the
config-uml file with custom kernel configuration options for the tests, to
be merged with the default configuration. Add a new job in the Github
workflow to build the UML kernel from a repository and branch specified in
the LINUX_URL and LINUX_BRANCH variables (if the kernel repository does not
have a branch with the same name of the ima-evm-utils one). Per Github
documentation, these variables can be defined at organization, repository
and environment level.

Return the correct script exit code if no test was executed. Introduce the
new API for creating and managing new enviroments, for existing and new
test scripts. If TST_ENV is not set, calling the API results in a nop, and
tests are executed in the current environment.

Add the possibility to select individual tests to run in a test script,
with the TST_LIST variable, so that a new environment can be created
multiple times for a subset of tests (useful if for example a test require
kernel settings different from the previous test).

Add tests for EVM portable signatures and modify fsverity.test to use the
new API.

Finally, don't require making changes to the system to run fsverity.test,
install a software dependency after the appropriate repository has been
set up, and temporarily remove CONFIG_DEBUG_SG to avoid a kernel panic
until the patches to fix it are accepted in the upstream kernel.

Changelog

v2:
 - Compile everything built-in for the UML kernel in Github Actions
 - Replace UML_MODE with TST_ENV, introduce TST_KERNEL to specify the path
   of the kernel to run
 - Temporarily disable CONFIG_DEBUG_SG (patch by Mimi)
 - Rename mdlen and hash variable respectively to siglen and sig (suggested
   by Stefan)
 - Always use _report_exit_and_cleanup() as trap function and pass the
   cleanup function as argument
 - Rename _run_user_mode(), _exit_user_mode(), _init_user_mode(),
   _cleanup_user_mode() respectively to _run_env(), _exit_env(),
   _init_env() and _cleanup_env()
 - Fix style issues in tests/functions.sh and
   tests/portable_signatures.test (suggested by Stefan)
 - Get the script exit code in _report_exit_and_cleanup() and return that
   if no test was executed
 - Mount tmpfs in the new environment, to avoid interference with the host
 - Don't delete fsverity-utils and mount-idmapped directories so that the
   built binaries are available for use without installing them (suggested
   by Stefan)
 - Rename global variables in tests/portable_signatures.test to avoid
   collisions (suggested by Stefan)
 - Declare the 'format' variable as local in get_xattr() in
   tests/portable_signatures.test (suggested by Stefan)
 - Print a message in tests/portable_signatures.test when the
   mount-idmapped binary is found
 - Check more paths for the private key in tests/portable_signatures.test
   (suggested by Mimi)
 - Increase the memory allocation for the UML kernel to 2048M to satisfy
   requests to mount tmpfs

v1:
 - Use Github vars context instead of secrets (suggested by Mimi)
 - Define default values of LINUX_URL and LINUX_BRANCH in case they are not
   provided (suggested by Mimi)
 - Pull source code with depth 1 instead of 5, as it is not necessary now
 - Run 'make ARCH=um olddefconfig' before merging test-specific options in
   config-uml
 - Install haveged for CentOS 8 after the EPEL repository is configured
   (patch by Mimi)

Mimi Zohar (2):
  ci: haveged requires EPEL on CentOS stream:8
  Temporarily remove CONFIG_DEBUG_SG to test portable signatures

Roberto Sassu (9):
  Fix error messages and vars in calc_evm_hmac()
  Add config for UML kernel
  Compile the UML kernel and download it in Github Actions
  Pass cleanup function and its arguments to _report_exit_and_cleanup()
  Add support for creating a new testing environment in functions.sh
  Introduce TST_LIST variable to select a test to execute
  Add tests for EVM portable signatures
  Adapt fsverity.test to be able to run in a new testing environment
  Use in-place built fsverity binary instead of installing it

 .github/workflows/ci.yml        |   99 ++-
 build.sh                        |    5 +
 ci/fedora.sh                    |   12 +-
 config-uml                      |  234 +++++++
 src/evmctl.c                    |   14 +-
 tests/Makefile.am               |    2 +-
 tests/boot_aggregate.test       |    2 +-
 tests/fsverity.test             |   14 +-
 tests/functions.sh              |  105 ++-
 tests/install-fsverity.sh       |    3 +-
 tests/install-mount-idmapped.sh |    6 +
 tests/portable_signatures.test  | 1088 +++++++++++++++++++++++++++++++
 12 files changed, 1565 insertions(+), 19 deletions(-)
 create mode 100644 config-uml
 create mode 100755 tests/install-mount-idmapped.sh
 create mode 100755 tests/portable_signatures.test

-- 
2.25.1


             reply	other threads:[~2023-01-25  8:51 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25  8:50 Roberto Sassu [this message]
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 01/11] Fix error messages and vars in calc_evm_hmac() Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 02/11] Add config for UML kernel Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 03/11] Compile the UML kernel and download it in Github Actions Roberto Sassu
2023-01-25 19:17   ` Mimi Zohar
2023-01-26  9:09     ` Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 04/11] Pass cleanup function and its arguments to _report_exit_and_cleanup() Roberto Sassu
2023-01-25 13:52   ` Stefan Berger
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 05/11] Add support for creating a new testing environment in functions.sh Roberto Sassu
2023-01-25 13:36   ` Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 06/11] Introduce TST_LIST variable to select a test to execute Roberto Sassu
2023-01-25 14:06   ` Stefan Berger
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 07/11] Add tests for EVM portable signatures Roberto Sassu
2023-01-25 23:15   ` Stefan Berger
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 08/11] Adapt fsverity.test to be able to run in a new testing environment Roberto Sassu
2023-01-25 22:45   ` Stefan Berger
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 09/11] Use in-place built fsverity binary instead of installing it Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 10/11] ci: haveged requires EPEL on CentOS stream:8 Roberto Sassu
2023-01-25  8:50 ` [PATCH ima-evm-utils v3 11/11] Temporarily remove CONFIG_DEBUG_SG to test portable signatures Roberto Sassu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230125085030.1568256-1-roberto.sassu@huaweicloud.com \
    --to=roberto.sassu@huaweicloud.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=pvorel@suse.cz \
    --cc=roberto.sassu@huawei.com \
    --cc=stefanb@linux.ibm.com \
    --cc=vt@altlinux.org \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.