Patch "net: ethernet: mtk_eth_soc: Avoid truncating allocation" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: ethernet: mtk_eth_soc: Avoid truncating allocation

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-ethernet-mtk_eth_soc-avoid-truncating-allocation.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 954e7e1f4863814e856f6b8327bece646351ea96
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Fri Jan 27 14:38:54 2023 -0800

    net: ethernet: mtk_eth_soc: Avoid truncating allocation
    
    [ Upstream commit f3eceaed9edd7c0e0d9fb057613131f92973626f ]
    
    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@xxxxxxxx>
    Cc: John Crispin <john@xxxxxxxxxxx>
    Cc: Sean Wang <sean.wang@xxxxxxxxxxxx>
    Cc: Mark Lee <Mark-MC.Lee@xxxxxxxxxxxx>
    Cc: Lorenzo Bianconi <lorenzo@xxxxxxxxxx>
    Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
    Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
    Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
    Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
    Cc: Matthias Brugger <matthias.bgg@xxxxxxxxx>
    Cc: netdev@xxxxxxxxxxxxxxx
    Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
    Cc: linux-mediatek@xxxxxxxxxxxxxxxxxxx
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Reviewed-by: Simon Horman <simon.horman@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230127223853.never.014-kees@xxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
index 784ecb2dc9fbd..34ea8af48c3d0 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
@@ -595,8 +595,7 @@ mtk_foe_entry_commit_subflow(struct mtk_ppe *ppe, struct mtk_flow_entry *entry,
 	u32 ib1_mask = mtk_get_ib1_pkt_type_mask(ppe->eth) | MTK_FOE_IB1_UDP;
 	int type;
 
-	flow_info = kzalloc(offsetof(struct mtk_flow_entry, l2_data.end),
-			    GFP_ATOMIC);
+	flow_info = kzalloc(sizeof(*flow_info), GFP_ATOMIC);
 	if (!flow_info)
 		return;
 
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.h b/drivers/net/ethernet/mediatek/mtk_ppe.h
index a09c32539bcc9..e66283b1bc79e 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe.h
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
@@ -277,7 +277,6 @@ struct mtk_flow_entry {
 		struct {
 			struct mtk_flow_entry *base_flow;
 			struct hlist_node list;
-			struct {} end;
 		} l2_data;
 	};
 	struct rhash_head node;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux