linux/drivers/net/ethernet/mediatek
Kees Cook 5252655127 net: ethernet: mtk_eth_soc: Avoid truncating allocation
[ Upstream commit f3eceaed9e ]

There doesn't appear to be a reason to truncate the allocation used for
flow_info, so do a full allocation and remove the unused empty struct.
GCC does not like having a reference to an object that has been
partially allocated, as bounds checking may become impossible when
such an object is passed to other code. Seen with GCC 13:

../drivers/net/ethernet/mediatek/mtk_ppe.c: In function 'mtk_foe_entry_commit_subflow':
../drivers/net/ethernet/mediatek/mtk_ppe.c:623:18: warning: array subscript 'struct mtk_flow_entry[0]' is partly outside array bounds of 'unsigned char[48]' [-Warray-bounds=]
  623 |         flow_info->l2_data.base_flow = entry;
      |                  ^~

Cc: Felix Fietkau <nbd@nbd.name>
Cc: John Crispin <john@phrozen.org>
Cc: Sean Wang <sean.wang@mediatek.com>
Cc: Mark Lee <Mark-MC.Lee@mediatek.com>
Cc: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Matthias Brugger <matthias.bgg@gmail.com>
Cc: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20230127223853.never.014-kees@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-02-22 12:59:43 +01:00
..
Kconfig net: ethernet: mtk_eth_soc: add support for page_pool_get_stats 2022-07-25 10:38:57 +01:00
Makefile net: ethernet: mediatek: Remove -Warray-bounds exception 2022-10-07 08:49:29 +01:00
mtk_eth_path.c
mtk_eth_soc.c net: ethernet: mtk_eth_soc: fix wrong parameters order in __xdp_rxq_info_reg() 2023-02-14 19:11:48 +01:00
mtk_eth_soc.h net: ethernet: mtk_eth_soc: drop packets to WDMA if the ring is full 2022-12-31 13:33:02 +01:00
mtk_ppe_debugfs.c net: ethernet: mtk_eth_soc: use DEFINE_SHOW_ATTRIBUTE to simplify code 2022-09-29 09:57:23 +02:00
mtk_ppe_offload.c net: ethernet: mtk_eth_soc: introduce flow offloading support for mt7986 2022-09-22 15:13:24 +02:00
mtk_ppe_regs.h net: ethernet: mtk_eth_soc: introduce flow offloading support for mt7986 2022-09-22 15:13:24 +02:00
mtk_ppe.c net: ethernet: mtk_eth_soc: Avoid truncating allocation 2023-02-22 12:59:43 +01:00
mtk_ppe.h net: ethernet: mtk_eth_soc: Avoid truncating allocation 2023-02-22 12:59:43 +01:00
mtk_sgmii.c
mtk_star_emac.c net: ethernet: mtk-star-emac: disable napi when connect and start PHY failed in mtk_star_enable() 2022-11-08 13:28:07 +01:00
mtk_wed_debugfs.c net: ethernet: mtk_eth_wed: add wed support for mt7986 chipset 2022-09-22 15:13:24 +02:00
mtk_wed_ops.c
mtk_wed_regs.h net: ethernet: mtk_eth_wed: add axi bus support 2022-09-22 15:13:24 +02:00
mtk_wed.c net: ethernet: mtk_eth_wed: add missing of_node_put() 2022-10-17 09:35:06 +01:00
mtk_wed.h net: ethernet: mtk_eth_wed: add wed support for mt7986 chipset 2022-09-22 15:13:24 +02:00