All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxgb4: fix signed wrap around when decrementing index idx
@ 2016-09-20 14:48 Colin King
  2016-09-20 14:48 ` Colin King
  2016-09-22  5:49 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-09-20 14:48 UTC (permalink / raw)
  To: Hariprasad S, netdev; +Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Change predecrement compare to post decrement compare to avoid an
unsigned integer wrap-around comparison when decrementing idx in
the while loop.

For example, when idx is zero, the current situation will
predecrement idx in the while loop, wrapping idx to the maximum
signed integer and cause out of bounds reads on rxq_info->msix_tbl[idx].

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index d12a73e..42a9c8d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -367,7 +367,7 @@ int request_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type)
 	}
 	return 0;
 unwind:
-	while (--idx >= 0) {
+	while (idx-- > 0) {
 		bmap_idx = rxq_info->msix_tbl[idx];
 		free_msix_idx_in_bmap(adap, bmap_idx);
 		free_irq(adap->msix_info_ulds[bmap_idx].vec,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] cxgb4: fix signed wrap around when decrementing index idx
  2016-09-20 14:48 [PATCH] cxgb4: fix signed wrap around when decrementing index idx Colin King
@ 2016-09-20 14:48 ` Colin King
  2016-09-22  5:49 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Colin King @ 2016-09-20 14:48 UTC (permalink / raw)
  To: Hariprasad S, netdev; +Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Change predecrement compare to post decrement compare to avoid an
unsigned integer wrap-around comparison when decrementing idx in
the while loop.

For example, when idx is zero, the current situation will
predecrement idx in the while loop, wrapping idx to the maximum
signed integer and cause out of bounds reads on rxq_info->msix_tbl[idx].

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
index d12a73e..42a9c8d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
@@ -367,7 +367,7 @@ int request_msix_queue_irqs_uld(struct adapter *adap, unsigned int uld_type)
 	}
 	return 0;
 unwind:
-	while (--idx >= 0) {
+	while (idx-- > 0) {
 		bmap_idx = rxq_info->msix_tbl[idx];
 		free_msix_idx_in_bmap(adap, bmap_idx);
 		free_irq(adap->msix_info_ulds[bmap_idx].vec,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxgb4: fix signed wrap around when decrementing index idx
  2016-09-20 14:48 [PATCH] cxgb4: fix signed wrap around when decrementing index idx Colin King
  2016-09-20 14:48 ` Colin King
@ 2016-09-22  5:49 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-09-22  5:49 UTC (permalink / raw)
  To: colin.king; +Cc: hariprasad, netdev, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Tue, 20 Sep 2016 15:48:45 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Change predecrement compare to post decrement compare to avoid an
> unsigned integer wrap-around comparison when decrementing idx in
> the while loop.
> 
> For example, when idx is zero, the current situation will
> predecrement idx in the while loop, wrapping idx to the maximum
> signed integer and cause out of bounds reads on rxq_info->msix_tbl[idx].
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

This doesn't apply cleanly to the 'net' tree, please respin.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-22  5:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 14:48 [PATCH] cxgb4: fix signed wrap around when decrementing index idx Colin King
2016-09-20 14:48 ` Colin King
2016-09-22  5:49 ` David Miller

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.