* [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
@ 2024-09-26 14:34 Qianqiang Liu
2024-09-27 14:06 ` [PATCH v2] " Qianqiang Liu
2024-10-09 14:30 ` [PATCH] " Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Qianqiang Liu @ 2024-09-26 14:34 UTC (permalink / raw)
To: jgg, leon; +Cc: linux-rdma, linux-kernel, Qianqiang Liu
nlmsg_put() may return a NULL pointer assigned to nlh, which will later
be dereferenced in nlmsg_end().
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
drivers/infiniband/core/nldev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 39f89a4b8649..7dc8e2ec62cc 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
nlh = nlmsg_put(skb, 0, 0,
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
0, 0);
+ if (!nlh)
+ goto err_free;
switch (type) {
case RDMA_REGISTER_EVENT:
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
2024-09-26 14:34 [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event Qianqiang Liu
@ 2024-09-27 14:06 ` Qianqiang Liu
2024-10-04 20:13 ` Jason Gunthorpe
2024-10-09 14:30 ` [PATCH] " Dan Carpenter
1 sibling, 1 reply; 5+ messages in thread
From: Qianqiang Liu @ 2024-09-27 14:06 UTC (permalink / raw)
To: leon; +Cc: jgg, linux-rdma, linux-kernel
nlmsg_put() may return a NULL pointer assigned to nlh, which will later
be dereferenced in nlmsg_end().
Fixes: 9cbed5aab5ae ("RDMA/nldev: Add support for RDMA monitoring")
Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
---
Changes since v1:
- Add Fixes tag
---
drivers/infiniband/core/nldev.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
index 39f89a4b86498..7dc8e2ec62cc8 100644
--- a/drivers/infiniband/core/nldev.c
+++ b/drivers/infiniband/core/nldev.c
@@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
nlh = nlmsg_put(skb, 0, 0,
RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
0, 0);
+ if (!nlh)
+ goto err_free;
switch (type) {
case RDMA_REGISTER_EVENT:
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
2024-09-27 14:06 ` [PATCH v2] " Qianqiang Liu
@ 2024-10-04 20:13 ` Jason Gunthorpe
2024-10-09 14:31 ` Dan Carpenter
0 siblings, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2024-10-04 20:13 UTC (permalink / raw)
To: Qianqiang Liu; +Cc: leon, linux-rdma, linux-kernel
On Fri, Sep 27, 2024 at 10:06:13PM +0800, Qianqiang Liu wrote:
> nlmsg_put() may return a NULL pointer assigned to nlh, which will later
> be dereferenced in nlmsg_end().
>
> Fixes: 9cbed5aab5ae ("RDMA/nldev: Add support for RDMA monitoring")
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---
> Changes since v1:
> - Add Fixes tag
> ---
> drivers/infiniband/core/nldev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 39f89a4b86498..7dc8e2ec62cc8 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
> nlh = nlmsg_put(skb, 0, 0,
> RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
> 0, 0);
> + if (!nlh)
> + goto err_free;
It doesn't look to me like nlmsg_put can fail in this usage, but we
should probbaly put the if to avoid getting static checkers warning on
it.
Applied to for-rc, thanks
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
2024-09-26 14:34 [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event Qianqiang Liu
2024-09-27 14:06 ` [PATCH v2] " Qianqiang Liu
@ 2024-10-09 14:30 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2024-10-09 14:30 UTC (permalink / raw)
To: Qianqiang Liu; +Cc: jgg, leon, linux-rdma, linux-kernel
On Thu, Sep 26, 2024 at 10:34:03PM +0800, Qianqiang Liu wrote:
> nlmsg_put() may return a NULL pointer assigned to nlh, which will later
> be dereferenced in nlmsg_end().
>
> Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> ---
> drivers/infiniband/core/nldev.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> index 39f89a4b8649..7dc8e2ec62cc 100644
> --- a/drivers/infiniband/core/nldev.c
> +++ b/drivers/infiniband/core/nldev.c
> @@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
> nlh = nlmsg_put(skb, 0, 0,
> RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
> 0, 0);
> + if (!nlh)
> + goto err_free;
Need to set the error code before the goto. "ret = -EMSGSIZE;"
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event
2024-10-04 20:13 ` Jason Gunthorpe
@ 2024-10-09 14:31 ` Dan Carpenter
0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2024-10-09 14:31 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Qianqiang Liu, leon, linux-rdma, linux-kernel
On Fri, Oct 04, 2024 at 05:13:02PM -0300, Jason Gunthorpe wrote:
> On Fri, Sep 27, 2024 at 10:06:13PM +0800, Qianqiang Liu wrote:
> > nlmsg_put() may return a NULL pointer assigned to nlh, which will later
> > be dereferenced in nlmsg_end().
> >
> > Fixes: 9cbed5aab5ae ("RDMA/nldev: Add support for RDMA monitoring")
> > Signed-off-by: Qianqiang Liu <qianqiang.liu@163.com>
> > ---
> > Changes since v1:
> > - Add Fixes tag
> > ---
> > drivers/infiniband/core/nldev.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nldev.c
> > index 39f89a4b86498..7dc8e2ec62cc8 100644
> > --- a/drivers/infiniband/core/nldev.c
> > +++ b/drivers/infiniband/core/nldev.c
> > @@ -2816,6 +2816,8 @@ int rdma_nl_notify_event(struct ib_device *device, u32 port_num,
> > nlh = nlmsg_put(skb, 0, 0,
> > RDMA_NL_GET_TYPE(RDMA_NL_NLDEV, RDMA_NLDEV_CMD_MONITOR),
> > 0, 0);
> > + if (!nlh)
> > + goto err_free;
>
> It doesn't look to me like nlmsg_put can fail in this usage, but we
> should probbaly put the if to avoid getting static checkers warning on
> it.
>
> Applied to for-rc, thanks
It's difficult for static checkers to predict when a function can *really*
return NULL or not. Smatch checks allocation functions and that's basically it.
I suspect there is a heuristic here where it warns if the percent of callers
that check is over 70% or something.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-09 14:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 14:34 [PATCH] RDMA/nldev: Fix NULL pointer dereferences issue in rdma_nl_notify_event Qianqiang Liu
2024-09-27 14:06 ` [PATCH v2] " Qianqiang Liu
2024-10-04 20:13 ` Jason Gunthorpe
2024-10-09 14:31 ` Dan Carpenter
2024-10-09 14:30 ` [PATCH] " Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox