From patchwork Mon Sep 5 07:58:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuigaosheng X-Patchwork-Id: 12965728 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 5DE7AC6FA89 for ; Mon, 5 Sep 2022 07:58:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237231AbiIEH6t (ORCPT ); Mon, 5 Sep 2022 03:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237166AbiIEH6m (ORCPT ); Mon, 5 Sep 2022 03:58:42 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 688D946DAC; Mon, 5 Sep 2022 00:58:40 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MLglx09Fbz1P6gb; Mon, 5 Sep 2022 15:54:52 +0800 (CST) Received: from cgs.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 15:58:38 +0800 From: Gaosheng Cui To: , , , , , CC: , , Subject: [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Date: Mon, 5 Sep 2022 15:58:34 +0800 Message-ID: <20220905075837.1083216-2-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905075837.1083216-1-cuigaosheng1@huawei.com> References: <20220905075837.1083216-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration with the new DECLARE_FLEX_ARRAY() helper macro in struct modsig. This helper allows for a flexible-array member in a union. Link: KSPP#21 Link: KSPP#193 Link: KSPP#197 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gaosheng Cui --- security/integrity/ima/ima_modsig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_modsig.c b/security/integrity/ima/ima_modsig.c index fb25723c65bc..d132383dbb64 100644 --- a/security/integrity/ima/ima_modsig.c +++ b/security/integrity/ima/ima_modsig.c @@ -29,7 +29,7 @@ struct modsig { * storing the signature. */ int raw_pkcs7_len; - u8 raw_pkcs7[]; + DECLARE_FLEX_ARRAY(u8, raw_pkcs7); }; /* From patchwork Mon Sep 5 07:58:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuigaosheng X-Patchwork-Id: 12965731 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 6F550C6FA91 for ; Mon, 5 Sep 2022 07:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237238AbiIEH6v (ORCPT ); Mon, 5 Sep 2022 03:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237183AbiIEH6n (ORCPT ); Mon, 5 Sep 2022 03:58:43 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99E0A26ACA; Mon, 5 Sep 2022 00:58:41 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MLglx12QZzkWJl; Mon, 5 Sep 2022 15:54:53 +0800 (CST) Received: from cgs.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 15:58:38 +0800 From: Gaosheng Cui To: , , , , , CC: , , Subject: [PATCH -next 2/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry Date: Mon, 5 Sep 2022 15:58:35 +0800 Message-ID: <20220905075837.1083216-3-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905075837.1083216-1-cuigaosheng1@huawei.com> References: <20220905075837.1083216-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration with the new DECLARE_FLEX_ARRAY() helper macro in struct ima_template_entry. This helper allows for a flexible-array member in a union. Link: KSPP#21 Link: KSPP#193 Link: KSPP#197 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gaosheng Cui --- security/integrity/ima/ima.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index be965a8715e4..15687e79944b 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -100,7 +100,7 @@ struct ima_template_entry { struct tpm_digest *digests; struct ima_template_desc *template_desc; /* template descriptor */ u32 template_data_len; - struct ima_field_data template_data[]; /* template related data */ + DECLARE_FLEX_ARRAY(struct ima_field_data, template_data); /* template related data */ }; struct ima_queue_entry { From patchwork Mon Sep 5 07:58:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuigaosheng X-Patchwork-Id: 12965730 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 488C2C6FA8E for ; Mon, 5 Sep 2022 07:58:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237235AbiIEH6u (ORCPT ); Mon, 5 Sep 2022 03:58:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237186AbiIEH6n (ORCPT ); Mon, 5 Sep 2022 03:58:43 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22038474E1; Mon, 5 Sep 2022 00:58:41 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLgmC547JzmV5d; Mon, 5 Sep 2022 15:55:07 +0800 (CST) Received: from cgs.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 15:58:39 +0800 From: Gaosheng Cui To: , , , , , CC: , , Subject: [PATCH -next 3/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy Date: Mon, 5 Sep 2022 15:58:36 +0800 Message-ID: <20220905075837.1083216-4-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905075837.1083216-1-cuigaosheng1@huawei.com> References: <20220905075837.1083216-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declaration with the new DECLARE_FLEX_ARRAY() helper macro in struct ima_rule_opt_list. This helper allows for a flexible-array member in a union. Link: KSPP#21 Link: KSPP#193 Link: KSPP#197 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gaosheng Cui --- security/integrity/ima/ima_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index a8802b8da946..a93e8d0fd90f 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -68,7 +68,7 @@ enum policy_rule_list { IMA_DEFAULT_POLICY = 1, IMA_CUSTOM_POLICY }; struct ima_rule_opt_list { size_t count; - char *items[]; + DECLARE_FLEX_ARRAY(char *, items); }; struct ima_rule_entry { From patchwork Mon Sep 5 07:58:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuigaosheng X-Patchwork-Id: 12965727 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 88630ECAAA1 for ; Mon, 5 Sep 2022 07:58:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237226AbiIEH6s (ORCPT ); Mon, 5 Sep 2022 03:58:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237188AbiIEH6o (ORCPT ); Mon, 5 Sep 2022 03:58:44 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 229F2474E9; Mon, 5 Sep 2022 00:58:41 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MLgmD0wjmzmV7N; Mon, 5 Sep 2022 15:55:08 +0800 (CST) Received: from cgs.huawei.com (10.244.148.83) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 5 Sep 2022 15:58:39 +0800 From: Gaosheng Cui To: , , , , , CC: , , Subject: [PATCH -next 4/4] integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h Date: Mon, 5 Sep 2022 15:58:37 +0800 Message-ID: <20220905075837.1083216-5-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220905075837.1083216-1-cuigaosheng1@huawei.com> References: <20220905075837.1083216-1-cuigaosheng1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.244.148.83] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected Precedence: bulk List-ID: Zero-length arrays are deprecated and we are moving towards adopting C99 flexible-array members instead. So, replace zero-length array declarations with the new DECLARE_FLEX_ARRAY() helper macro in integrity.h. As follows: struct evm_ima_xattr_data, struct ima_digest_data, struct signature_v2_hdr, This helper allows for a flexible-array member in a union. Link: KSPP#21 Link: KSPP#193 Link: KSPP#197 Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html Signed-off-by: Gaosheng Cui --- security/integrity/integrity.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 7167a6e99bdc..3eeea8d630e0 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h @@ -85,7 +85,7 @@ enum evm_ima_xattr_type { struct evm_ima_xattr_data { u8 type; - u8 data[]; + DECLARE_FLEX_ARRAY(u8, data); } __packed; /* Only used in the EVM HMAC code. */ @@ -110,7 +110,7 @@ struct ima_digest_data { } ng; u8 data[2]; } xattr; - u8 digest[]; + DECLARE_FLEX_ARRAY(u8, digest); } __packed; /* @@ -138,7 +138,7 @@ struct signature_v2_hdr { uint8_t hash_algo; /* Digest algorithm [enum hash_algo] */ __be32 keyid; /* IMA key identifier - not X509/PGP specific */ __be16 sig_size; /* signature size */ - uint8_t sig[]; /* signature payload */ + DECLARE_FLEX_ARRAY(uint8_t, sig); /* signature payload */ } __packed; /*