* Potential NULL pointer dereference in drivers/infiniband/core
@ 2017-02-21 6:23 Shaobo
[not found] ` <7e4ed5f8bdc1578f2459231c78e0d1e9-sDh8Nw2yj/+Vc3sceRu5cw@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Shaobo @ 2017-02-21 6:23 UTC (permalink / raw)
To: linux-rdma-u79uwXL29TY76Z2rM5mHXA
Dear developers,
My name is Shaobo He and I am a graduate student at University of Utah.
I am applying a static analysis tool to the Linux device drivers and got
an error trace of null pointer dereference in drivers/infiniband/core
starting from function `ucma_accept`: it calls `rdma_accept` with the
second argument being NULL. In `rdma_accept`, `cma_accept_iw` is called
with the second argument also being NULL. Then in `cma_accept_iw`,
`cma_modify_qp_rtr` can return 0 if `id_priv->id.qp` is NULL, which can
be suggested by an if statement in `rdma_accept`. Finally, the second
argument `conn_param` of `cma_accept_iw` gets dereferenced. As you can
see, the error trace is only plausible since it depends on certain
conditions. Therefore, I was wondering if you could confirm it.
Thanks for your time. I am looking forward to your reply.
Best,
Shaobo
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Potential NULL pointer dereference in drivers/infiniband/core
[not found] ` <7e4ed5f8bdc1578f2459231c78e0d1e9-sDh8Nw2yj/+Vc3sceRu5cw@public.gmane.org>
@ 2017-02-21 11:59 ` Yuval Shaia
0 siblings, 0 replies; 6+ messages in thread
From: Yuval Shaia @ 2017-02-21 11:59 UTC (permalink / raw)
To: Shaobo; +Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA
On Mon, Feb 20, 2017 at 11:23:41PM -0700, Shaobo wrote:
> Dear developers,
>
> My name is Shaobo He and I am a graduate student at University of
> Utah. I am applying a static analysis tool to the Linux device
> drivers and got an error trace of null pointer dereference in
> drivers/infiniband/core starting from function `ucma_accept`: it
> calls `rdma_accept` with the second argument being NULL. In
> `rdma_accept`, `cma_accept_iw` is called with the second argument
> also being NULL. Then in `cma_accept_iw`, `cma_modify_qp_rtr` can
> return 0 if `id_priv->id.qp` is NULL, which can be suggested by an
> if statement in `rdma_accept`. Finally, the second argument
> `conn_param` of `cma_accept_iw` gets dereferenced. As you can see,
> the error trace is only plausible since it depends on certain
> conditions. Therefore, I was wondering if you could confirm it.
>
> Thanks for your time. I am looking forward to your reply.
Suggesting to prepare a patch and ask for review.
I believe the issue will get faster attention this way.
>
> Best,
> Shaobo
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Potential NULL pointer dereference in drivers/infiniband/core
[not found] <003d01d28c09$46d1e200$d475a600$@cs.utah.edu>
@ 2017-02-21 18:52 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99BB-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Hefty, Sean @ 2017-02-21 18:52 UTC (permalink / raw)
To: Shaobo, linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Steve Wise
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Steve,
Can you look at the iWarp code flow described below?
> My name is Shaobo He and I am a graduate student at University of Utah.
> I am applying a static analysis tool to the Linux device drivers and
> got an error trace of null pointer dereference in
> drivers/infiniband/core starting from function `ucma_accept`: it calls
> `rdma_accept` with the second argument being NULL. In `rdma_accept`,
> `cma_accept_iw` is called with the second argument also being NULL.
> Then in `cma_accept_iw`, `cma_modify_qp_rtr` can return 0 if `id_priv-
> >id.qp` is NULL, which can be suggested by an if statement in
> `rdma_accept`. Finally, the second argument `conn_param` of
> `cma_accept_iw` gets dereferenced. As you can see, the error trace is
> only plausible since it depends on certain conditions. Therefore, I was
> wondering if you could confirm it.
Based on a quick look, this looks like it's at least a problem in how conn_param is verified. IB allows conn_param to be optional, whereas iWarp requires it. Since this is coming from user space, we can crash.
- Sean
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Potential NULL pointer dereference in drivers/infiniband/core
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99BB-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2017-02-21 18:58 ` Steve Wise
2017-02-21 19:05 ` Hefty, Sean
0 siblings, 1 reply; 6+ messages in thread
From: Steve Wise @ 2017-02-21 18:58 UTC (permalink / raw)
To: 'Hefty, Sean', 'Shaobo',
linux-rdma-u79uwXL29TY76Z2rM5mHXA
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
leon-DgEjT+Ai2ygdnm+yROfE0A
>
> Steve,
>
> Can you look at the iWarp code flow described below?
sure:
>
> > My name is Shaobo He and I am a graduate student at University of Utah.
> > I am applying a static analysis tool to the Linux device drivers and
> > got an error trace of null pointer dereference in
> > drivers/infiniband/core starting from function `ucma_accept`: it calls
> > `rdma_accept` with the second argument being NULL. In `rdma_accept`,
> > `cma_accept_iw` is called with the second argument also being NULL.
> > Then in `cma_accept_iw`, `cma_modify_qp_rtr` can return 0 if `id_priv-
> > >id.qp` is NULL, which can be suggested by an if statement in
> > `rdma_accept`. Finally, the second argument `conn_param` of
> > `cma_accept_iw` gets dereferenced. As you can see, the error trace is
> > only plausible since it depends on certain conditions. Therefore, I was
> > wondering if you could confirm it.
>
> Based on a quick look, this looks like it's at least a problem in how
conn_param is
> verified. IB allows conn_param to be optional, whereas iWarp requires it.
Since
> this is coming from user space, we can crash.
>
Agreed. cma_accept_iw() needs to either fail the accept for a NULL conn_param,
or generate values for the iw_param struct if conn_param is NULL. I suggest the
former. Something like:
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 3e70a9c..c377afc 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -3583,6 +3583,9 @@ static int cma_accept_iw(struct rdma_id_private *id_priv,
struct iw_cm_conn_param iw_param;
int ret;
+ if (!conn_param)
+ return -EINVAL;
+
ret = cma_modify_qp_rtr(id_priv, conn_param);
if (ret)
return ret;
---
Steve.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: Potential NULL pointer dereference in drivers/infiniband/core
2017-02-21 18:58 ` Steve Wise
@ 2017-02-21 19:05 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99ED-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Hefty, Sean @ 2017-02-21 19:05 UTC (permalink / raw)
To: Steve Wise, 'Shaobo',
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
leon-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
> diff --git a/drivers/infiniband/core/cma.c
> b/drivers/infiniband/core/cma.c
> index 3e70a9c..c377afc 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -3583,6 +3583,9 @@ static int cma_accept_iw(struct rdma_id_private
> *id_priv,
> struct iw_cm_conn_param iw_param;
> int ret;
>
> + if (!conn_param)
> + return -EINVAL;
> +
> ret = cma_modify_qp_rtr(id_priv, conn_param);
> if (ret)
> return ret;
Can you re-submit as a formal patch? Feel free to include Acked-by: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
This should go into stable. Thanks! And thanks Shaobo!
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: Potential NULL pointer dereference in drivers/infiniband/core
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99ED-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2017-02-21 19:24 ` Steve Wise
0 siblings, 0 replies; 6+ messages in thread
From: Steve Wise @ 2017-02-21 19:24 UTC (permalink / raw)
To: 'Hefty, Sean', 'Shaobo',
linux-rdma-u79uwXL29TY76Z2rM5mHXA
Cc: dledford-H+wXaHxf7aLQT0dZR+AlfA,
hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w,
leon-DgEjT+Ai2ygdnm+yROfE0A
>
> Can you re-submit as a formal patch? Feel free to include Acked-by: Sean
Hefty
> <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
> This should go into stable. Thanks! And thanks Shaobo!
Will do.
Steve.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-02-21 19:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <003d01d28c09$46d1e200$d475a600$@cs.utah.edu>
2017-02-21 18:52 ` Potential NULL pointer dereference in drivers/infiniband/core Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99BB-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-02-21 18:58 ` Steve Wise
2017-02-21 19:05 ` Hefty, Sean
[not found] ` <1828884A29C6694DAF28B7E6B8A82373AB0E99ED-P5GAC/sN6hkd3b2yrw5b5LfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-02-21 19:24 ` Steve Wise
2017-02-21 6:23 Shaobo
[not found] ` <7e4ed5f8bdc1578f2459231c78e0d1e9-sDh8Nw2yj/+Vc3sceRu5cw@public.gmane.org>
2017-02-21 11:59 ` Yuval Shaia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox