| 1 |
From: Helmut Grohne <[email protected]> |
| 2 |
Date: Sun, 5 Feb 2023 14:23:48 +0100 |
| 3 |
Subject: [PATCH] CVE-2022-45142: gsskrb5: fix accidental logic inversions |
| 4 |
|
| 5 |
The referenced commit attempted to fix miscompilations with gcc-9 and |
| 6 |
gcc-10 by changing `memcmp(...)` to `memcmp(...) != 0`. Unfortunately, |
| 7 |
it also inverted the result of the comparison in two occasions. This |
| 8 |
inversion happened during backporting the patch to 7.7.1 and 7.8.0. |
| 9 |
|
| 10 |
Fixes: f6edaafcfefd ("gsskrb5: CVE-2022-3437 Use constant-time memcmp() |
| 11 |
for arcfour unwrap") |
| 12 |
Signed-off-by: Helmut Grohne <[email protected]> |
| 13 |
--- |
| 14 |
lib/gssapi/krb5/arcfour.c | 4 ++-- |
| 15 |
1 file changed, 2 insertions(+), 2 deletions(-) |
| 16 |
|
| 17 |
diff --git a/lib/gssapi/krb5/arcfour.c b/lib/gssapi/krb5/arcfour.c |
| 18 |
index aa03cbe..c6c15eb 100644 |
| 19 |
--- a/lib/gssapi/krb5/arcfour.c |
| 20 |
+++ b/lib/gssapi/krb5/arcfour.c |
| 21 |
@@ -365,7 +365,7 @@ _gssapi_verify_mic_arcfour(OM_uint32 * minor_status, |
| 22 |
return GSS_S_FAILURE; |
| 23 |
} |
| 24 |
|
| 25 |
- cmp = (ct_memcmp(cksum_data, p + 8, 8) == 0); |
| 26 |
+ cmp = (ct_memcmp(cksum_data, p + 8, 8) != 0); |
| 27 |
if (cmp) { |
| 28 |
*minor_status = 0; |
| 29 |
return GSS_S_BAD_MIC; |
| 30 |
@@ -730,7 +730,7 @@ OM_uint32 _gssapi_unwrap_arcfour(OM_uint32 *minor_status, |
| 31 |
return GSS_S_FAILURE; |
| 32 |
} |
| 33 |
|
| 34 |
- cmp = (ct_memcmp(cksum_data, p0 + 16, 8) == 0); /* SGN_CKSUM */ |
| 35 |
+ cmp = (ct_memcmp(cksum_data, p0 + 16, 8) != 0); /* SGN_CKSUM */ |
| 36 |
if (cmp) { |
| 37 |
_gsskrb5_release_buffer(minor_status, output_message_buffer); |
| 38 |
*minor_status = 0; |