1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
From b34da057dc9eb01df30b436ba9cb047c21fb0151 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Tue, 2 Jun 2020 21:45:17 +0200
Subject: [PATCH 3/3] valgrind: check if session ticket key is used without
initialization
commit 3d7fae761e65e9d0f16d7247ee8a464d4fe002da from https://gitlab.com/gnutls/gnutls.git
This adds a valgrind client request for
session->key.session_ticket_key to make sure that it is not used
without initialization.
Upstream-Status: Backport
Signed-off-by: Daiki Ueno <ueno@gnu.org>
Signed-off-by: Haiqing Bai <Haiqing.Bai@windriver.com>
---
lib/state.c | 5 ++++-
lib/stek.c | 8 ++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/state.c b/lib/state.c
index 98900c1..cabdf7d 100644
--- a/lib/state.c
+++ b/lib/state.c
@@ -578,9 +578,12 @@ int gnutls_init(gnutls_session_t * session, unsigned int flags)
if (flags & GNUTLS_CLIENT)
VALGRIND_MAKE_MEM_UNDEFINED((*session)->security_parameters.client_random,
GNUTLS_RANDOM_SIZE);
- if (flags & GNUTLS_SERVER)
+ if (flags & GNUTLS_SERVER) {
VALGRIND_MAKE_MEM_UNDEFINED((*session)->security_parameters.server_random,
GNUTLS_RANDOM_SIZE);
+ VALGRIND_MAKE_MEM_UNDEFINED((*session)->key.session_ticket_key,
+ TICKET_MASTER_KEY_SIZE);
+ }
}
#endif
handshake_internal_state_clear1(*session);
diff --git a/lib/stek.c b/lib/stek.c
index 5ab9e7d..316555b 100644
--- a/lib/stek.c
+++ b/lib/stek.c
@@ -21,6 +21,9 @@
*/
#include "gnutls_int.h"
#include "stek.h"
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
#define NAME_POS (0)
#define KEY_POS (TICKET_KEY_NAME_SIZE)
@@ -143,6 +146,11 @@ static int rotate(gnutls_session_t session)
call_rotation_callback(session, key, t);
session->key.totp.last_result = t;
memcpy(session->key.session_ticket_key, key, sizeof(key));
+#ifdef HAVE_VALGRIND_MEMCHECK_H
+ if (RUNNING_ON_VALGRIND)
+ VALGRIND_MAKE_MEM_DEFINED(session->key.session_ticket_key,
+ TICKET_MASTER_KEY_SIZE);
+#endif
session->key.totp.was_rotated = 1;
} else if (t < 0) {
--
2.17.1
|