linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift
@ 2019-06-17 16:12 Colin King
  2019-06-17 19:17 ` Dan Carpenter
  2019-06-19  1:01 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2019-06-17 16:12 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

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

Left shifting the signed int value 1 by 31 bits has undefined behaviour
and the shift amount oq_no can be as much as 63.  Fix this by using
BIT_ULL(oq_no) instead.

Addresses-Coverity: ("Bad shift operation")
Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---

V2: Use BIT_ULL(oq_no) instead of 1ULL << oq_no. Thanks to Dan Carpenter for
    noting this is more appropriate.

---
 drivers/net/ethernet/cavium/liquidio/lio_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_core.c b/drivers/net/ethernet/cavium/liquidio/lio_core.c
index 1c50c10b5a16..d7e805749a5b 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_core.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_core.c
@@ -964,7 +964,7 @@ static void liquidio_schedule_droq_pkt_handlers(struct octeon_device *oct)
 
 			if (droq->ops.poll_mode) {
 				droq->ops.napi_fn(droq);
-				oct_priv->napi_mask |= (1 << oq_no);
+				oct_priv->napi_mask |= BIT_ULL(oq_no);
 			} else {
 				tasklet_schedule(&oct_priv->droq_tasklet);
 			}
-- 
2.20.1


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

* Re: [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift
  2019-06-17 16:12 [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift Colin King
@ 2019-06-17 19:17 ` Dan Carpenter
  2019-06-19  1:01 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-06-17 19:17 UTC (permalink / raw)
  To: Colin King
  Cc: Derek Chickles, Satanand Burla, Felix Manlunas, David S . Miller,
	netdev, kernel-janitors, linux-kernel

On Mon, Jun 17, 2019 at 05:12:49PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Left shifting the signed int value 1 by 31 bits has undefined behaviour
> and the shift amount oq_no can be as much as 63.  Fix this by using
> BIT_ULL(oq_no) instead.
> 
> Addresses-Coverity: ("Bad shift operation")
> Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---

Looks good.  Thanks!

Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>

regards,
dan carpenter


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

* Re: [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift
  2019-06-17 16:12 [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift Colin King
  2019-06-17 19:17 ` Dan Carpenter
@ 2019-06-19  1:01 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-19  1:01 UTC (permalink / raw)
  To: colin.king
  Cc: dchickles, sburla, fmanlunas, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Mon, 17 Jun 2019 17:12:49 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Left shifting the signed int value 1 by 31 bits has undefined behaviour
> and the shift amount oq_no can be as much as 63.  Fix this by using
> BIT_ULL(oq_no) instead.
> 
> Addresses-Coverity: ("Bad shift operation")
> Fixes: f21fb3ed364b ("Add support of Cavium Liquidio ethernet adapters")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> 
> V2: Use BIT_ULL(oq_no) instead of 1ULL << oq_no. Thanks to Dan Carpenter for
>     noting this is more appropriate.

Applied.

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

end of thread, other threads:[~2019-06-19  1:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-17 16:12 [PATCH][V2] net: lio_core: fix potential sign-extension overflow on large shift Colin King
2019-06-17 19:17 ` Dan Carpenter
2019-06-19  1:01 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).