summaryrefslogtreecommitdiffstats
path: root/recipes-security
diff options
context:
space:
mode:
authorPeter Griffin <peter.griffin@linaro.org>2020-01-10 13:06:30 +0100
committerOtavio Salvador <otavio@ossystems.com.br>2020-01-14 23:04:44 -0300
commitdd67d23dddb6fb50170edc541a844143d1dffc57 (patch)
tree6873f5e89526851bb7551ee4b43107e61ffd3a02 /recipes-security
parent7b49a35b976bc76ff9de66191ad09558639e000b (diff)
downloadmeta-freescale-dd67d23dddb6fb50170edc541a844143d1dffc57.tar.gz
optee-client_3.2.0.imx: remove 0001-libteec-refactor-_dprintf.patch
This patch no longer applies as it is already included in the new optee-client tag. Fixes: 020d818 Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Diffstat (limited to 'recipes-security')
-rw-r--r--recipes-security/optee-imx/optee-client/0001-libteec-refactor-_dprintf.patch171
-rw-r--r--recipes-security/optee-imx/optee-client_3.2.0.imx.bb3
2 files changed, 1 insertions, 173 deletions
diff --git a/recipes-security/optee-imx/optee-client/0001-libteec-refactor-_dprintf.patch b/recipes-security/optee-imx/optee-client/0001-libteec-refactor-_dprintf.patch
deleted file mode 100644
index 1c053f38..00000000
--- a/recipes-security/optee-imx/optee-client/0001-libteec-refactor-_dprintf.patch
+++ /dev/null
@@ -1,171 +0,0 @@
1Upstream-Status: Backport 3.3.0
2
3Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
4---
5From 0361f9b21bb1acfaf23323a121f542fe03dcd2c8 Mon Sep 17 00:00:00 2001
6From: Jerome Forissier <jerome.forissier@linaro.org>
7Date: Thu, 5 Jul 2018 15:15:31 +0200
8Subject: [PATCH] libteec: refactor _dprintf()
9MIME-Version: 1.0
10Content-Type: text/plain; charset=UTF-8
11Content-Transfer-Encoding: 8bit
12
13GCC8.1 gives an error when compiling _dprintf():
14
15src/teec_trace.c: In function ‘_dprintf’:
16src/teec_trace.c:110:5: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 246 [-Werror=format-truncation=]
17 "%s [%d] %s:%s:%d: %s",
18 ^~~~~~~~~~~~~~~~~~~~~~
19src/teec_trace.c:112:11:
20 line, raw);
21 ~~~
22src/teec_trace.c:109:3: note: ‘snprintf’ output 11 or more bytes (assuming 266) into a destination of size 256
23 snprintf(prefixed, MAX_PRINT_SIZE,
24 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25 "%s [%d] %s:%s:%d: %s",
26 ~~~~~~~~~~~~~~~~~~~~~~~
27 trace_level_strings[level], thread_id, prefix, func,
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 line, raw);
30 ~~~~~~~~~~
31
32Fix this error by using a single output buffer, printing the prefix first
33then the other arguments with the supplied format.
34
35In addition, further simplify the function by getting rid of things that
36do not make much sense:
37- Remove the 'flen' parameter, which is only ever set to zero or
38 strlen(__func__).
39- Remove the TRACE_FUNC_LENGTH_CST macro which is not set by default and
40 does not seem very useful.
41- Change the return type to void because callers do not care about success
42 or failure.
43
44Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
45Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
46---
47 libteec/src/teec_trace.c | 63 +++++++++++++++---------------------------------
48 public/teec_trace.h | 8 +++---
49 2 files changed, 23 insertions(+), 48 deletions(-)
50
51diff --git a/libteec/src/teec_trace.c b/libteec/src/teec_trace.c
52index 78b79d6..3a2a0da 100644
53--- a/libteec/src/teec_trace.c
54+++ b/libteec/src/teec_trace.c
55@@ -47,7 +47,6 @@
56 * PPPP: MMMMM [FFFFFFFFFFFFFFF : LLLLL]
57 */
58 #define MAX_PRINT_SIZE 256
59-#define MAX_FUNC_PRINT_SIZE 32
60
61 #ifdef TEEC_LOG_FILE
62 static void log_to_file(const char *buffer)
63@@ -69,57 +68,33 @@ static const char * const trace_level_strings[] = {
64 "", "ERR", "INF", "DBG", "FLW"
65 };
66
67-int _dprintf(const char *function, int flen, int line, int level,
68- const char *prefix, const char *fmt, ...)
69+void _dprintf(const char *function, int line, int level, const char *prefix,
70+ const char *fmt, ...)
71 {
72- char raw[MAX_PRINT_SIZE];
73- char prefixed[MAX_PRINT_SIZE];
74- char *to_print = NULL;
75- const char *func;
76- int err;
77+ char msg[MAX_PRINT_SIZE];
78+ int n = 0;
79 va_list ap;
80
81- va_start(ap, fmt);
82- err = vsnprintf(raw, sizeof(raw), fmt, ap);
83- va_end(ap);
84-
85 if (function) {
86-#ifdef TRACE_FUNC_LENGTH_CST
87- char func_buf[MAX_FUNC_PRINT_SIZE];
88- /* Limit the function name to MAX_FUNC_PRINT_SIZE characters. */
89- strncpy(func_buf, function, flen > MAX_FUNC_PRINT_SIZE ?
90- (MAX_FUNC_PRINT_SIZE - 1) : flen);
91- if (flen < (MAX_FUNC_PRINT_SIZE - 1)) {
92- memset(func_buf + flen, 0x20,
93- (MAX_FUNC_PRINT_SIZE - flen));
94- }
95- func_buf[MAX_FUNC_PRINT_SIZE - 1] = '\0';
96- func = func_buf;
97-#else
98- (void)flen;
99- func = function;
100-#endif
101+ int thread_id = syscall(SYS_gettid);
102
103- /*
104- * pthread_self returns the POSIX tid which is different from
105- * the kernel id
106- */
107- int thread_id = syscall(SYS_gettid); /* perf issue ? */
108-
109- snprintf(prefixed, MAX_PRINT_SIZE,
110- "%s [%d] %s:%s:%d: %s",
111- trace_level_strings[level], thread_id, prefix, func,
112- line, raw);
113- to_print = prefixed;
114- } else {
115- to_print = raw;
116+ n = snprintf(msg, sizeof(msg), "%s [%d] %s:%s:%d: ",
117+ trace_level_strings[level], thread_id, prefix,
118+ function, line);
119+ if (n < 0)
120+ return;
121 }
122
123- fprintf(stdout, "%s", to_print);
124-
125- log_to_file(to_print);
126+ if ((size_t)n < sizeof(msg)) {
127+ va_start(ap, fmt);
128+ n = vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
129+ va_end(ap);
130+ if (n < 0)
131+ return;
132+ }
133
134- return err;
135+ fprintf(stdout, "%s", msg);
136+ log_to_file(msg);
137 }
138
139 #if (defined(DEBUGLEVEL_3) || defined(DEBUGLEVEL_true) || defined(DEBUGLEVEL_4))
140diff --git a/public/teec_trace.h b/public/teec_trace.h
141index 28e290c..f75358f 100644
142--- a/public/teec_trace.h
143+++ b/public/teec_trace.h
144@@ -91,12 +91,12 @@ extern "C" {
145 #define __PRINTFLIKE(__fmt, __varargs) __attribute__\
146 ((__format__(__printf__, __fmt, __varargs)))
147
148-int _dprintf(const char *function, int flen, int line, int level,
149- const char *prefix, const char *fmt, ...) __PRINTFLIKE(6, 7);
150+void _dprintf(const char *function, int line, int level, const char *prefix,
151+ const char *fmt, ...) __PRINTFLIKE(5, 6);
152
153 #define dprintf(level, x...) do { \
154 if ((level) <= DEBUGLEVEL) { \
155- _dprintf(__func__, strlen(__func__), __LINE__, level, \
156+ _dprintf(__func__, __LINE__, level, \
157 BINARY_PREFIX, x); \
158 } \
159 } while (0)
160@@ -118,7 +118,7 @@ int _dprintf(const char *function, int flen, int line, int level,
161
162 #define dprintf_raw(level, x...) do { \
163 if ((level) <= DEBUGLEVEL) \
164- _dprintf(0, 0, 0, (level), BINARY_PREFIX, x); \
165+ _dprintf(0, 0, (level), BINARY_PREFIX, x); \
166 } while (0)
167
168 #define EMSG_RAW(fmt, ...) dprintf_raw(TRACE_ERROR, fmt, ##__VA_ARGS__)
169--
1702.7.4
171
diff --git a/recipes-security/optee-imx/optee-client_3.2.0.imx.bb b/recipes-security/optee-imx/optee-client_3.2.0.imx.bb
index f572d003..4fed4c10 100644
--- a/recipes-security/optee-imx/optee-client_3.2.0.imx.bb
+++ b/recipes-security/optee-imx/optee-client_3.2.0.imx.bb
@@ -15,8 +15,7 @@ SRCREV = "71a9bef78fff2d5d4db8a2307d3b91e2aa671dc9"
15 15
16FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 16FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
17 17
18SRC_URI_append = " file://0001-libteec-refactor-_dprintf.patch \ 18SRC_URI_append = " file://tee-supplicant.service"
19 file://tee-supplicant.service"
20 19
21S = "${WORKDIR}/git" 20S = "${WORKDIR}/git"
22SYSTEMD_SERVICE_${PN} = "tee-supplicant.service" 21SYSTEMD_SERVICE_${PN} = "tee-supplicant.service"