From 230e595312b7b0f48ad7129f908d9b337d63e8b6 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 8 Jun 2022 10:58:01 +0200 Subject: [PATCH] rtnl: fix segmentation fault on parsing linkinfo RTA without data Some link types, such as veth, yield an IFLA_LINKINFO nla without an embedded IFLA_INFO_DATA / INFLA_INFO_SLAVE_DATA nla which causes the nla converter to dereference a NULL nla pointer. Properly deal with such cases and check for the existence of the child nla before attempting to parse it. Signed-off-by: Jo-Philipp Wich --- lib/rtnl.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/rtnl.c b/lib/rtnl.c index b6a3e385..d4cf8b37 100644 --- a/lib/rtnl.c +++ b/lib/rtnl.c @@ -1890,8 +1890,9 @@ uc_nl_convert_rta_linkinfo_data(uc_value_t *obj, size_t attr, struct nl_msg *msg } } - if (nattrs > 0) { - attr = (attr == IFLA_INFO_KIND) ? IFLA_INFO_DATA : IFLA_INFO_SLAVE_DATA; + attr = (attr == IFLA_INFO_KIND) ? IFLA_INFO_DATA : IFLA_INFO_SLAVE_DATA; + + if (nattrs > 0 && tb[attr]) { rv = uc_nl_convert_attrs(msg, nla_data(tb[attr]), nla_len(tb[attr]), 0, attrs, nattrs, vm, obj); if (!rv)