From: Avi Weiss <thnkslprpt@gmail.com>
To: alcioa@amazon.com
Cc: aws-nitro-enclaves-devel@amazon.com,
linux-kernel@vger.kernel.org, andraprs@amazon.com
Subject: [PATCH] samples: nitro_enclaves: reject invalid boot heartbeat
Date: Wed, 11 Nov 2026 15:02:01 +0200 [thread overview]
Message-ID: <20261111130200.1767978-2-thnkslprpt@gmail.com> (raw)
ne_start_enclave_check_booted() expects zero on success and a negative
return value on failure. However, when the received heartbeat is incorrect
or the connection closes before sending one, it returns the result of
read() unchanged.
An incorrect heartbeat therefore returns 1, while EOF returns 0. The caller
treats both nonnegative values as successful enclave boot verification.
Return -EINVAL through the existing cleanup path when heartbeat
validation fails.
Although this is sample code, it demonstrates enclave boot verification and
may be copied or adapted into real enclave-management applications. Better
to correct the example to avoid propagating this false-success behavior
into real implementations.
Amazon's standalone Nitro Enclaves kernel driver does not implement
heartbeat verification. The Nitro Enclaves CLI implements this check
separately in Rust and there I believe it correctly rejects invalid or
missing heartbeats.
Fixes: acc4229c39903 ("nitro_enclaves: Add sample for ioctl interface usage")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
---
diff --git a/samples/nitro_enclaves/ne_ioctl_sample.c b/samples/nitro_enclaves/ne_ioctl_sample.c
index 765b131c73190..a620f81581c2b 100644
--- a/samples/nitro_enclaves/ne_ioctl_sample.c
+++ b/samples/nitro_enclaves/ne_ioctl_sample.c
@@ -744,6 +744,7 @@ static int ne_start_enclave_check_booted(int enclave_fd)
printf("Read %d instead of %d\n", recv_buf,
NE_IMAGE_LOAD_HEARTBEAT_VALUE);
+ rc = -EINVAL;
goto out;
}
reply other threads:[~2026-11-11 13:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261111130200.1767978-2-thnkslprpt@gmail.com \
--to=thnkslprpt@gmail.com \
--cc=alcioa@amazon.com \
--cc=andraprs@amazon.com \
--cc=aws-nitro-enclaves-devel@amazon.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®