• Kees Cook's avatar
    net: ethernet: mtk_eth_soc: Avoid truncating allocation · f3eceaed
    Kees Cook authored
    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: default avatarKees Cook <keescook@chromium.org>
    Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
    Link: https://lore.kernel.org/r/20230127223853.never.014-kees@kernel.orgSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    f3eceaed
mtk_ppe.h 8.35 KB