* [PATCH] cxgb4: prevent potential integer overflow on 32bit
@ 2024-11-30 10:01 Dan Carpenter
2024-12-09 18:55 ` Jason Gunthorpe
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-11-30 10:01 UTC (permalink / raw)
To: Atul Gupta
Cc: Potnuri Bharat Teja, Jason Gunthorpe, Leon Romanovsky,
David S. Miller, Casey Leedom, Michael Werner, linux-rdma,
linux-kernel, kernel-janitors
The "gl->tot_len" variable is controlled by the user. It comes from
process_responses(). On 32bit systems, the "gl->tot_len +
sizeof(struct cpl_pass_accept_req) + sizeof(struct rss_header)" addition
could have an integer wrapping bug. Use size_add() to prevent this.
Fixes: a08943947873 ("crypto: chtls - Register chtls with net tls")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
This is from static analysis. I've spent some time reviewing this code
but I might be wrong.
drivers/infiniband/hw/cxgb4/device.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
index 80970a1738f8..034b85c42255 100644
--- a/drivers/infiniband/hw/cxgb4/device.c
+++ b/drivers/infiniband/hw/cxgb4/device.c
@@ -1114,8 +1114,10 @@ static inline struct sk_buff *copy_gl_to_skb_pkt(const struct pkt_gl *gl,
* The math here assumes sizeof cpl_pass_accept_req >= sizeof
* cpl_rx_pkt.
*/
- skb = alloc_skb(gl->tot_len + sizeof(struct cpl_pass_accept_req) +
- sizeof(struct rss_header) - pktshift, GFP_ATOMIC);
+ skb = alloc_skb(size_add(gl->tot_len,
+ sizeof(struct cpl_pass_accept_req) +
+ sizeof(struct rss_header)) - pktshift,
+ GFP_ATOMIC);
if (unlikely(!skb))
return NULL;
--
2.45.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] cxgb4: prevent potential integer overflow on 32bit
2024-11-30 10:01 [PATCH] cxgb4: prevent potential integer overflow on 32bit Dan Carpenter
@ 2024-12-09 18:55 ` Jason Gunthorpe
2024-12-10 9:18 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2024-12-09 18:55 UTC (permalink / raw)
To: Dan Carpenter
Cc: Atul Gupta, Potnuri Bharat Teja, Leon Romanovsky, David S. Miller,
Casey Leedom, Michael Werner, linux-rdma, linux-kernel,
kernel-janitors
On Sat, Nov 30, 2024 at 01:01:37PM +0300, Dan Carpenter wrote:
> The "gl->tot_len" variable is controlled by the user. It comes from
> process_responses(). On 32bit systems, the "gl->tot_len +
> sizeof(struct cpl_pass_accept_req) + sizeof(struct rss_header)" addition
> could have an integer wrapping bug. Use size_add() to prevent this.
>
> Fixes: a08943947873 ("crypto: chtls - Register chtls with net tls")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> This is from static analysis. I've spent some time reviewing this code
> but I might be wrong.
Applied to for-next
I fixed the Fixes line:
Fixes: 1cab775c3e75 ("RDMA/cxgb4: Fix LE hash collision bug for passive open connection")
Thanks,
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] cxgb4: prevent potential integer overflow on 32bit
2024-12-09 18:55 ` Jason Gunthorpe
@ 2024-12-10 9:18 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-12-10 9:18 UTC (permalink / raw)
To: Jason Gunthorpe
Cc: Atul Gupta, Potnuri Bharat Teja, Leon Romanovsky, David S. Miller,
Casey Leedom, Michael Werner, linux-rdma, linux-kernel,
kernel-janitors
On Mon, Dec 09, 2024 at 02:55:56PM -0400, Jason Gunthorpe wrote:
> On Sat, Nov 30, 2024 at 01:01:37PM +0300, Dan Carpenter wrote:
> > The "gl->tot_len" variable is controlled by the user. It comes from
> > process_responses(). On 32bit systems, the "gl->tot_len +
> > sizeof(struct cpl_pass_accept_req) + sizeof(struct rss_header)" addition
> > could have an integer wrapping bug. Use size_add() to prevent this.
> >
> > Fixes: a08943947873 ("crypto: chtls - Register chtls with net tls")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > This is from static analysis. I've spent some time reviewing this code
> > but I might be wrong.
>
> Applied to for-next
>
> I fixed the Fixes line:
>
> Fixes: 1cab775c3e75 ("RDMA/cxgb4: Fix LE hash collision bug for passive open connection")
Aw crud. There are two implementations of copy_gl_to_skb_pkt() and I
only patched one. It's pretty weird how I mixed up the Fixes tags.
Anyway, I'll patch drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_main.c
as well.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-12-10 9:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-30 10:01 [PATCH] cxgb4: prevent potential integer overflow on 32bit Dan Carpenter
2024-12-09 18:55 ` Jason Gunthorpe
2024-12-10 9:18 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox