From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>,
Roberto Sassu <roberto.sassu@huawei.com>,
Mimi Zohar <zohar@linux.ibm.com>, Sasha Levin <sashal@kernel.org>,
dmitry.kasatkin@gmail.com, paul@paul-moore.com,
jmorris@namei.org, serge@hallyn.com,
linux-integrity@vger.kernel.org,
linux-security-module@vger.kernel.org
Subject: [PATCH AUTOSEL 6.11 01/10] integrity: Use static_assert() to check struct sizes
Date: Wed, 20 Nov 2024 09:05:26 -0500 [thread overview]
Message-ID: <20241120140556.1768511-1-sashal@kernel.org> (raw)
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
next reply other threads:[~2024-11-20 14:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-20 14:05 Sasha Levin [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241120140556.1768511-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=dmitry.kasatkin@gmail.com \
--cc=gustavoars@kernel.org \
--cc=jmorris@namei.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=stable@vger.kernel.org \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®