From patchwork Tue Oct 3 15:55:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 820931 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y63sM57vLz9s8J for ; Wed, 4 Oct 2017 03:10:15 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 4EB1CC21F7A; Tue, 3 Oct 2017 16:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 97D3DC21F8F; Tue, 3 Oct 2017 16:07:41 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6F4EEC21D63; Tue, 3 Oct 2017 15:55:57 +0000 (UTC) Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by lists.denx.de (Postfix) with ESMTPS id 0BBFAC21D09 for ; Tue, 3 Oct 2017 15:55:57 +0000 (UTC) Received: by mail-wm0-f67.google.com with SMTP id i124so17912486wmf.3 for ; Tue, 03 Oct 2017 08:55:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hTI6wA4JQIWfaCDQa3tcHWQuejlVQE9RHLTWpPnc924=; b=AoX7f96PkN/FXJh5dyBC76AjuvL4oFCVpGnTabGPOG+TatiRNtuM0XrjT17G7r2PcI cjSn44GW9ybfAKScQWieW4WaH2R5UxR8nZNduNYfK33OcSBG3KQtZRtmyfagRIT2rdli maX3qCnUh9MG1o6XlqnPWe1jI3qewtFhMVjqm3LHXMf9sDfGTTrWHtLS0X2s7iNHNfX4 6yuBWL9rB5c4Z4P5TWp221qb8ZCfGt1tZoT6OcyNKG4obaZsjjXtnRd2INzpxVfLKxP6 Hxi18O2SsOyfCdX6admPIrQ4l+yzymByf4AL/qg8M2Gem8DgwAp5rWApyDWd04MrgXTU 8hbg== X-Gm-Message-State: AMCzsaVQKcdCJZcV2NYvhdOBiRgjHMt8GwqBI8MIv94ckI6xk2GyoGYU ebAROzh2KYY3iGtuhkG9Y6UCR+R9 X-Google-Smtp-Source: AOwi7QCXvUDp1QHyzj8GvjQwD+vNXo6Gr/AqaGrZ7e3JdGZXzW69JptdSnSqduxrXolKpHPqdDUH4g== X-Received: by 10.28.90.87 with SMTP id o84mr7661173wmb.132.1507046156302; Tue, 03 Oct 2017 08:55:56 -0700 (PDT) Received: from tfsielt31850.tycofs.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id f17sm5643193wmf.47.2017.10.03.08.55.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:55:55 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= To: u-boot@lists.denx.de Date: Tue, 3 Oct 2017 16:55:50 +0100 Message-Id: <20171003155554.10705-1-git@andred.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003155228.9702-1-git@andred.net> References: <20171003155228.9702-1-git@andred.net> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Oct 2017 16:07:34 +0000 Subject: [U-Boot] [PATCH v2 1/5] SPL: fix printing of image name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: André Draszik 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 Acked-by: Simon Glass Acked-by: Simon Glass --- 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 */ From patchwork Tue Oct 3 15:55:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 820937 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y63v7083Gz9t2h for ; Wed, 4 Oct 2017 03:11:46 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 9F585C21F99; Tue, 3 Oct 2017 16:09:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5285DC21C4E; Tue, 3 Oct 2017 16:07:42 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E8A01C21D63; Tue, 3 Oct 2017 15:55:58 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id 9C193C21D09 for ; Tue, 3 Oct 2017 15:55:58 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id k4so15793098wmc.1 for ; Tue, 03 Oct 2017 08:55:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uSiWg0dzwsAcAJYjMdVHq+v1MBavL3xv5Mibwe3rgH4=; b=WqLf2gB2O3EZIv6xkjAGun1QPubspp2O6Hu0Bhsf0/h6VqnOd1y7MQgEKKc9OO1KMF mRBMG1jveOv7wB7oV6DqFlG88Uarfb2dyLetCtkJRp6ERLCCm9WQR4uyKiMfTQ24WhHV 7ouCk+Ui0KcgamGl02SE5SFLoL15JtFcd9cOPDhm66rjXv/HxekEu0jqNqijdrlbfhEJ iopuuTqLdX1o4cXbUehGjDgN57PKeAekNLEjXLxZiOjJ9WlyQifn76VK9V2v7+YDq+WX vrxh9oOH54fpTpvPFj76OskbZIBASeRCC5dak11LRVofQpDQpr8ne/Xq9h28o2s0YNoD 2Mrg== X-Gm-Message-State: AMCzsaUsJzJ7x1Hy+qdVGtIDsvpYZ9Qkgr0HYG4WTjUcGbOqwLChZc4T ZTc1bQCwZRwFTKaxPOlq3DC7uIUY X-Google-Smtp-Source: AOwi7QCBsVJ01U0HWR5/WTtbHlWkKAU8QFYmhQ7DAwr7B2XZdaj3YrVT+DAJphXj8/a11Gx+i7od5Q== X-Received: by 10.28.129.197 with SMTP id c188mr3787980wmd.58.1507046157876; Tue, 03 Oct 2017 08:55:57 -0700 (PDT) Received: from tfsielt31850.tycofs.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id f17sm5643193wmf.47.2017.10.03.08.55.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:55:56 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= To: u-boot@lists.denx.de Date: Tue, 3 Oct 2017 16:55:51 +0100 Message-Id: <20171003155554.10705-2-git@andred.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003155554.10705-1-git@andred.net> References: <20171003155228.9702-1-git@andred.net> <20171003155554.10705-1-git@andred.net> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Oct 2017 16:07:34 +0000 Subject: [U-Boot] [PATCH v2 2/5] tpm: fix reading of permanent flags X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: André Draszik 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 Acked-by: Simon Glass Acked-by: Simon Glass --- 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; } From patchwork Tue Oct 3 15:55:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 820933 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y63t06sMlz9t2Q for ; Wed, 4 Oct 2017 03:10:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 977CBC21F98; Tue, 3 Oct 2017 16:09:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 12A76C21FA8; Tue, 3 Oct 2017 16:07:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 363ACC21D09; Tue, 3 Oct 2017 15:56:00 +0000 (UTC) Received: from mail-wm0-f68.google.com (mail-wm0-f68.google.com [74.125.82.68]) by lists.denx.de (Postfix) with ESMTPS id C0F53C21D09 for ; Tue, 3 Oct 2017 15:55:59 +0000 (UTC) Received: by mail-wm0-f68.google.com with SMTP id i82so15524311wmd.3 for ; Tue, 03 Oct 2017 08:55:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S3uKQOrrGPRJbo27zjUVleqQZzyJYCsTNFCCOFxNNtI=; b=OeCdJy7ExQTLNH2+87OTf5wvdRxG/euFrxfClDCFtbGQCKowNFgp0ES7L/QXTzGEpz BydqZcRfIp570i9Lc4Q28e2UHICOdZnNThnWHdfajwTF6JrbH7/emfZWMcG9h/B2iLCm xSpNcF3MMyBrw1Eah3RXJlfZ4FSQ2ZZx7Vii9U7DRsLR/rM6J7U4dIL2C38lAg9vmbFF Zm0BZdCGITh9RYNZe1BlAeRS/kd4vH6cEdsNK+bPRx/PFDbfD8WIWzHSN0qDkzxmBsTz 44qWA7CeOl6yhN52EMYblJlOWXqQjk9MeeIWVHVwRlkBtEFEsM3TmihbEOYnyAy2XSF4 udpw== X-Gm-Message-State: AMCzsaVbD673vcQWtwHxCeVVx4EFAF2ZgMEsVJbORmLLusVs61PLl7rT +7sdYqakQ+/j6OuW4Q2Z5SiA/mcg X-Google-Smtp-Source: AOwi7QB7xe5tVpAcn3DI5qQZtk/LjLW8QhhVUO6Qdb4V0W+irQCfTa9h63w0P4mrpU8H62NtVlJ/4Q== X-Received: by 10.28.247.9 with SMTP id v9mr7789798wmh.104.1507046159120; Tue, 03 Oct 2017 08:55:59 -0700 (PDT) Received: from tfsielt31850.tycofs.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id f17sm5643193wmf.47.2017.10.03.08.55.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:55:58 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= To: u-boot@lists.denx.de Date: Tue, 3 Oct 2017 16:55:52 +0100 Message-Id: <20171003155554.10705-3-git@andred.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003155554.10705-1-git@andred.net> References: <20171003155228.9702-1-git@andred.net> <20171003155554.10705-1-git@andred.net> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Oct 2017 16:07:34 +0000 Subject: [U-Boot] [PATCH v2 3/5] tpm: add tpm_get_random() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: André Draszik Signed-off-by: André Draszik Acked-by: Simon Glass Acked-by: Simon Glass --- 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; +} From patchwork Tue Oct 3 15:55:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 820939 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y63x62Qmqz9s8J for ; Wed, 4 Oct 2017 03:13:30 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 12E2DC21F9E; Tue, 3 Oct 2017 16:09:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CE92AC21F9D; Tue, 3 Oct 2017 16:07:43 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 0A56BC21D74; Tue, 3 Oct 2017 15:56:00 +0000 (UTC) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by lists.denx.de (Postfix) with ESMTPS id AAD22C21D09 for ; Tue, 3 Oct 2017 15:56:00 +0000 (UTC) Received: by mail-wm0-f66.google.com with SMTP id b189so13772724wmd.4 for ; Tue, 03 Oct 2017 08:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fXEsgOSWB1JLqCQE/krX8N2TC41kmJqDoql42MFWyDA=; b=TbB5ehQ7Er1a8mhtzZU6kkS0kid0jCVfYIytgac1d8oMXdOawI44c+PA8SpvovvC4V q30rR40D33lcF7JN29W8IBaifxz2newp5PEgXAzMGL1mlq401PrynzRJwZ3fmp0RX1PL JTsZFICWBbdLDUnWzs2toMaz7JYc93M7hsk/MA2VfuiVufq58HIAh9Vs8eFOieX/K9yf Oq33WTTDqpMjorPSK1COeKi7zzrBA+eTCyXQFGPn1hTXtD62bDV4ggHHZb/HaIQNnqI8 7gZAfdr872TiUOE5wCk+tx67FbWIjfAI4MruYvYjzpfWHPk+uLAGRjduKYiB1wB32Tu9 zlew== X-Gm-Message-State: AHPjjUhpx82Cnkedi5qx6jgjYwZr7gn6n/k7WZgSO3xe3gpdr5KMZKMZ fHMZNYgqiBaPSJPwGQgTzjZctE4Z X-Google-Smtp-Source: AOwi7QC7fT9EdpZdtt2Aixj+j6ylaKbxNTRW4+8o5uOH/FFr7fRbGbQBxAuT3OmPxBSYIeI6KDnCjQ== X-Received: by 10.28.132.73 with SMTP id g70mr12667171wmd.33.1507046160109; Tue, 03 Oct 2017 08:56:00 -0700 (PDT) Received: from tfsielt31850.tycofs.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id f17sm5643193wmf.47.2017.10.03.08.55.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:55:59 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= To: u-boot@lists.denx.de Date: Tue, 3 Oct 2017 16:55:53 +0100 Message-Id: <20171003155554.10705-4-git@andred.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003155554.10705-1-git@andred.net> References: <20171003155228.9702-1-git@andred.net> <20171003155554.10705-1-git@andred.net> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Oct 2017 16:07:34 +0000 Subject: [U-Boot] [PATCH v2 4/5] tpm: add more useful NV storage permission flags X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: André Draszik 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 --- 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, From patchwork Tue Oct 3 15:55:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Draszik?= X-Patchwork-Id: 820940 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3y63yB0K0fz9t2M for ; Wed, 4 Oct 2017 03:14:25 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C2242C21FAA; Tue, 3 Oct 2017 16:10:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 9BD24C21FB6; Tue, 3 Oct 2017 16:07:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5DF14C21D7B; Tue, 3 Oct 2017 15:56:02 +0000 (UTC) Received: from mail-wr0-f196.google.com (mail-wr0-f196.google.com [209.85.128.196]) by lists.denx.de (Postfix) with ESMTPS id 0CDA9C21D09 for ; Tue, 3 Oct 2017 15:56:02 +0000 (UTC) Received: by mail-wr0-f196.google.com with SMTP id y44so1099592wry.2 for ; Tue, 03 Oct 2017 08:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=W1mIdvjcPS0SH+ASjxYy5fj9BqxJW4UKx4vEJMdbasg=; b=BWWq5OlfihYKon5LsGd7drTet2MHAaEz4IhhnOj/4/VDpJYCUzIo/si1oiKXYglpkc 2bImJOjxLumz1HprUxyd/RLhJYKskb6vOiwE903rhUecIQ/NVvlbM6tknjJKlmtP634h c+oyaWfoyTxRz3hmQ6hqqlmQBUUU1qUQ3p8Cpy0iegPAQj2sLlyZjNRSoTPuEsgJ/AOX AEK6jNZ3AGzU2TYRfHN+a1CXfJ69tbRymIyEn7xT4AnLDlGq3SbaNX8rW35Z51CAPvV9 y6kN7dDWAL2KuXQBnA0kMyquEt6N68Vh/3+29AXAxajGMY+7J4J+ydmKs0EVUZTr6ags 9LrQ== X-Gm-Message-State: AMCzsaWkvXOavBxa2u9reW6DVpFjkxo5Q/9LyneNwKM8zWUqP2Yv5Mrt PzFgUrsH31nNnB3CWveonAu/tIEb X-Google-Smtp-Source: AOwi7QDREsfV6D/Q2cJN6Av2GxoysyiuAfkNfVwJMAcN7cQcT2dgQ8V9RFdOi0nNUhpGuUgkintt9g== X-Received: by 10.223.169.239 with SMTP id b102mr1787878wrd.171.1507046161431; Tue, 03 Oct 2017 08:56:01 -0700 (PDT) Received: from tfsielt31850.tycofs.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id f17sm5643193wmf.47.2017.10.03.08.56.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:56:00 -0700 (PDT) From: =?utf-8?q?Andr=C3=A9_Draszik?= To: u-boot@lists.denx.de Date: Tue, 3 Oct 2017 16:55:54 +0100 Message-Id: <20171003155554.10705-5-git@andred.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003155554.10705-1-git@andred.net> References: <20171003155228.9702-1-git@andred.net> <20171003155554.10705-1-git@andred.net> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 03 Oct 2017 16:07:34 +0000 Subject: [U-Boot] [PATCH v2 5/5] tpm: add more missing va_end() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: André Draszik 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 Acked-by: Simon Glass Acked-by: Simon Glass --- 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':