Re: [PATCH] net: dev_addr_list: add address length validation in __hw_addr_insert function

From: Eric Dumazet
Date: Mon Feb 17 2025 - 13:28:41 EST


On Mon, Feb 17, 2025 at 5:54 PM Suchit K <suchitkarunakaran@xxxxxxxxx> wrote:
>
> Add validation checks for hardware address length in
> __hw_addr_insert() to prevent problems with invalid lengths.
>
> Signed-off-by: Suchit Karunakaran <suchitkarunakaran@xxxxxxxxx>
> ---
> net/core/dev_addr_lists.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/core/dev_addr_lists.c b/net/core/dev_addr_lists.c
> index 90716bd73..b6b906b2a 100644
> --- a/net/core/dev_addr_lists.c
> +++ b/net/core/dev_addr_lists.c
> @@ -21,6 +21,9 @@
> static int __hw_addr_insert(struct netdev_hw_addr_list *list,
> struct netdev_hw_addr *new, int addr_len)
> {
> + if (!list || !new || addr_len <= 0 || addr_len > MAX_ADDR_LEN)
> + return -EINVAL;
> +

We do not put code before variable declarations.

Also, why @list would be NULL, or @new being NULL ?
This does not match the changelog.

> struct rb_node **ins_point = &list->tree.rb_node, *parent = NULL;
> struct netdev_hw_addr *ha;
>

Any syzbot report to share with us ?

Also, a Fixes: tag would be needed.