From nobody Thu May 7 16:12:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9C8D1C433F5 for ; Tue, 24 May 2022 20:47:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241689AbiEXUrt (ORCPT ); Tue, 24 May 2022 16:47:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238638AbiEXUrq (ORCPT ); Tue, 24 May 2022 16:47:46 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A85BA7379F for ; Tue, 24 May 2022 13:47:44 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id p8so17447051pfh.8 for ; Tue, 24 May 2022 13:47:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3uRtfrODZaP6cR0RkQJZ2+zsYii1OwcOLnuKabGpEK8=; b=T5b5Xt9YaoxgVs4sV5AT0c/hlVtaFZxKefza3PoOUmHqZGiuEVXrmgipbywdk0MUHv LbZp53m4VRovrykWpWKYmL9BXOcQcpPZA4yDAC7jlOBrVu8qPWjzrtyG6soLeWcGb2xe njsftnjDBPYSxiLtaUKBxgn/7Nj/DEF3jdTA35hYa2v32+lALhxanhYg10oaanHqAU91 YlUx7iVa9M7JLF5z/JY7Tsuyn8T7My41ilTf3t6j8p4cRJ/xefmDHyRGgeswxSr/9Eef M4QVseQ8pftKqFsh4YfF14layFOZRoYWN/Y8vuEn8Zw3muUO5KqAZbQhByGQqabHdLXW 5U0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3uRtfrODZaP6cR0RkQJZ2+zsYii1OwcOLnuKabGpEK8=; b=GWSRmiMcdmGQnAhKy6AlJUwvuFJS1gDpjq0mKKXaXOK9QR7JiixSEkH8cMinQ9HkP8 Yx2Q6SRyooHN7lPVjHuvMbRZo8ugIgAZn70fgNlBYpyKwP/ORnp2QrHYzbqoUX43Zl27 ln6JpqoUv3BywlT16Y+Tl9XOWiFrGnNYcgGNcMOA6dRcvkqRLP21pW+o1HyR+omEfFS5 OA+saqPkLcTJwsQioH4t5fNmoMnH4kfmQFVIOFUw/jlJMFxiTVSt4JBTgLypdnqzwhyK pGmympHrUDDWqN+0v3pGYjEaUPg9/QOf1cxL4/yWwhHF8YvN0w541//aeoNif6exyv5w dIfQ== X-Gm-Message-State: AOAM531QZJEszc6/NNmCYgIvK6xoLmcqBxD8IbYFhElQQZJAEyqTyyxU Qsk0DPd4BUQNOFbMmNSWdUmxLmyPjAQZoQ== X-Google-Smtp-Source: ABdhPJwwpVXtrpCz9jVGk8iP4WrNBX+WMLN52wp4D2psv/hI+w3spN+5vdPNbAvKQkjySp4B6lh9jg== X-Received: by 2002:a05:6a00:1145:b0:4f6:3ebc:a79b with SMTP id b5-20020a056a00114500b004f63ebca79bmr30284723pfm.41.1653425264154; Tue, 24 May 2022 13:47:44 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id r8-20020a17090a690800b001dfffd861cbsm216333pjj.21.2022.05.24.13.47.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 May 2022 13:47:43 -0700 (PDT) From: Stephen Hemminger To: netdev@vger.kernel.org Cc: Stephen Hemminger , Steffen Klassert , Herbert Xu , "David S. Miller" , linux-kernel@vger.kernel.org (open list) Subject: [RFC] xfrm: convert alg_key to flexible array member Date: Tue, 24 May 2022 13:47:40 -0700 Message-Id: <20220524204741.980721-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Iproute2 build generates a warning when built with gcc-12. This is because the alg_key in xfrm.h API has zero size array element instead of flexible array. CC xfrm_state.o In function =E2=80=98xfrm_algo_parse=E2=80=99, inlined from =E2=80=98xfrm_state_modify.constprop=E2=80=99 at xfrm_stat= e.c:573:5: xfrm_state.c:162:32: warning: writing 1 byte into a region of size 0 [-Wstr= ingop-overflow=3D] 162 | buf[j] =3D val; | ~~~~~~~^~~~~ This patch convert the alg_key into flexible array member. There are other zero size arrays here that should be converted as well. This patch is RFC only since it is only compile tested and passes trivial iproute2 tests. Signed-off-by: Stephen Hemminger Acked-by: Herbert Xu --- include/uapi/linux/xfrm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h index 65e13a099b1a..3ed61df9cc91 100644 --- a/include/uapi/linux/xfrm.h +++ b/include/uapi/linux/xfrm.h @@ -102,21 +102,21 @@ struct xfrm_replay_state_esn { struct xfrm_algo { char alg_name[64]; unsigned int alg_key_len; /* in bits */ - char alg_key[0]; + char alg_key[]; }; =20 struct xfrm_algo_auth { char alg_name[64]; unsigned int alg_key_len; /* in bits */ unsigned int alg_trunc_len; /* in bits */ - char alg_key[0]; + char alg_key[]; }; =20 struct xfrm_algo_aead { char alg_name[64]; unsigned int alg_key_len; /* in bits */ unsigned int alg_icv_len; /* in bits */ - char alg_key[0]; + char alg_key[]; }; =20 struct xfrm_stats { --=20 2.35.1