linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kriish Sharma <kriish.sharma2006@gmail.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	Vlad Dumitrescu <vdumitrescu@nvidia.com>,
	Parav Pandit <parav@nvidia.com>,
	Edward Srouji <edwards@nvidia.com>
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Kriish Sharma <kriish.sharma2006@gmail.com>,
	syzbot+938fcd548c303fe33c1a@syzkaller.appspotmail.com
Subject: [PATCH v2] RDMA/core: Check for missing DGID attribute in ib_nl_is_good_ip_resp()
Date: Sat,  8 Nov 2025 03:43:36 +0000	[thread overview]
Message-ID: <20251108034336.2100529-1-kriish.sharma2006@gmail.com> (raw)

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@nvidia.com>
Reported-by: syzbot+938fcd548c303fe33c1a@syzkaller.appspotmail.com
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@gmail.com>
---
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@gmail.com

 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


             reply	other threads:[~2025-11-08  3:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-08  3:43 Kriish Sharma [this message]
2025-11-09  0:22 ` [PATCH v2] RDMA/core: Check for missing DGID attribute in ib_nl_is_good_ip_resp() Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251108034336.2100529-1-kriish.sharma2006@gmail.com \
    --to=kriish.sharma2006@gmail.com \
    --cc=edwards@nvidia.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=parav@nvidia.com \
    --cc=syzbot+938fcd548c303fe33c1a@syzkaller.appspotmail.com \
    --cc=vdumitrescu@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).