* [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation
@ 2021-06-05 12:20 Colin King
2021-06-07 14:54 ` Saleem, Shiraz
2021-06-07 23:45 ` Jason Gunthorpe
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-06-05 12:20 UTC (permalink / raw)
To: Mustafa Ismail, Shiraz Saleem, Doug Ledford, Jason Gunthorpe, linux-rdma
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The shifting of the u8 integer info->map[i] the left will be promoted
to a 32 bit signed int and then sign-extended to a u64. In the event
that the top bit of the u8 is set then all then all the upper 32 bits
of the u64 end up as also being set because of the sign-extension.
Fix this by casting the u8 values to a u64 before the left shift. This
Addresses-Coverity: ("Unitentional integer overflow / bad shift operation")
Fixes: 3f49d6842569 ("RDMA/irdma: Implement HW Admin Queue OPs")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/infiniband/hw/irdma/ctrl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/irdma/ctrl.c b/drivers/infiniband/hw/irdma/ctrl.c
index 5aa112067bce..8bd3aecadaf6 100644
--- a/drivers/infiniband/hw/irdma/ctrl.c
+++ b/drivers/infiniband/hw/irdma/ctrl.c
@@ -2157,7 +2157,7 @@ static enum irdma_status_code irdma_sc_set_up_map(struct irdma_sc_cqp *cqp,
return IRDMA_ERR_RING_FULL;
for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++)
- temp |= info->map[i] << (i * 8);
+ temp |= (u64)info->map[i] << (i * 8);
set_64bit_val(wqe, 0, temp);
set_64bit_val(wqe, 40,
--
2.31.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation
2021-06-05 12:20 [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation Colin King
@ 2021-06-07 14:54 ` Saleem, Shiraz
2021-06-07 23:45 ` Jason Gunthorpe
1 sibling, 0 replies; 3+ messages in thread
From: Saleem, Shiraz @ 2021-06-07 14:54 UTC (permalink / raw)
To: Colin King, Ismail, Mustafa, Doug Ledford, Jason Gunthorpe, linux-rdma
Cc: kernel-janitors, linux-kernel
> Subject: [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The shifting of the u8 integer info->map[i] the left will be promoted to a 32 bit
> signed int and then sign-extended to a u64. In the event that the top bit of the u8 is
> set then all then all the upper 32 bits of the u64 end up as also being set because
> of the sign-extension.
> Fix this by casting the u8 values to a u64 before the left shift. This
>
> Addresses-Coverity: ("Unitentional integer overflow / bad shift operation")
> Fixes: 3f49d6842569 ("RDMA/irdma: Implement HW Admin Queue OPs")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/infiniband/hw/irdma/ctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/irdma/ctrl.c b/drivers/infiniband/hw/irdma/ctrl.c
> index 5aa112067bce..8bd3aecadaf6 100644
> --- a/drivers/infiniband/hw/irdma/ctrl.c
> +++ b/drivers/infiniband/hw/irdma/ctrl.c
> @@ -2157,7 +2157,7 @@ static enum irdma_status_code
> irdma_sc_set_up_map(struct irdma_sc_cqp *cqp,
> return IRDMA_ERR_RING_FULL;
>
> for (i = 0; i < IRDMA_MAX_USER_PRIORITY; i++)
> - temp |= info->map[i] << (i * 8);
> + temp |= (u64)info->map[i] << (i * 8);
>
Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation
2021-06-05 12:20 [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation Colin King
2021-06-07 14:54 ` Saleem, Shiraz
@ 2021-06-07 23:45 ` Jason Gunthorpe
1 sibling, 0 replies; 3+ messages in thread
From: Jason Gunthorpe @ 2021-06-07 23:45 UTC (permalink / raw)
To: Colin King
Cc: Mustafa Ismail, Shiraz Saleem, Doug Ledford, linux-rdma,
kernel-janitors, linux-kernel
On Sat, Jun 05, 2021 at 01:20:59PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The shifting of the u8 integer info->map[i] the left will be promoted
> to a 32 bit signed int and then sign-extended to a u64. In the event
> that the top bit of the u8 is set then all then all the upper 32 bits
> of the u64 end up as also being set because of the sign-extension.
> Fix this by casting the u8 values to a u64 before the left shift. This
>
> Addresses-Coverity: ("Unitentional integer overflow / bad shift operation")
> Fixes: 3f49d6842569 ("RDMA/irdma: Implement HW Admin Queue OPs")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Acked-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
> drivers/infiniband/hw/irdma/ctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to for-next, thanks
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-07 23:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-05 12:20 [PATCH][next] RDMA/irdma: Fix issues with u8 left shift operation Colin King
2021-06-07 14:54 ` Saleem, Shiraz
2021-06-07 23:45 ` Jason Gunthorpe
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.