From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jonas Rebmann <jre@pengutronix.de>
Cc: BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH v2] tlv: Add tlv_bind_soc_uid mapping
Date: Tue, 18 Nov 2025 09:40:06 +0100 [thread overview]
Message-ID: <aRww5p7AxPtgEmgm@pengutronix.de> (raw)
In-Reply-To: <20251117-tlv_bind_serial-v2-1-60c7b1e3e81b@pengutronix.de>
On Mon, Nov 17, 2025 at 06:14:06PM +0100, Jonas Rebmann wrote:
> Particularly when using secure boot with signed TLVs, it may be required
> to issue and sign TLVs for specific units. As typically all units of a
> board are compiled to validate TLVs against the same key, a "binding"
> mechanism is needed if interchange of TLVs across those units must be
> prevented. This mapping binds against the UID of the SoC, rendering a
> signed TLV with such a field invalid for all but the one unit.
>
> When generating TLVs that use this mapping, the exact case-sensitive
> string representation of the SoC UID must be taken into account.
Do we really want to have this case-sensitive? I am not sure we're not
creating problems with this once somebody changes the case for
compatibility with the kernel, it was accidently wrong etc.
>
> Add the special mapping tlv_bind_soc_uid that aborts TLV parsing if the
> supplied string does not match the SoC UID number.
>
> Include this mapping in barebox_tlv_v1_mappings with tag 0x0024 to make
> it available in testing and in other setups using the generic tlv
> parsers.
>
> Set up tlv_register_default as a late initcall so that it's loaded after
> the SoC UID was initialized.
>
> Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
> ---
> Changes in v2:
> - Switch to using barebox_get_soc_uid and rename and reword everything
> accordingly (serial number -> soc uid)
> - Init tlv_register_default as late_initcall instead of device_initcall
> - Link to v1: https://lore.barebox.org/barebox/20251112-tlv_bind_serial-v1-1-638cf222553a@pengutronix.de
> ---
> common/tlv/barebox.c | 18 +++++++++++++++++-
> include/tlv/tlv.h | 1 +
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/common/tlv/barebox.c b/common/tlv/barebox.c
> index 24de3eeaaa..fdba9fa2a5 100644
> --- a/common/tlv/barebox.c
> +++ b/common/tlv/barebox.c
> @@ -1,8 +1,12 @@
> // SPDX-License-Identifier: GPL-2.0-only
>
> +#include "barebox-info.h"
> #include <common.h>
> #include <net.h>
> #include <tlv/tlv.h>
> +#include <param.h>
> +#include <string.h>
> +
>
> int tlv_handle_serial(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val)
> {
> @@ -16,6 +20,16 @@ int tlv_handle_serial(struct tlv_device *dev, struct tlv_mapping *map, u16 len,
> return 0;
> }
>
> +int tlv_bind_soc_uid(struct tlv_device *dev, struct tlv_mapping *map, u16 len, const u8 *val)
> +{
> + char *tlv_serial = basprintf("%.*s", len, val);
tlv_serial is not freed.
> +
> + if (streq_ptr(tlv_serial, barebox_get_soc_uid()))
> + return __tlv_format_str(dev, map, len, val) ? 0 : -ENOMEM;
Why not simply forward the return value __tlv_format_str() instead?
(which is 0 or -ENOMEM anyway).
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2025-11-18 8:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 17:14 Jonas Rebmann
2025-11-18 8:40 ` Sascha Hauer [this message]
2025-11-18 9:49 ` Jonas Rebmann
2025-11-18 9:57 ` Jonas Rebmann
2025-11-18 13:56 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aRww5p7AxPtgEmgm@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jre@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox