aboutsummaryrefslogtreecommitdiff
path: root/lib/libsecureboot/verify_file.c
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2020-03-25 19:12:19 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2020-03-25 19:12:19 +0000
commit53f151f90603580d0c0a8fa1840ba1262958a7c1 (patch)
tree78969ebac620eb68b5a22beb561b91e35c99db70 /lib/libsecureboot/verify_file.c
parent7c63520c42754642acce60c7be5fc9676e3e3266 (diff)
downloadsrc-53f151f90603580d0c0a8fa1840ba1262958a7c1.tar.gz
src-53f151f90603580d0c0a8fa1840ba1262958a7c1.zip
Fix pkgfs stat so it satisfies libsecureboot
We need a valid st_dev, st_ino and st_mtime to correctly track which files have been verified and to update our notion of time. ve_utc_set(): ignore utc if it would jump our current time by more than VE_UTC_MAX_JUMP (20 years). Allow testing of install command via userboot. Need to fix its stat implementation too. bhyveload also needs stat fixed - due to change to userboot.h Call ve_error_get() from vectx_close() when hash is wrong. Track the names of files we have hashed into pcr For the purposes of measured boot, it is important to be able to reproduce the hash reflected in loader.ve.pcr so loader.ve.hashed provides a list of names in the order they were added. Reviewed by: imp MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org//D24027
Notes
Notes: svn path=/head/; revision=359307
Diffstat (limited to 'lib/libsecureboot/verify_file.c')
-rw-r--r--lib/libsecureboot/verify_file.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/libsecureboot/verify_file.c b/lib/libsecureboot/verify_file.c
index eee749667759..20fc0ae4ae78 100644
--- a/lib/libsecureboot/verify_file.c
+++ b/lib/libsecureboot/verify_file.c
@@ -117,10 +117,12 @@ is_verified(struct stat *stp)
{
struct verify_status *vsp;
- for (vsp = verified_files; vsp != NULL; vsp = vsp->vs_next) {
- if (stp->st_dev == vsp->vs_dev &&
- stp->st_ino == vsp->vs_ino)
- return (vsp->vs_status);
+ if (stp->st_ino > 0) {
+ for (vsp = verified_files; vsp != NULL; vsp = vsp->vs_next) {
+ if (stp->st_dev == vsp->vs_dev &&
+ stp->st_ino == vsp->vs_ino)
+ return (vsp->vs_status);
+ }
}
return (VE_NOT_CHECKED);
}
@@ -367,10 +369,11 @@ verify_prep(int fd, const char *filename, off_t off, struct stat *stp,
return (0);
}
DEBUG_PRINTF(2,
- ("caller=%s,fd=%d,name='%s',off=%lld,dev=%lld,ino=%lld\n",
+ ("verify_prep: caller=%s,fd=%d,name='%s',off=%lld,dev=%lld,ino=%lld\n",
caller, fd, filename, (long long)off, (long long)stp->st_dev,
(long long)stp->st_ino));
rc = is_verified(stp);
+ DEBUG_PRINTF(4,("verify_prep: is_verified()->%d\n", rc));
if (rc == VE_NOT_CHECKED) {
rc = find_manifest(filename);
} else {
@@ -458,7 +461,6 @@ verify_file(int fd, const char *filename, off_t off, int severity,
#endif
}
if (severity < VE_MUST) { /* not a kernel or module */
-
if ((cp = strrchr(filename, '/'))) {
cp++;
if (strncmp(cp, "loader.ve.", 10) == 0) {
@@ -511,6 +513,7 @@ verify_pcr_export(void)
#ifdef VE_PCR_SUPPORT
char hexbuf[br_sha256_SIZE * 2 + 2];
unsigned char hbuf[br_sha256_SIZE];
+ char *hinfo;
char *hex;
ssize_t hlen;
@@ -520,6 +523,17 @@ verify_pcr_export(void)
if (hex) {
hex[hlen*2] = '\0'; /* clobber newline */
setenv("loader.ve.pcr", hex, 1);
+ DEBUG_PRINTF(1,
+ ("%s: setenv(loader.ve.pcr, %s\n", __func__,
+ hex));
+ hinfo = ve_pcr_hashed_get(1);
+ if (hinfo) {
+ setenv("loader.ve.hashed", hinfo, 1);
+ DEBUG_PRINTF(1,
+ ("%s: setenv(loader.ve.hashed, %s\n",
+ __func__, hinfo));
+ free(hinfo);
+ }
}
}
#endif