Thread (5 messages) 5 messages, 2 authors, 2025-02-17

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

From: Eric Dumazet <edumazet@google.com>
Date: 2025-02-17 18:28:27
Also in: linux-kernel-mentees, lkml

On Mon, Feb 17, 2025 at 5:54 PM Suchit K [off-list ref] wrote:
quoted hunk ↗ jump to hunk
Add validation checks for hardware address length in
__hw_addr_insert() to prevent problems with invalid lengths.

Signed-off-by: Suchit Karunakaran <redacted>
---
 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help