diff options
author | Gustavo A. R. Silva <gustavoars@kernel.org> | 2023-09-15 12:17:49 -0600 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-11-20 11:56:48 +0100 |
commit | 3f7955a902d8b285453e337a46f6ec74bb811c21 (patch) | |
tree | 6f207c0ae72b4c7a5a4b4316f99139bcc5747d49 /drivers/net/ethernet | |
parent | 1e5788c94e979e0224b26bae1d07da3acd794a1b (diff) | |
download | linux-stable-3f7955a902d8b285453e337a46f6ec74bb811c21.tar.gz linux-stable-3f7955a902d8b285453e337a46f6ec74bb811c21.tar.bz2 linux-stable-3f7955a902d8b285453e337a46f6ec74bb811c21.zip |
gve: Use size_add() in call to struct_size()
[ Upstream commit d692873cbe861a870cdc9cbfb120eefd113c3dfd ]
If, for any reason, `tx_stats_num + rx_stats_num` wraps around, the
protection that struct_size() adds against potential integer overflows
is defeated. Fix this by hardening call to struct_size() with size_add().
Fixes: 691f4077d560 ("gve: Replace zero-length array with flexible-array member")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/google/gve/gve_main.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c index e6f1711d9be0..465a6db5a40a 100644 --- a/drivers/net/ethernet/google/gve/gve_main.c +++ b/drivers/net/ethernet/google/gve/gve_main.c @@ -191,7 +191,7 @@ static int gve_alloc_stats_report(struct gve_priv *priv) rx_stats_num = (GVE_RX_STATS_REPORT_NUM + NIC_RX_STATS_REPORT_NUM) * priv->rx_cfg.num_queues; priv->stats_report_len = struct_size(priv->stats_report, stats, - tx_stats_num + rx_stats_num); + size_add(tx_stats_num, rx_stats_num)); priv->stats_report = dma_alloc_coherent(&priv->pdev->dev, priv->stats_report_len, &priv->stats_report_bus, GFP_KERNEL); |