From: Leon Romanovsky <leon@kernel.org>
To: Prathamesh Deshpande <prathameshdeshpande7@gmail.com>
Cc: dledford@redhat.com, haggaie@mellanox.com, jgg@ziepe.ca,
linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org
Subject: Re: [PATCH] IB/mlx5: Fix potential NULL dereference in query_device
Date: Tue, 31 Mar 2026 22:04:19 +0300 [thread overview]
Message-ID: <20260331190419.GJ814676@unreal> (raw)
In-Reply-To: <20260331182615.16983-1-prathameshdeshpande7@gmail.com>
On Tue, Mar 31, 2026 at 07:25:56PM +0100, Prathamesh Deshpande wrote:
> On Tue, Mar 31, 2026 at 04:49:55PM +0300, Leon Romanovsky wrote:
> > On Tue, Mar 31, 2026 at 02:44:27AM +0100, Prathamesh Deshpande wrote:
> > > Smatch reported an inconsistent NULL check for 'uhw' in
> > > mlx5_ib_query_device(). While 'uhw_outlen' is checked at the end of
> > > the function before calling ib_copy_to_udata(), 'uhw' is explicitly
> > > checked for NULL earlier in the same function.
> > >
> > > If a caller provides a non-zero 'uhw_outlen' but a NULL 'uhw' pointer,
> > > ib_copy_to_udata() will attempt to dereference 'uhw',
> >
> > How is it possible?
>
> Hi Leon,
>
> You are right that in the current uverbs paths, 'uhw_outlen' and 'uhw'
> should stay in sync.
>
> However, Smatch flags this as an inconsistency because 'uhw' is explicitly
> checked for NULL earlier in this same function (at line 968). If the code
> assumes 'uhw' could be NULL there, it is safer and more consistent to
> check the pointer directly before passing it to ib_copy_to_udata() at
> line 1357.
>
> This prevents any future refactoring or unconventional kernel-space
> callers from accidentally triggering a NULL dereference.
Kernel-space callers don't use uverbs path. It is solely for the
user-space access.
Thanks
>
> What do you think?
>
> Thanks,
> Prathamesh
next prev parent reply other threads:[~2026-03-31 19:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 1:44 [PATCH] IB/mlx5: Fix potential NULL dereference in query_device Prathamesh Deshpande
2026-03-31 13:49 ` Leon Romanovsky
2026-03-31 18:25 ` Prathamesh Deshpande
2026-03-31 19:04 ` Leon Romanovsky [this message]
[not found] <202603311604.GD814676@unreal>
2026-03-31 21:57 ` Prathamesh Deshpande
2026-04-09 9:51 ` Leon Romanovsky
2026-04-10 1:07 ` Prathamesh Deshpande
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=20260331190419.GJ814676@unreal \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=haggaie@mellanox.com \
--cc=jgg@ziepe.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=prathameshdeshpande7@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.