]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
rdma/cxgb4: Prevent potential integer overflow on 32bit
authorDan Carpenter <dan.carpenter@linaro.org>
Sat, 30 Nov 2024 10:01:37 +0000 (13:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Mar 2025 11:50:04 +0000 (12:50 +0100)
[ Upstream commit bd96a3935e89486304461a21752f824fc25e0f0b ]

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: 1cab775c3e75 ("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: Sasha Levin <sashal@kernel.org>
drivers/infiniband/hw/cxgb4/device.c

index 541dbcf22d0ebf78aec4a979336bacc7357600bb..13e4b2c40d835a2a8166ca30c27bf258276b7202 100644 (file)
@@ -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;