[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240219100621.7bbb708e@hermes.local>
Date: Mon, 19 Feb 2024 10:06:21 -0800
From: Stephen Hemminger <stephen@...workplumber.org>
To: Maks Mishin <maks.mishinfz@...il.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH] m_tunnel_key: Add check for result hex2mem()
On Sun, 18 Feb 2024 23:40:26 +0300
Maks Mishin <maks.mishinfz@...il.com> wrote:
> Added check for hex2mem() result to report of error
> with incorrect args.
>
> Signed-off-by: Maks Mishin <maks.mishinFZ@...il.com>
> ---
> tc/m_tunnel_key.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tc/m_tunnel_key.c b/tc/m_tunnel_key.c
> index ff699cc8..9bb5c2aa 100644
> --- a/tc/m_tunnel_key.c
> +++ b/tc/m_tunnel_key.c
> @@ -575,7 +575,10 @@ static void tunnel_key_print_geneve_options(struct rtattr *attr)
> data_len = RTA_PAYLOAD(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]);
> hexstring_n2a(RTA_DATA(tb[TCA_TUNNEL_KEY_ENC_OPT_GENEVE_DATA]),
> data_len, data, sizeof(data));
> - hex2mem(data, data_r, data_len);
> +
> + if (hex2mem(data, data_r, data_len) < 0)
> + invarg("labels mask must be a hex string\n", data);
> +
invarg() is intended only for use in command line args.
This is where the result of a geneve option from kernel netlink is being parsed.
Not user input.
Not sure why hex2mem is needed here at all? The original data is in the
netlink message. Doing the inverse is redundant.
Powered by blists - more mailing lists