* [patch] IB/ipath: add a range check before bumping the stats
@ 2013-03-12 11:03 Dan Carpenter
[not found] ` <20130312110307.GA22921-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2013-03-12 11:03 UTC (permalink / raw)
To: Mike Marciniszyn
Cc: Roland Dreier, Sean Hefty, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA
My static checker complains that this could corrupt memory. It
seems valid to add a range check here.
Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
---
I can't test this.
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 439c35d..f15dd70 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -621,6 +621,10 @@ void ipath_ib_rcv(struct ipath_ibdev *dev, void *rhdr, void *data,
}
opcode = be32_to_cpu(ohdr->bth[0]) >> 24;
+ if (opcode >= ARRAY_SIZE(dev->opstats)) {
+ dev->rcv_errors++;
+ goto bail;
+ }
dev->opstats[opcode].n_bytes += tlen;
dev->opstats[opcode].n_packets++;
--
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] 3+ messages in thread
* RE: [patch] IB/ipath: add a range check before bumping the stats
[not found] ` <20130312110307.GA22921-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
@ 2013-03-15 13:43 ` Marciniszyn, Mike
[not found] ` <32E1700B9017364D9B60AED9960492BC0D5C926B-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Marciniszyn, Mike @ 2013-03-15 13:43 UTC (permalink / raw)
To: Dan Carpenter, infinipath
Cc: Roland Dreier, Hefty, Sean, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Oddly, I don't see an issue with qib, which masks the opcode.
Would:
opcode = (be32_to_cpu(ohdr->bth[0]) >> 24) & 0x7f;
also correct the issue without adding the if test. At this point the hardware has already validated the opcode, so there is no value in the fail handling.
What args are you using with smatch?
Mike
> My static checker complains that this could corrupt memory. It seems valid to
> add a range check here.
>
--
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] 3+ messages in thread
* Re: [patch] IB/ipath: add a range check before bumping the stats
[not found] ` <32E1700B9017364D9B60AED9960492BC0D5C926B-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
@ 2013-03-16 10:25 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2013-03-16 10:25 UTC (permalink / raw)
To: Marciniszyn, Mike
Cc: infinipath, Roland Dreier, Hefty, Sean, Hal Rosenstock,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
On Fri, Mar 15, 2013 at 01:43:39PM +0000, Marciniszyn, Mike wrote:
> Oddly, I don't see an issue with qib, which masks the opcode.
>
> Would:
> opcode = (be32_to_cpu(ohdr->bth[0]) >> 24) & 0x7f;
>
> also correct the issue without adding the if test. At this point
> the hardware has already validated the opcode, so there is no
> value in the fail handling.
>
> What args are you using with smatch?
>
Gar sorry, for the noise. You can just drop this then.
This is some custom stuff that probably has too many false positives
to push.
Doing an "& 0x7f" would silence the warning but if this is validated
by the hardware then we don't need it.
regards,
dan carpenter
--
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] 3+ messages in thread
end of thread, other threads:[~2013-03-16 10:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 11:03 [patch] IB/ipath: add a range check before bumping the stats Dan Carpenter
[not found] ` <20130312110307.GA22921-dZEljifmRObu9KfB+GxooP8+0UxHXcjY@public.gmane.org>
2013-03-15 13:43 ` Marciniszyn, Mike
[not found] ` <32E1700B9017364D9B60AED9960492BC0D5C926B-AtyAts71sc88Ug9VwtkbtrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2013-03-16 10:25 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox