naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

Blame SOURCES/0043-ip-link-Fix-use-after-free-in-nl_get_ll_addr_len.patch

36cfb7
From dcafeb49b2538cc7118cb64f62c685980c106b48 Mon Sep 17 00:00:00 2001
36cfb7
From: Phil Sutter <psutter@redhat.com>
36cfb7
Date: Tue, 6 Mar 2018 11:35:28 +0100
36cfb7
Subject: [PATCH] ip-link: Fix use after free in nl_get_ll_addr_len()
36cfb7
36cfb7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1550097
36cfb7
Upstream Status: iproute2.git commit 06867c3719587
36cfb7
36cfb7
commit 06867c371958773e39b4ccac07cfe3e2fff2ea55
36cfb7
Author: Phil Sutter <phil@nwl.cc>
36cfb7
Date:   Thu Mar 1 10:35:12 2018 +0100
36cfb7
36cfb7
    ip-link: Fix use after free in nl_get_ll_addr_len()
36cfb7
36cfb7
    Immediately after freeing the buffer returned from rtnl_talk(), it is
36cfb7
    accessed again via pointer in struct rtattr array. This leads to some
36cfb7
    builds not allowing to set an interface's MAC address because the
36cfb7
    expected length value is garbage.
36cfb7
36cfb7
    Fixes: 86bf43c7c2fdc ("lib/libnetlink: update rtnl_talk to support malloc buff at run time")
36cfb7
    Signed-off-by: Phil Sutter <phil@nwl.cc>
36cfb7
---
36cfb7
 ip/iplink.c | 3 ++-
36cfb7
 1 file changed, 2 insertions(+), 1 deletion(-)
36cfb7
36cfb7
diff --git a/ip/iplink.c b/ip/iplink.c
e138d9
index 193997cad2a35..db5b2c9645ba8 100644
36cfb7
--- a/ip/iplink.c
36cfb7
+++ b/ip/iplink.c
36cfb7
@@ -268,8 +268,9 @@ static int nl_get_ll_addr_len(unsigned int dev_index)
36cfb7
 		return -1;
36cfb7
 	}
36cfb7
 
36cfb7
+	len = RTA_PAYLOAD(tb[IFLA_ADDRESS]);
36cfb7
 	free(answer);
36cfb7
-	return RTA_PAYLOAD(tb[IFLA_ADDRESS]);
36cfb7
+	return len;
36cfb7
 }
36cfb7
 
36cfb7
 static void iplink_parse_vf_vlan_info(int vf, int *argcp, char ***argvp,
36cfb7
-- 
e138d9
2.21.0
36cfb7