* [U-Boot] [PATCH 2/5] tpm: fix reading of permanent flags
2017-10-03 15:52 [U-Boot] [PATCH 1/5] SPL: fix printing of image name André Draszik
@ 2017-10-03 15:52 ` André Draszik
2017-10-03 15:52 ` [U-Boot] [PATCH 3/5] tpm: add tpm_get_random() André Draszik
` (3 subsequent siblings)
4 siblings, 0 replies; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:52 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
The offset of the permanent flags structure is in a different
place in the response compared to what the code is doing,
which gives us a completely result.
Fix by replacing hand-crafted code with generic parser
infrastructure.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
lib/tpm.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/tpm.c b/lib/tpm.c
index d1cf5a8a16..5659fa5e18 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -607,14 +607,24 @@ uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
0x0, 0x0, 0x0, 0x4, /* subcap size */
0x0, 0x0, 0x1, 0x8, /* subcap value */
};
+ const size_t data_size_offset = TPM_HEADER_SIZE;
+ const size_t data_offset = TPM_HEADER_SIZE + sizeof (uint32_t);
uint8_t response[COMMAND_BUFFER_SIZE];
size_t response_length = sizeof(response);
uint32_t err;
+ uint32_t data_size;
err = tpm_sendrecv_command(command, response, &response_length);
if (err)
return err;
- memcpy(pflags, response + TPM_HEADER_SIZE, sizeof(*pflags));
+ if (unpack_byte_string(response, response_length, "d",
+ data_size_offset, &data_size))
+ return TPM_LIB_ERROR;
+ if (data_size < sizeof(*pflags))
+ return TPM_LIB_ERROR;
+ if (unpack_byte_string(response, response_length, "s",
+ data_offset, pflags, sizeof(*pflags)))
+ return TPM_LIB_ERROR;
return 0;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH 3/5] tpm: add tpm_get_random()
2017-10-03 15:52 [U-Boot] [PATCH 1/5] SPL: fix printing of image name André Draszik
2017-10-03 15:52 ` [U-Boot] [PATCH 2/5] tpm: fix reading of permanent flags André Draszik
@ 2017-10-03 15:52 ` André Draszik
2017-10-03 15:52 ` [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags André Draszik
` (2 subsequent siblings)
4 siblings, 0 replies; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:52 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
include/tpm.h | 12 ++++++++++++
lib/tpm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/include/tpm.h b/include/tpm.h
index f88388f353..2a7528dd48 100644
--- a/include/tpm.h
+++ b/include/tpm.h
@@ -651,4 +651,16 @@ uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type);
uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
pubkey_digest[20], uint32_t *handle);
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
+
+/**
+ * Read random bytes from the TPM RNG. The implementation deals with the fact
+ * that the TPM may legally return fewer bytes than requested by retrying
+ * until @p count bytes have been received.
+ *
+ * @param data output buffer for the random bytes
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+uint32_t tpm_get_random(void *data, uint32_t count);
+
#endif /* __TPM_H */
diff --git a/lib/tpm.c b/lib/tpm.c
index 5659fa5e18..42a6591f81 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -1049,3 +1049,46 @@ uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
#endif /* CONFIG_TPM_AUTH_SESSIONS */
+
+uint32_t tpm_get_random(void *data, uint32_t count)
+{
+ const uint8_t command[14] = {
+ 0x0, 0xc1, /* TPM_TAG */
+ 0x0, 0x0, 0x0, 0xe, /* parameter size */
+ 0x0, 0x0, 0x0, 0x46, /* TPM_COMMAND_CODE */
+ };
+ const size_t length_offset = 10;
+ const size_t data_size_offset = 10;
+ const size_t data_offset = 14;
+ uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+ size_t response_length = sizeof(response);
+ uint32_t data_size;
+ uint8_t *out = data;
+
+ while (count > 0) {
+ uint32_t this_bytes = min(count,
+ sizeof (response) - data_offset);
+ uint32_t err;
+
+ if (pack_byte_string(buf, sizeof(buf), "sd",
+ 0, command, sizeof(command),
+ length_offset, this_bytes))
+ return TPM_LIB_ERROR;
+ err = tpm_sendrecv_command(buf, response, &response_length);
+ if (err)
+ return err;
+ if (unpack_byte_string(response, response_length, "d",
+ data_size_offset, &data_size))
+ return TPM_LIB_ERROR;
+ if (data_size > count)
+ return TPM_LIB_ERROR;
+ if (unpack_byte_string(response, response_length, "s",
+ data_offset, out, data_size))
+ return TPM_LIB_ERROR;
+
+ count -= data_size;
+ out += data_size;
+ }
+
+ return 0;
+}
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags
2017-10-03 15:52 [U-Boot] [PATCH 1/5] SPL: fix printing of image name André Draszik
2017-10-03 15:52 ` [U-Boot] [PATCH 2/5] tpm: fix reading of permanent flags André Draszik
2017-10-03 15:52 ` [U-Boot] [PATCH 3/5] tpm: add tpm_get_random() André Draszik
@ 2017-10-03 15:52 ` André Draszik
2017-11-17 14:05 ` Simon Glass
2017-10-03 15:52 ` [U-Boot] [PATCH 5/5] tpm: add more missing va_end() André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
4 siblings, 1 reply; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:52 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
TPM_NV_PER_PPREAD: physical presence needed for reading
TPM_NV_PER_WRITEDEFINE: persistent write lock by writing size 0
TPM_NV_PER_WRITEALL: write in one go
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
include/tpm.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/tpm.h b/include/tpm.h
index 2a7528dd48..760d94865c 100644
--- a/include/tpm.h
+++ b/include/tpm.h
@@ -84,9 +84,12 @@ enum tpm_capability_areas {
};
#define TPM_NV_PER_GLOBALLOCK (1U << 15)
+#define TPM_NV_PER_PPREAD (1U << 16)
#define TPM_NV_PER_PPWRITE (1U << 0)
#define TPM_NV_PER_READ_STCLEAR (1U << 31)
#define TPM_NV_PER_WRITE_STCLEAR (1U << 14)
+#define TPM_NV_PER_WRITEDEFINE (1U << 13)
+#define TPM_NV_PER_WRITEALL (1U << 12)
enum {
TPM_PUBEK_SIZE = 256,
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags
2017-10-03 15:52 ` [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags André Draszik
@ 2017-11-17 14:05 ` Simon Glass
2017-11-17 15:41 ` sjg at google.com
0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2017-11-17 14:05 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:52, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> TPM_NV_PER_PPREAD: physical presence needed for reading
> TPM_NV_PER_WRITEDEFINE: persistent write lock by writing size 0
> TPM_NV_PER_WRITEALL: write in one go
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> include/tpm.h | 3 +++
> 1 file changed, 3 insertions(+)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags
2017-11-17 14:05 ` Simon Glass
@ 2017-11-17 15:41 ` sjg at google.com
0 siblings, 0 replies; 22+ messages in thread
From: sjg at google.com @ 2017-11-17 15:41 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:52, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> TPM_NV_PER_PPREAD: physical presence needed for reading
> TPM_NV_PER_WRITEDEFINE: persistent write lock by writing size 0
> TPM_NV_PER_WRITEALL: write in one go
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> include/tpm.h | 3 +++
> 1 file changed, 3 insertions(+)
Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH 5/5] tpm: add more missing va_end()
2017-10-03 15:52 [U-Boot] [PATCH 1/5] SPL: fix printing of image name André Draszik
` (2 preceding siblings ...)
2017-10-03 15:52 ` [U-Boot] [PATCH 4/5] tpm: add more useful NV storage permission flags André Draszik
@ 2017-10-03 15:52 ` André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
4 siblings, 0 replies; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:52 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
While commit 36d35345b1f6 ("tpm: add missing va_end") added
some missing calls to va_end(), it missed a few places.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
lib/tpm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/tpm.c b/lib/tpm.c
index 42a6591f81..f461e639e0 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -92,6 +92,7 @@ int pack_byte_string(uint8_t *str, size_t size, const char *format, ...)
break;
default:
debug("Couldn't recognize format string\n");
+ va_end(args);
return -1;
}
@@ -170,8 +171,10 @@ int unpack_byte_string(const uint8_t *str, size_t size, const char *format, ...)
return -1;
}
- if (offset + length > size)
+ if (offset + length > size) {
+ va_end(args);
return -1;
+ }
switch (*format) {
case 'b':
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name
2017-10-03 15:52 [U-Boot] [PATCH 1/5] SPL: fix printing of image name André Draszik
` (3 preceding siblings ...)
2017-10-03 15:52 ` [U-Boot] [PATCH 5/5] tpm: add more missing va_end() André Draszik
@ 2017-10-03 15:55 ` André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags André Draszik
` (4 more replies)
4 siblings, 5 replies; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:55 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
The maximum length of the name of the image is
obviously not sizeof(), which is just the
length of a pointer, but IH_NMLEN.
fixes: 62cf11c0921a90c6bd62344f4bc069668e6c698c
("SPL: Limit image name print length")
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
common/spl/spl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 4afbe97fc1..7c7467ecd2 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -154,7 +154,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,
spl_image->os = image_get_os(header);
spl_image->name = image_get_name(header);
debug("spl: payload image: %.*s load addr: 0x%lx size: %d\n",
- (int)sizeof(spl_image->name), spl_image->name,
+ IH_NMLEN, spl_image->name,
spl_image->load_addr, spl_image->size);
#else
/* LEGACY image not supported */
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
@ 2017-10-03 15:55 ` André Draszik
2017-11-17 14:05 ` Simon Glass
2017-10-03 15:55 ` [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random() André Draszik
` (3 subsequent siblings)
4 siblings, 1 reply; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:55 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
The offset of the permanent flags structure is in a different
place in the response compared to what the code is doing,
which gives us a completely useless result.
Fix by replacing hand-crafted code with generic parser
infrastructure.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
lib/tpm.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/tpm.c b/lib/tpm.c
index d1cf5a8a16..5659fa5e18 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -607,14 +607,24 @@ uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
0x0, 0x0, 0x0, 0x4, /* subcap size */
0x0, 0x0, 0x1, 0x8, /* subcap value */
};
+ const size_t data_size_offset = TPM_HEADER_SIZE;
+ const size_t data_offset = TPM_HEADER_SIZE + sizeof (uint32_t);
uint8_t response[COMMAND_BUFFER_SIZE];
size_t response_length = sizeof(response);
uint32_t err;
+ uint32_t data_size;
err = tpm_sendrecv_command(command, response, &response_length);
if (err)
return err;
- memcpy(pflags, response + TPM_HEADER_SIZE, sizeof(*pflags));
+ if (unpack_byte_string(response, response_length, "d",
+ data_size_offset, &data_size))
+ return TPM_LIB_ERROR;
+ if (data_size < sizeof(*pflags))
+ return TPM_LIB_ERROR;
+ if (unpack_byte_string(response, response_length, "s",
+ data_offset, pflags, sizeof(*pflags)))
+ return TPM_LIB_ERROR;
return 0;
}
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags
2017-10-03 15:55 ` [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags André Draszik
@ 2017-11-17 14:05 ` Simon Glass
2017-11-17 15:41 ` sjg at google.com
0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2017-11-17 14:05 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> The offset of the permanent flags structure is in a different
> place in the response compared to what the code is doing,
> which gives us a completely useless result.
>
> Fix by replacing hand-crafted code with generic parser
> infrastructure.
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> lib/tpm.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags
2017-11-17 14:05 ` Simon Glass
@ 2017-11-17 15:41 ` sjg at google.com
0 siblings, 0 replies; 22+ messages in thread
From: sjg at google.com @ 2017-11-17 15:41 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> The offset of the permanent flags structure is in a different
> place in the response compared to what the code is doing,
> which gives us a completely useless result.
>
> Fix by replacing hand-crafted code with generic parser
> infrastructure.
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> lib/tpm.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random()
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags André Draszik
@ 2017-10-03 15:55 ` André Draszik
2017-11-17 14:05 ` Simon Glass
2017-10-03 15:55 ` [U-Boot] [PATCH v2 4/5] tpm: add more useful NV storage permission flags André Draszik
` (2 subsequent siblings)
4 siblings, 1 reply; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:55 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
include/tpm.h | 12 ++++++++++++
lib/tpm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/include/tpm.h b/include/tpm.h
index f88388f353..2a7528dd48 100644
--- a/include/tpm.h
+++ b/include/tpm.h
@@ -651,4 +651,16 @@ uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type);
uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
pubkey_digest[20], uint32_t *handle);
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
+
+/**
+ * Read random bytes from the TPM RNG. The implementation deals with the fact
+ * that the TPM may legally return fewer bytes than requested by retrying
+ * until @p count bytes have been received.
+ *
+ * @param data output buffer for the random bytes
+ * @param count size of output buffer
+ * @return return code of the operation
+ */
+uint32_t tpm_get_random(void *data, uint32_t count);
+
#endif /* __TPM_H */
diff --git a/lib/tpm.c b/lib/tpm.c
index 5659fa5e18..42a6591f81 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -1049,3 +1049,46 @@ uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
#endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
#endif /* CONFIG_TPM_AUTH_SESSIONS */
+
+uint32_t tpm_get_random(void *data, uint32_t count)
+{
+ const uint8_t command[14] = {
+ 0x0, 0xc1, /* TPM_TAG */
+ 0x0, 0x0, 0x0, 0xe, /* parameter size */
+ 0x0, 0x0, 0x0, 0x46, /* TPM_COMMAND_CODE */
+ };
+ const size_t length_offset = 10;
+ const size_t data_size_offset = 10;
+ const size_t data_offset = 14;
+ uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+ size_t response_length = sizeof(response);
+ uint32_t data_size;
+ uint8_t *out = data;
+
+ while (count > 0) {
+ uint32_t this_bytes = min(count,
+ sizeof (response) - data_offset);
+ uint32_t err;
+
+ if (pack_byte_string(buf, sizeof(buf), "sd",
+ 0, command, sizeof(command),
+ length_offset, this_bytes))
+ return TPM_LIB_ERROR;
+ err = tpm_sendrecv_command(buf, response, &response_length);
+ if (err)
+ return err;
+ if (unpack_byte_string(response, response_length, "d",
+ data_size_offset, &data_size))
+ return TPM_LIB_ERROR;
+ if (data_size > count)
+ return TPM_LIB_ERROR;
+ if (unpack_byte_string(response, response_length, "s",
+ data_offset, out, data_size))
+ return TPM_LIB_ERROR;
+
+ count -= data_size;
+ out += data_size;
+ }
+
+ return 0;
+}
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random()
2017-10-03 15:55 ` [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random() André Draszik
@ 2017-11-17 14:05 ` Simon Glass
2017-11-17 15:41 ` sjg at google.com
0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2017-11-17 14:05 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
Please add a commit message. Also where is this used? Is it dead code?
Acked-by: Simon Glass <sjg@chromium.org>
> From: André Draszik <adraszik@tycoint.com>
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> include/tpm.h | 12 ++++++++++++
> lib/tpm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 55 insertions(+)
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random()
2017-11-17 14:05 ` Simon Glass
@ 2017-11-17 15:41 ` sjg at google.com
2017-11-17 15:47 ` Simon Glass
0 siblings, 1 reply; 22+ messages in thread
From: sjg at google.com @ 2017-11-17 15:41 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
Please add a commit message. Also where is this used? Is it dead code?
Acked-by: Simon Glass <sjg@chromium.org>
> From: André Draszik <adraszik@tycoint.com>
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> include/tpm.h | 12 ++++++++++++
> lib/tpm.c | 43 +++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 55 insertions(+)
Applied to u-boot-dm thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random()
2017-11-17 15:41 ` sjg at google.com
@ 2017-11-17 15:47 ` Simon Glass
0 siblings, 0 replies; 22+ messages in thread
From: Simon Glass @ 2017-11-17 15:47 UTC (permalink / raw)
To: u-boot
Hi.
On 17 November 2017 at 08:41, <sjg@google.com> wrote:
>
> On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
>
> Please add a commit message. Also where is this used? Is it dead code?
>
> Acked-by: Simon Glass <sjg@chromium.org>
>
I applied this with changes:
- added a commit message
- added a cast to fix a build warning on (e.g.) sandbox_noblk
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 4/5] tpm: add more useful NV storage permission flags
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random() André Draszik
@ 2017-10-03 15:55 ` André Draszik
2017-10-03 15:55 ` [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end() André Draszik
2017-11-01 9:09 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
4 siblings, 0 replies; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:55 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
TPM_NV_PER_PPREAD: physical presence needed for reading
TPM_NV_PER_WRITEDEFINE: persistent write lock by writing size 0
TPM_NV_PER_WRITEALL: write in one go
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
include/tpm.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/tpm.h b/include/tpm.h
index 2a7528dd48..760d94865c 100644
--- a/include/tpm.h
+++ b/include/tpm.h
@@ -84,9 +84,12 @@ enum tpm_capability_areas {
};
#define TPM_NV_PER_GLOBALLOCK (1U << 15)
+#define TPM_NV_PER_PPREAD (1U << 16)
#define TPM_NV_PER_PPWRITE (1U << 0)
#define TPM_NV_PER_READ_STCLEAR (1U << 31)
#define TPM_NV_PER_WRITE_STCLEAR (1U << 14)
+#define TPM_NV_PER_WRITEDEFINE (1U << 13)
+#define TPM_NV_PER_WRITEALL (1U << 12)
enum {
TPM_PUBEK_SIZE = 256,
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end()
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
` (2 preceding siblings ...)
2017-10-03 15:55 ` [U-Boot] [PATCH v2 4/5] tpm: add more useful NV storage permission flags André Draszik
@ 2017-10-03 15:55 ` André Draszik
2017-11-17 14:06 ` Simon Glass
2017-11-01 9:09 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
4 siblings, 1 reply; 22+ messages in thread
From: André Draszik @ 2017-10-03 15:55 UTC (permalink / raw)
To: u-boot
From: André Draszik <adraszik@tycoint.com>
While commit 36d35345b1f6 ("tpm: add missing va_end") added
some missing calls to va_end(), it missed a few places.
Signed-off-by: André Draszik <adraszik@tycoint.com>
---
lib/tpm.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/tpm.c b/lib/tpm.c
index 42a6591f81..f461e639e0 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -92,6 +92,7 @@ int pack_byte_string(uint8_t *str, size_t size, const char *format, ...)
break;
default:
debug("Couldn't recognize format string\n");
+ va_end(args);
return -1;
}
@@ -170,8 +171,10 @@ int unpack_byte_string(const uint8_t *str, size_t size, const char *format, ...)
return -1;
}
- if (offset + length > size)
+ if (offset + length > size) {
+ va_end(args);
return -1;
+ }
switch (*format) {
case 'b':
--
2.14.2
^ permalink raw reply related [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end()
2017-10-03 15:55 ` [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end() André Draszik
@ 2017-11-17 14:06 ` Simon Glass
2017-11-17 15:41 ` sjg at google.com
0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2017-11-17 14:06 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> While commit 36d35345b1f6 ("tpm: add missing va_end") added
> some missing calls to va_end(), it missed a few places.
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> lib/tpm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end()
2017-11-17 14:06 ` Simon Glass
@ 2017-11-17 15:41 ` sjg at google.com
0 siblings, 0 replies; 22+ messages in thread
From: sjg at google.com @ 2017-11-17 15:41 UTC (permalink / raw)
To: u-boot
On 3 October 2017 at 09:55, André Draszik <git@andred.net> wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> While commit 36d35345b1f6 ("tpm: add missing va_end") added
> some missing calls to va_end(), it missed a few places.
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
> ---
> lib/tpm.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread
* [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name
2017-10-03 15:55 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
` (3 preceding siblings ...)
2017-10-03 15:55 ` [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end() André Draszik
@ 2017-11-01 9:09 ` André Draszik
2017-11-17 14:05 ` Simon Glass
4 siblings, 1 reply; 22+ messages in thread
From: André Draszik @ 2017-11-01 9:09 UTC (permalink / raw)
To: u-boot
Hi,
On Tue, 2017-10-03 at 16:55 +0100, André Draszik wrote:
> From: André Draszik <adraszik@tycoint.com>
>
> The maximum length of the name of the image is
> obviously not sizeof(), which is just the
> length of a pointer, but IH_NMLEN.
>
> fixes: 62cf11c0921a90c6bd62344f4bc069668e6c698c
> ("SPL: Limit image name print length")
>
> Signed-off-by: André Draszik <adraszik@tycoint.com>
I see these patches haven't been merged yet, is there anything wrong?
Cheers,
Andre'
^ permalink raw reply [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name
2017-11-01 9:09 ` [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name André Draszik
@ 2017-11-17 14:05 ` Simon Glass
2017-11-17 15:41 ` sjg at google.com
0 siblings, 1 reply; 22+ messages in thread
From: Simon Glass @ 2017-11-17 14:05 UTC (permalink / raw)
To: u-boot
Hi Andre,
On 1 November 2017 at 03:09, André Draszik <git@andred.net> wrote:
>
> Hi,
>
>
> On Tue, 2017-10-03 at 16:55 +0100, André Draszik wrote:
> > From: André Draszik <adraszik@tycoint.com>
> >
> > The maximum length of the name of the image is
> > obviously not sizeof(), which is just the
> > length of a pointer, but IH_NMLEN.
> >
> > fixes: 62cf11c0921a90c6bd62344f4bc069668e6c698c
> > ("SPL: Limit image name print length")
> >
> > Signed-off-by: André Draszik <adraszik@tycoint.com>
>
> I see these patches haven't been merged yet, is there anything wrong?
I just found them in my queue, but was not on cc.
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 22+ messages in thread* [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name
2017-11-17 14:05 ` Simon Glass
@ 2017-11-17 15:41 ` sjg at google.com
0 siblings, 0 replies; 22+ messages in thread
From: sjg at google.com @ 2017-11-17 15:41 UTC (permalink / raw)
To: u-boot
Hi Andre,
On 1 November 2017 at 03:09, André Draszik <git@andred.net> wrote:
>
> Hi,
>
>
> On Tue, 2017-10-03 at 16:55 +0100, André Draszik wrote:
> > From: André Draszik <adraszik@tycoint.com>
> >
> > The maximum length of the name of the image is
> > obviously not sizeof(), which is just the
> > length of a pointer, but IH_NMLEN.
> >
> > fixes: 62cf11c0921a90c6bd62344f4bc069668e6c698c
> > ("SPL: Limit image name print length")
> >
> > Signed-off-by: André Draszik <adraszik@tycoint.com>
>
> I see these patches haven't been merged yet, is there anything wrong?
I just found them in my queue, but was not on cc.
Acked-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm thanks!
^ permalink raw reply [flat|nested] 22+ messages in thread