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: Suchit K <hidden>
Date: 2025-02-17 19:05:11
Also in: linux-kernel-mentees, lkml

Hi Eric,
Thanks for the feedback! I'm new to kernel development and still
finding my way around.
I wasn't working from a syzbot report on this one; I was just
exploring the code and felt there is no parameter validation. I went
ahead and made this change based on that impression. I realized my
changelog should have been more generic. Sorry about that. Also since
it's not based on a syzbot report, is it good to have this change?
Your insights and suggestions would be most welcome. I will make the
required changes accordingly.
Thanks.

On Mon, 17 Feb 2025 at 23:58, Eric Dumazet [off-list ref] wrote:
On Mon, Feb 17, 2025 at 5:54 PM Suchit K [off-list ref] wrote:
quoted
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.
quoted
  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