From: Miquel Raynal <miquel.raynal@bootlin.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Srinivas Kandagatla <srini@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] nvmem: layouts: onie-tlv: validate the base MAC address length
Date: Thu, 19 Nov 2026 13:21:20 +0100 [thread overview]
Message-ID: <87cxs1dnb3.fsf@bootlin.com> (raw)
In-Reply-To: <20261117-submit-nvmem-onie-mac-length-v1-v1-1-e6d359b82862@gmail.com> (James Hilliard's message of "Tue, 17 Nov 2026 15:27:53 -0700")
On 17/11/2026 at 15:27:53 -07, James Hilliard <james.hilliard1@gmail.com> wrote:
> The ONIE base MAC address field is six bytes, but the layout accepts
> any length from the TLV. Its read callback calls eth_addr_add(), which
> always accesses six bytes, even if the cell is shorter.
>
> Check the declared field length before registering the cell. The read
> callback gets the transfer length rounded up to the provider's word
> size, which can be larger than a valid six-byte address. Skip a
> malformed MAC field and continue registering the other cells.
>
> Fixes: d3c0d12f6474 ("nvmem: layouts: onie-tlv: Add new layout
> driver")
Not sure this qualifies as a fix.
> Cc: stable@vger.kernel.org
Especially not for stable kernels.
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> drivers/nvmem/layouts/onie-tlv.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/nvmem/layouts/onie-tlv.c b/drivers/nvmem/layouts/onie-tlv.c
> index 4da3a704388e..85562fc6b06f 100644
> --- a/drivers/nvmem/layouts/onie-tlv.c
> +++ b/drivers/nvmem/layouts/onie-tlv.c
> @@ -30,9 +30,9 @@ struct onie_tlv {
> u8 len;
> } __packed;
>
> -static const char *onie_tlv_cell_name(u8 type)
> +static const char *onie_tlv_cell_name(const struct onie_tlv *tlv)
> {
> - switch (type) {
> + switch (tlv->type) {
> case 0x21:
> return "product-name";
> case 0x22:
> @@ -40,7 +40,7 @@ static const char *onie_tlv_cell_name(u8 type)
> case 0x23:
> return "serial-number";
> case 0x24:
> - return "mac-address";
> + return tlv->len == ETH_ALEN ? "mac-address" : NULL;
How useful is it in the ONIE case? I don't know. Doesn't hurt...
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
prev parent reply other threads:[~2026-11-19 12:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 22:27 [PATCH] nvmem: layouts: onie-tlv: validate the base MAC address length James Hilliard
2026-11-19 12:21 ` Miquel Raynal [this message]
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=87cxs1dnb3.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.hilliard1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srini@kernel.org \
--cc=stable@vger.kernel.org \
/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