eBPF-based security platform
keys: Report trust-set loading failures
Michi Mutsuzaki220bbc65cd61
diff --git a/util/image_keys.c b/util/image_keys.cindex aeed121b..fef05acf 100644--- a/util/image_keys.c+++ b/util/image_keys.c@@ -18,6 +18,7 @@#include "image_config.h"#include "keyring.h"#include "keys.h"+#include "log.h"#include "malloc.h"#include "paths.h"@@ -109,14 +110,29 @@ int shirudo_keys_validate_image_set(const char *primary, int root_fd,int rc;rc = shirudo_image_config_validate(root_fd);- if (!rc)- rc = revocations(root_fd, false, false);- if (rc)+ if (rc) {+ pr_err("image trust set: validate config image: %s",+ strerror(-rc));return rc;+ }+ rc = revocations(root_fd, false, false);+ if (rc) {+ pr_err("image trust set: validate revocations: %s",+ strerror(-rc));+ return rc;+ }rc = shirudo_keys_load_image_root(primary, root_fd, true, set);- if (!rc && (!set->n || set->n_unvouched))- rc = -EKEYREJECTED;- return rc;+ if (rc) {+ pr_err("image trust set: load certificates: %s",+ strerror(-rc));+ return rc;+ }+ if (!set->n || set->n_unvouched) {+ pr_err("image trust set: reject set with %zu certificates and %zu unvouched",+ set->n, set->n_unvouched);+ return -EKEYREJECTED;+ }+ return 0;}int shirudo_keys_check_image_set(const struct shirudo_trusted_set *set)diff --git a/util/keys.c b/util/keys.cindex 704e22db..b139e4ab 100644--- a/util/keys.c+++ b/util/keys.c@@ -20,6 +20,7 @@#include "crypto.h"#include "hex.h"#include "io.h"+#include "log.h"#include "keys.h"#include "macros.h"#include "malloc.h"@@ -677,8 +678,11 @@ int shirudo_keys_load_image_root(const char *primary, int root_fd,int keys_fd, rc;keys_fd = open_beneath(root_fd, "keys", O_RDONLY | O_DIRECTORY);- if (keys_fd < 0)+ if (keys_fd < 0) {+ pr_err("image trust set: open config image keys/: %s",+ strerror(-keys_fd));return keys_fd;+ }rc = shirudo_keys_load_image_at(primary, keys_fd, with_trusted, set);close(keys_fd);return rc;