cxgb4: prevent potential integer overflow on 32bit
Subsystems (3)
PATCH 1/1 cxgb4: prevent potential integer overflow on 32bit
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.
---
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(-)
drivers/infiniband/hw/cxgb4/device.c +4 -2
@@ -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 ;
Signature · 1 line
2.45.2
Quoted 10 lines · Dan Carpenter
The "
gl->tot_len" variable is controlled by the user. It comes fromprocess_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. Usesize_add()to prevent this.Fixes a08943947873 ("crypto: chtls - Register chtls with net tls")Signed-off-by Dan Carpenter <[email protected]>---
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:
Thanks,
Jason
Quoted 12 lines · Jason Gunthorpe
Quoted 10 lines · Dan Carpenter
The "
gl->tot_len" variable is controlled by the user. It comes fromprocess_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. Usesize_add()to prevent this.Fixes a08943947873 ("crypto: chtls - Register chtls with net tls")Signed-off-by Dan Carpenter <[email protected]>---
This is from static analysis. I've spent some time reviewing this code but I might be wrong.
Quoted 5 lines
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