git: b1e82823480a - main - libsecureboot: don't remember files accepted unverified

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Thu, 26 Nov 2026 04:02:32 UTC
The branch main has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=b1e82823480a285193e6790ad63b8941e3231504

commit b1e82823480a285193e6790ad63b8941e3231504
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2026-11-26 04:00:54 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-11-26 04:01:03 +0000

    libsecureboot: don't remember files accepted unverified
    
    verify_file() caches the result for each file by dev/ino, including
    VE_UNVERIFIED_OK.  That status only says that the file was unverified
    but acceptable at the severity the caller asked for, but a later
    request for the same file takes the cached result as-is: verify_prep()
    and vectx_open() both treat it as "not verifying this", even at
    VE_MUST.
    
    As a result, anything that could be opened at a lower severity could
    then be loaded where it must verify, e.g.:
    
            include /boot/modules/evil.ko   # VE_WANT, no fingerprint
            load evil                       # VE_MUST, but cached as OK
    
    Stop caching VE_UNVERIFIED_OK so that each request is judged by its own
    severity, under whatever policy is in effect at the time.  Files that
    would be accepted unverified have no usable fingerprint, so there's
    nothing to hash; they're just looked up again (and reported, if verbose)
    each time they're opened.
    
    Reviewed by:    sjg
    Sponsored by:   The FreeBSD Foundation
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D61841
---
 lib/libsecureboot/verify_file.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/libsecureboot/verify_file.c b/lib/libsecureboot/verify_file.c
index b1aad36672d0..f526f81778bd 100644
--- a/lib/libsecureboot/verify_file.c
+++ b/lib/libsecureboot/verify_file.c
@@ -581,7 +581,13 @@ verify_file(int fd, const char *filename, off_t off, int severity,
 		else if (rc == VE_FINGERPRINT_NONE && severity < accept_no_fp)
 			rc = VE_UNVERIFIED_OK;
 
-		add_verify_status(&st, rc);
+		/*
+		 * VE_UNVERIFIED_OK only reflects the severity of this request,
+		 * so we can't remember it: a later request for the same file
+		 * may need it to be verified.
+		 */
+		if (rc != VE_UNVERIFIED_OK)
+			add_verify_status(&st, rc);
 
 		/* recheck debug/verbose level next time we are called */
 		if (rc == VE_UNVERIFIED_OK) {