public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Kriish Sharma <kriish.sharma2006@gmail.com>
Cc: Leon Romanovsky <leon@kernel.org>,
	Vlad Dumitrescu <vdumitrescu@nvidia.com>,
	Parav Pandit <parav@nvidia.com>,
	Edward Srouji <edwards@nvidia.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot+938fcd548c303fe33c1a@syzkaller.appspotmail.com
Subject: Re: [PATCH] RDMA/core: Fix uninitialized gid in ib_nl_process_good_ip_rsep()
Date: Fri, 7 Nov 2025 11:37:33 -0400	[thread overview]
Message-ID: <20251107153733.GA1859178@ziepe.ca> (raw)
In-Reply-To: <20251107041002.2091584-1-kriish.sharma2006@gmail.com>

On Fri, Nov 07, 2025 at 04:10:02AM +0000, Kriish Sharma wrote:
> KMSAN reported a use of uninitialized memory in hex_byte_pack()
> via ip6_string() when printing %pI6 from ib_nl_handle_ip_res_resp().
> If the LS_NLA_TYPE_DGID attribute is missing, 'gid' remains
> uninitialized before being used in pr_info(), leading to a
> KMSAN uninit-value report.
> 
> 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>
> ---
>  drivers/infiniband/core/addr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
> index 61596cda2b65..4c602fcae12f 100644
> --- a/drivers/infiniband/core/addr.c
> +++ b/drivers/infiniband/core/addr.c
> @@ -99,7 +99,7 @@ static inline bool ib_nl_is_good_ip_resp(const struct nlmsghdr *nlh)
>  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;

This doesn't seem right.

We have this as the only caller:

	if (ib_nl_is_good_ip_resp(nlh))
		ib_nl_process_good_ip_rsep(nlh);

And ib_nl_is_good_ip_resp() does:

	ret = nla_parse_deprecated(tb, LS_NLA_TYPE_MAX - 1, nlmsg_data(nlh),
				   nlmsg_len(nlh), ib_nl_addr_policy,
				   NULL);

static const struct nla_policy ib_nl_addr_policy[LS_NLA_TYPE_MAX] = {
	[LS_NLA_TYPE_DGID] = {.type = NLA_BINARY,
		.len = sizeof(struct rdma_nla_ls_gid),
		.validation_type = NLA_VALIDATE_MIN,
		.min = sizeof(struct rdma_nla_ls_gid)},
};

So I expect the nla_parse_deprecated() to fail if this:

	nla_for_each_attr(curr, head, len, rem) {
		if (curr->nla_type == LS_NLA_TYPE_DGID)
			memcpy(&gid, nla_data(curr), nla_len(curr));
	}

Doesn't find a DGID.

So how can gid be uninitialized?

The fix to whatever this is should be in ib_nl_is_good_ip_resp().

Jason

  reply	other threads:[~2025-11-07 15:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07  4:10 [PATCH] RDMA/core: Fix uninitialized gid in ib_nl_process_good_ip_rsep() Kriish Sharma
2025-11-07 15:37 ` Jason Gunthorpe [this message]
2025-11-07 18:13   ` Kriish Sharma
2025-11-07 19:11   ` Vlad Dumitrescu
2025-11-07 19:17     ` Jason Gunthorpe
2025-11-07 19:58       ` Kriish Sharma
2025-11-07 21:06         ` Vlad Dumitrescu
2025-11-08  3:48           ` Kriish Sharma

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=20251107153733.GA1859178@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=edwards@nvidia.com \
    --cc=kriish.sharma2006@gmail.com \
    --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