2
0

733-v6.2-01-net-ethernet-mtk_eth_soc-Avoid-truncating-allocation.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From f3eceaed9edd7c0e0d9fb057613131f92973626f Mon Sep 17 00:00:00 2001
  2. From: Kees Cook <[email protected]>
  3. Date: Fri, 27 Jan 2023 14:38:54 -0800
  4. Subject: [PATCH] net: ethernet: mtk_eth_soc: Avoid truncating allocation
  5. There doesn't appear to be a reason to truncate the allocation used for
  6. flow_info, so do a full allocation and remove the unused empty struct.
  7. GCC does not like having a reference to an object that has been
  8. partially allocated, as bounds checking may become impossible when
  9. such an object is passed to other code. Seen with GCC 13:
  10. ../drivers/net/ethernet/mediatek/mtk_ppe.c: In function 'mtk_foe_entry_commit_subflow':
  11. ../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=]
  12. 623 | flow_info->l2_data.base_flow = entry;
  13. | ^~
  14. Cc: Felix Fietkau <[email protected]>
  15. Cc: John Crispin <[email protected]>
  16. Cc: Sean Wang <[email protected]>
  17. Cc: Mark Lee <[email protected]>
  18. Cc: Lorenzo Bianconi <[email protected]>
  19. Cc: "David S. Miller" <[email protected]>
  20. Cc: Eric Dumazet <[email protected]>
  21. Cc: Jakub Kicinski <[email protected]>
  22. Cc: Paolo Abeni <[email protected]>
  23. Cc: Matthias Brugger <[email protected]>
  24. Cc: [email protected]
  25. Cc: [email protected]
  26. Cc: [email protected]
  27. Signed-off-by: Kees Cook <[email protected]>
  28. Reviewed-by: Simon Horman <[email protected]>
  29. Link: https://lore.kernel.org/r/[email protected]
  30. Signed-off-by: Paolo Abeni <[email protected]>
  31. ---
  32. drivers/net/ethernet/mediatek/mtk_ppe.c | 3 +--
  33. drivers/net/ethernet/mediatek/mtk_ppe.h | 1 -
  34. 2 files changed, 1 insertion(+), 3 deletions(-)
  35. --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
  36. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
  37. @@ -621,8 +621,7 @@ mtk_foe_entry_commit_subflow(struct mtk_
  38. u32 ib1_mask = mtk_get_ib1_pkt_type_mask(ppe->eth) | MTK_FOE_IB1_UDP;
  39. int type;
  40. - flow_info = kzalloc(offsetof(struct mtk_flow_entry, l2_data.end),
  41. - GFP_ATOMIC);
  42. + flow_info = kzalloc(sizeof(*flow_info), GFP_ATOMIC);
  43. if (!flow_info)
  44. return;
  45. --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
  46. +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
  47. @@ -279,7 +279,6 @@ struct mtk_flow_entry {
  48. struct {
  49. struct mtk_flow_entry *base_flow;
  50. struct hlist_node list;
  51. - struct {} end;
  52. } l2_data;
  53. };
  54. struct rhash_head node;