mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.11 01/10] integrity: Use static_assert() to check struct sizes
@ 2024-11-20 14:05 Sasha Levin
  2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 02/10] ASoC: audio-graph-card2: Purge absent supplies for device tree nodes Sasha Levin
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Sasha Levin @ 2024-11-20 14:05 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Gustavo A. R. Silva, Roberto Sassu, Mimi Zohar, Sasha Levin,
	dmitry.kasatkin, paul, jmorris, serge, linux-integrity,
	linux-security-module

From: "Gustavo A. R. Silva" <gustavoars@kernel.org>

[ Upstream commit 08ae3e5f5fc8edb9bd0c7ef9696ff29ef18b26ef ]

Commit 38aa3f5ac6d2 ("integrity: Avoid -Wflex-array-member-not-at-end
warnings") introduced tagged `struct evm_ima_xattr_data_hdr` and
`struct ima_digest_data_hdr`. We want to ensure that when new members
need to be added to the flexible structures, they are always included
within these tagged structs.

So, we use `static_assert()` to ensure that the memory layout for
both the flexible structure and the tagged struct is the same after
any changes.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Tested-by: Roberto Sassu <roberto.sassu@huawei.com>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 security/integrity/integrity.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h
index 660f76cb69d37..c2c2da6911233 100644
--- a/security/integrity/integrity.h
+++ b/security/integrity/integrity.h
@@ -37,6 +37,8 @@ struct evm_ima_xattr_data {
 	);
 	u8 data[];
 } __packed;
+static_assert(offsetof(struct evm_ima_xattr_data, data) == sizeof(struct evm_ima_xattr_data_hdr),
+	      "struct member likely outside of __struct_group()");
 
 /* Only used in the EVM HMAC code. */
 struct evm_xattr {
@@ -65,6 +67,8 @@ struct ima_digest_data {
 	);
 	u8 digest[];
 } __packed;
+static_assert(offsetof(struct ima_digest_data, digest) == sizeof(struct ima_digest_data_hdr),
+	      "struct member likely outside of __struct_group()");
 
 /*
  * Instead of wrapping the ima_digest_data struct inside a local structure
-- 
2.43.0


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

end of thread, other threads:[~2024-11-20 14:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-20 14:05 [PATCH AUTOSEL 6.11 01/10] integrity: Use static_assert() to check struct sizes Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 02/10] ASoC: audio-graph-card2: Purge absent supplies for device tree nodes Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 03/10] LoongArch: For all possible CPUs setup logical-physical CPU mapping Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 04/10] LoongArch: Define a default value for VM_DATA_DEFAULT_FLAGS Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 05/10] ASoC: max9768: Fix event generation for playback mute Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 06/10] ALSA: usb-audio: Fix Yamaha P-125 Quirk Entry Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 07/10] ARM: 9420/1: smp: Fix SMP for xip kernels Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 08/10] ARM: 9434/1: cfi: Fix compilation corner case Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 09/10] drm/xe: Restore system memory GGTT mappings Sasha Levin
2024-11-20 14:05 ` [PATCH AUTOSEL 6.11 10/10] ipmr: Fix access to mfc_cache_list without lock held Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®