linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima
@ 2022-09-05  7:58 Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Gaosheng Cui
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Gaosheng Cui @ 2022-09-05  7:58 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge, cuigaosheng1
  Cc: linux-integrity, linux-security-module, linux-kernel

This series contains a few cleanup patches, to replace fake flexible-array
declarations with DECLARE_FLEX_ARRAY() helper for ima. Thanks!

Link: https://github.com/KSPP/linux/issues/193

Gaosheng Cui (4):
  ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig
  ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry
  ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy
  integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h

 security/integrity/ima/ima.h        | 2 +-
 security/integrity/ima/ima_modsig.c | 2 +-
 security/integrity/ima/ima_policy.c | 2 +-
 security/integrity/integrity.h      | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig
  2022-09-05  7:58 [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima Gaosheng Cui
@ 2022-09-05  7:58 ` Gaosheng Cui
  2022-09-23 20:28   ` Mimi Zohar
  2022-09-05  7:58 ` [PATCH -next 2/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry Gaosheng Cui
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Gaosheng Cui @ 2022-09-05  7:58 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge, cuigaosheng1
  Cc: linux-integrity, linux-security-module, linux-kernel

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 <cuigaosheng1@huawei.com>
---
 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);
 };
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next 2/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry
  2022-09-05  7:58 [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Gaosheng Cui
@ 2022-09-05  7:58 ` Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 3/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 4/4] integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h Gaosheng Cui
  3 siblings, 0 replies; 6+ messages in thread
From: Gaosheng Cui @ 2022-09-05  7:58 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge, cuigaosheng1
  Cc: linux-integrity, linux-security-module, linux-kernel

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 <cuigaosheng1@huawei.com>
---
 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 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next 3/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy
  2022-09-05  7:58 [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 2/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry Gaosheng Cui
@ 2022-09-05  7:58 ` Gaosheng Cui
  2022-09-05  7:58 ` [PATCH -next 4/4] integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h Gaosheng Cui
  3 siblings, 0 replies; 6+ messages in thread
From: Gaosheng Cui @ 2022-09-05  7:58 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge, cuigaosheng1
  Cc: linux-integrity, linux-security-module, linux-kernel

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 <cuigaosheng1@huawei.com>
---
 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 {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH -next 4/4] integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h
  2022-09-05  7:58 [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima Gaosheng Cui
                   ` (2 preceding siblings ...)
  2022-09-05  7:58 ` [PATCH -next 3/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy Gaosheng Cui
@ 2022-09-05  7:58 ` Gaosheng Cui
  3 siblings, 0 replies; 6+ messages in thread
From: Gaosheng Cui @ 2022-09-05  7:58 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge, cuigaosheng1
  Cc: linux-integrity, linux-security-module, linux-kernel

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 <cuigaosheng1@huawei.com>
---
 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;
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig
  2022-09-05  7:58 ` [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Gaosheng Cui
@ 2022-09-23 20:28   ` Mimi Zohar
  0 siblings, 0 replies; 6+ messages in thread
From: Mimi Zohar @ 2022-09-23 20:28 UTC (permalink / raw)
  To: Gaosheng Cui, dmitry.kasatkin, paul, jmorris, serge
  Cc: linux-integrity, linux-security-module, linux-kernel

Hi Gaosheng,

Thank you for the patches.

On Mon, 2022-09-05 at 15:58 +0800, Gaosheng Cui wrote:
> 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

The above shortened link is a bit confusing.  The #193 complete link is
mentioned in the cover letter.  In all cases being modified the "[]" 
notation is used.  Is this a boiler plate patch description or are all
three of these links really applicable to each of the patches?  

- Eliminate fake flexible arrays from the kernel ("variable length"
one-element and zero-length arrays) #21
- Replace fake flexible-array declarations with the
DECLARE_FLEX_ARRAY() helper macro #193
- Address -Wzero-length-array warnings reported by Clang #197

> Link: https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html

Shouldn't this link be in the cover letter?  And the applicable
link(s), as shown in the cover letter, here in the patches?

-- 
thanks,

Mimi

> Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
> ---
>  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);
>  };
>  
>  /*



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-23 20:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-05  7:58 [PATCH -next 0/4] Use DECLARE_FLEX_ARRAY() helper for ima Gaosheng Cui
2022-09-05  7:58 ` [PATCH -next 1/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_modsig Gaosheng Cui
2022-09-23 20:28   ` Mimi Zohar
2022-09-05  7:58 ` [PATCH -next 2/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_template_entry Gaosheng Cui
2022-09-05  7:58 ` [PATCH -next 3/4] ima: Use DECLARE_FLEX_ARRAY() helper in ima_policy Gaosheng Cui
2022-09-05  7:58 ` [PATCH -next 4/4] integrity: Use DECLARE_FLEX_ARRAY() helper in integrity.h Gaosheng Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).