Skip to content

Commit 91305f5

Browse files
committed
rdma/cxgb4: Prevent potential integer overflow on 32bit
JIRA: https://issues.redhat.com/browse/RHEL-83218 commit bd96a39 Author: Dan Carpenter <dan.carpenter@linaro.org> Date: Sat Nov 30 13:01:37 2024 +0300 rdma/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. Fixes: 1cab775 ("RDMA/cxgb4: Fix LE hash collision bug for passive open connection") Link: https://patch.msgid.link/r/86b404e1-4a75-4a35-a34e-e3054fa554c7@stanley.mountain Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Kamal Heib <kheib@redhat.com>
1 parent 3f16b28 commit 91305f5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/infiniband/hw/cxgb4/device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,10 @@ static inline struct sk_buff *copy_gl_to_skb_pkt(const struct pkt_gl *gl,
11141114
* The math here assumes sizeof cpl_pass_accept_req >= sizeof
11151115
* cpl_rx_pkt.
11161116
*/
1117-
skb = alloc_skb(gl->tot_len + sizeof(struct cpl_pass_accept_req) +
1118-
sizeof(struct rss_header) - pktshift, GFP_ATOMIC);
1117+
skb = alloc_skb(size_add(gl->tot_len,
1118+
sizeof(struct cpl_pass_accept_req) +
1119+
sizeof(struct rss_header)) - pktshift,
1120+
GFP_ATOMIC);
11191121
if (unlikely(!skb))
11201122
return NULL;
11211123

0 commit comments

Comments
 (0)