Skip to content

Commit 6927cd4

Browse files
[AUTO-CHERRYPICK] [High] patch vendored openssl code in hvloader in 2.0 - branch main (#13147)
Co-authored-by: Tobias Brick <39196763+tobiasb-ms@users.noreply.github.com>
1 parent eb0be70 commit 6927cd4

3 files changed

Lines changed: 76 additions & 2 deletions

File tree

SPECS-SIGNED/hvloader-signed/hvloader-signed.spec

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Summary: Signed HvLoader.efi for %{buildarch} systems
77
Name: hvloader-signed-%{buildarch}
88
Version: 1.0.1
9-
Release: 9%{?dist}
9+
Release: 10%{?dist}
1010
License: MIT
1111
Vendor: Microsoft Corporation
1212
Distribution: Mariner
@@ -69,6 +69,9 @@ popd
6969
/boot/efi/HvLoader.efi
7070

7171
%changelog
72+
* Wed Mar 26 2025 Tobias Brick <tobiasb@microsoft.com> - 1.0.1-10
73+
- Bump release for consistency with hvloader spec.
74+
7275
* Fri Mar 21 2025 Daniel McIlvaney <damcilva@microsoft.com> - 1.0.1-9
7376
- Update version for consistency with hvloader spec
7477

SPECS/hvloader/hvloader.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: HvLoader.efi is an EFI application for loading an external hypervisor loader.
55
Name: hvloader
66
Version: 1.0.1
7-
Release: 9%{?dist}
7+
Release: 10%{?dist}
88
License: MIT
99
Vendor: Microsoft Corporation
1010
Distribution: Mariner
@@ -28,6 +28,7 @@ Patch10: CVE-2023-0465.patch
2828
Patch11: CVE-2024-0727.patch
2929
Patch12: CVE-2023-3817.patch
3030
Patch13: CVE-2023-5678.patch
31+
Patch14: vendored-openssl-1.1.1-Only-free-the-read-buffers-if-we-re-not-using-them.patch
3132

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

7576
%changelog
77+
* Tue Mar 25 2025 Tobias Brick <tobiasb@microsoft.com> - 1.0.1-10
78+
- Patch vendored openssl to only free read buffers if not in use.
79+
7680
* Fri Mar 21 2025 Daniel McIlvaney <damcilva@microsoft.com> - 1.0.1-9
7781
- Reconcile merge issue
7882

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From f7a045f3143fc6da2ee66bf52d8df04829590dd4 Mon Sep 17 00:00:00 2001
2+
From: Watson Ladd <watsonbladd@gmail.com>
3+
Date: Wed, 24 Apr 2024 11:26:56 +0100
4+
Subject: [PATCH] Only free the read buffers if we're not using them
5+
6+
If we're part way through processing a record, or the application has
7+
not released all the records then we should not free our buffer because
8+
they are still needed.
9+
10+
Reviewed-by: Tomas Mraz <tomas@openssl.org>
11+
Reviewed-by: Neil Horman <nhorman@openssl.org>
12+
Reviewed-by: Matt Caswell <matt@openssl.org>
13+
---
14+
CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c | 9 +++++++++
15+
CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h | 1 +
16+
CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c | 3 +++
17+
3 files changed, 13 insertions(+)
18+
19+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
20+
index 1db1712a0..525c3abf4 100644
21+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
22+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/rec_layer_s3.c
23+
@@ -81,6 +81,15 @@ int RECORD_LAYER_read_pending(const RECORD_LAYER *rl)
24+
return SSL3_BUFFER_get_left(&rl->rbuf) != 0;
25+
}
26+
27+
+int RECORD_LAYER_data_present(const RECORD_LAYER *rl)
28+
+{
29+
+ if (rl->rstate == SSL_ST_READ_BODY)
30+
+ return 1;
31+
+ if (RECORD_LAYER_processed_read_pending(rl))
32+
+ return 1;
33+
+ return 0;
34+
+}
35+
+
36+
/* Checks if we have decrypted unread record data pending */
37+
int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl)
38+
{
39+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
40+
index af56206e0..513ab3988 100644
41+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
42+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/record/record.h
43+
@@ -197,6 +197,7 @@ void RECORD_LAYER_release(RECORD_LAYER *rl);
44+
int RECORD_LAYER_read_pending(const RECORD_LAYER *rl);
45+
int RECORD_LAYER_processed_read_pending(const RECORD_LAYER *rl);
46+
int RECORD_LAYER_write_pending(const RECORD_LAYER *rl);
47+
+int RECORD_LAYER_data_present(const RECORD_LAYER *rl);
48+
void RECORD_LAYER_reset_read_sequence(RECORD_LAYER *rl);
49+
void RECORD_LAYER_reset_write_sequence(RECORD_LAYER *rl);
50+
int RECORD_LAYER_is_sslv2_record(RECORD_LAYER *rl);
51+
diff --git a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
52+
index c01ad8291..356d65cb6 100644
53+
--- a/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
54+
+++ b/CryptoPkg/Library/OpensslLib/openssl/ssl/ssl_lib.c
55+
@@ -5248,6 +5248,9 @@ int SSL_free_buffers(SSL *ssl)
56+
if (RECORD_LAYER_read_pending(rl) || RECORD_LAYER_write_pending(rl))
57+
return 0;
58+
59+
+ if (RECORD_LAYER_data_present(rl))
60+
+ return 0;
61+
+
62+
RECORD_LAYER_release(rl);
63+
return 1;
64+
}
65+
--
66+
2.33.8
67+

0 commit comments

Comments
 (0)