Skip to content

[High] patch vendored openssl code in hvloader in 2.0 #13113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion SPECS-SIGNED/hvloader-signed/hvloader-signed.spec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Summary: Signed HvLoader.efi for %{buildarch} systems
Name: hvloader-signed-%{buildarch}
Version: 1.0.1
Release: 9%{?dist}
Release: 10%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Expand Down Expand Up @@ -69,6 +69,9 @@ popd
/boot/efi/HvLoader.efi

%changelog
* Wed Mar 26 2025 Tobias Brick <[email protected]> - 1.0.1-10
- Bump release for consistency with hvloader spec.

* Fri Mar 21 2025 Daniel McIlvaney <[email protected]> - 1.0.1-9
- Update version for consistency with hvloader spec

Expand Down
6 changes: 5 additions & 1 deletion SPECS/hvloader/hvloader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Summary: HvLoader.efi is an EFI application for loading an external hypervisor loader.
Name: hvloader
Version: 1.0.1
Release: 9%{?dist}
Release: 10%{?dist}
License: MIT
Vendor: Microsoft Corporation
Distribution: Mariner
Expand All @@ -28,6 +28,7 @@ Patch10: CVE-2023-0465.patch
Patch11: CVE-2024-0727.patch
Patch12: CVE-2023-3817.patch
Patch13: CVE-2023-5678.patch
Patch14: vendored-openssl-1.1.1-Only-free-the-read-buffers-if-we-re-not-using-them.patch

BuildRequires: bc
BuildRequires: gcc
Expand Down Expand Up @@ -73,6 +74,9 @@ cp ./Build/MdeModule/RELEASE_GCC5/X64/MdeModulePkg/Application/%{name_github}-%{
/boot/efi/HvLoader.efi

%changelog
* Tue Mar 25 2025 Tobias Brick <[email protected]> - 1.0.1-10
- Patch vendored openssl to only free read buffers if not in use.

* Fri Mar 21 2025 Daniel McIlvaney <[email protected]> - 1.0.1-9
- Reconcile merge issue

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From f7a045f3143fc6da2ee66bf52d8df04829590dd4 Mon Sep 17 00:00:00 2001
From: Watson Ladd <[email protected]>
Date: Wed, 24 Apr 2024 11:26:56 +0100
Subject: [PATCH] Only free the read buffers if we're not using them

If we're part way through processing a record, or the application has
not released all the records then we should not free our buffer because
they are still needed.

Reviewed-by: Tomas Mraz <[email protected]>
Reviewed-by: Neil Horman <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
---
CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c | 9 +++++++++
CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h | 1 +
CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c | 3 +++
3 files changed, 13 insertions(+)

diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
index 1db1712a0..525c3abf4 100644
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
@@ -81,6 +81,15 @@ int RECORD_LAYER_read_pending(const RECORD_LAYER *rl)
return SSL3_BUFFER_get_left(&rl->rbuf) != 0;
}

+int RECORD_LAYER_data_present(const RECORD_LAYER *rl)
+{
+ if (rl->rstate == SSL_ST_READ_BODY)
+ return 1;
+ if (RECORD_LAYER_processed_read_pending(rl))
+ return 1;
+ return 0;
+}
+
/* Checks if we have decrypted unread record data pending */
int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl)
{
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
index af56206e0..513ab3988 100644
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
@@ -197,6 +197,7 @@ void RECORD_LAYER_release(RECORD_LAYER *rl);
int RECORD_LAYER_read_pending(const RECORD_LAYER *rl);
int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl);
int RECORD_LAYER_write_pending(const RECORD_LAYER *rl);
+int RECORD_LAYER_data_present(const RECORD_LAYER *rl);
void RECORD_LAYER_reset_read_sequence(RECORD_LAYER *rl);
void RECORD_LAYER_reset_write_sequence(RECORD_LAYER *rl);
int RECORD_LAYER_is_sslv2_record(RECORD_LAYER *rl);
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
index c01ad8291..356d65cb6 100644
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
@@ -5248,6 +5248,9 @@ int SSL_free_buffers(SSL *ssl)
if (RECORD_LAYER_read_pending(rl) || RECORD_LAYER_write_pending(rl))
return 0;

+ if (RECORD_LAYER_data_present(rl))
+ return 0;
+
RECORD_LAYER_release(rl);
return 1;
}
--
2.33.8

Loading