[PATCH v2] RDMA/core: Check for missing DGID attribute in ib_nl_is_good_ip_resp()

From: Kriish Sharma

Date: Fri Nov 07 2025 - 22:44:59 EST


KMSAN reported a use of uninitialized memory in hex_byte_pack()
via ip6_string() when printing %pI6 from ib_nl_handle_ip_res_resp().
Previously, ib_nl_process_good_ip_rsep() used the 'gid' without
verifying that the LS_NLA_TYPE_DGID attribute was present.

This patch adds a check for the DGID attribute in ib_nl_is_good_ip_resp(),
returning false if it is missing. This prevents uninitialized memory
usage downstream in ib_nl_process_good_ip_rsep().

Suggested-by: Vlad Dumitrescu <vdumitrescu@xxxxxxxxxx>
Reported-by: syzbot+938fcd548c303fe33c1a@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=938fcd548c303fe33c1a
Fixes: ae43f8286730 ("IB/core: Add IP to GID netlink offload")
Signed-off-by: Kriish Sharma <kriish.sharma2006@xxxxxxxxx>
---
v2:
- Added check for LS_NLA_TYPE_DGID in ib_nl_is_good_ip_resp() to
avoid uninitialized 'gid' usage, as suggested by Vlad Dumitrescu.

v1: https://lore.kernel.org/all/20251107041002.2091584-1-kriish.sharma2006@xxxxxxxxx

drivers/infiniband/core/addr.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 61596cda2b65..dde9114fe6a1 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -93,13 +93,16 @@ static inline bool ib_nl_is_good_ip_resp(const struct nlmsghdr *nlh)
if (ret)
return false;

+ if (!tb[LS_NLA_TYPE_DGID])
+ return false;
+
return true;
}

static void ib_nl_process_good_ip_rsep(const struct nlmsghdr *nlh)
{
const struct nlattr *head, *curr;
- union ib_gid gid;
+ union ib_gid gid = {};
struct addr_req *req;
int len, rem;
int found = 0;
--
2.34.1