From: Fan Wu <wufan@kernel.org>
To: linux-security-module@vger.kernel.org
Subject: [PATCH 3/6] ipe: check parser token table sizes
Date: Fri, 2 Oct 2026 19:51:32 -0700 [thread overview]
Message-ID: <20261003025135.3666767-4-wufan@kernel.org> (raw)
In-Reply-To: <20261003025135.3666767-1-wufan@kernel.org>
The parser token tables contain one entry for each enum value followed
by a terminator. Add static assertions so adding an enum value without a
corresponding token fails the build.
Assisted-by: LLM
Signed-off-by: Fan Wu <wufan@kernel.org>
---
security/ipe/policy_parser.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/security/ipe/policy_parser.c b/security/ipe/policy_parser.c
index f1c05e53667f..309a61594e1d 100644
--- a/security/ipe/policy_parser.c
+++ b/security/ipe/policy_parser.c
@@ -128,6 +128,8 @@ static const match_table_t header_tokens = {
{__IPE_HEADER_MAX, NULL}
};
+static_assert(ARRAY_SIZE(header_tokens) == __IPE_HEADER_MAX + 1);
+
/**
* parse_header() - Parse policy header information.
* @line: Supplies header line to be parsed.
@@ -240,6 +242,8 @@ static const match_table_t operation_tokens = {
{IPE_OP_INVALID, NULL}
};
+static_assert(ARRAY_SIZE(operation_tokens) == __IPE_OP_MAX + 1);
+
/**
* parse_operation() - Parse the operation type given a token string.
* @t: Supplies the token string to be parsed.
@@ -259,6 +263,8 @@ static const match_table_t action_tokens = {
{IPE_ACTION_INVALID, NULL}
};
+static_assert(ARRAY_SIZE(action_tokens) == __IPE_ACTION_MAX + 1);
+
/**
* parse_action() - Parse the action type given a token string.
* @t: Supplies the token string to be parsed.
@@ -284,6 +290,8 @@ static const match_table_t property_tokens = {
{IPE_PROP_INVALID, NULL}
};
+static_assert(ARRAY_SIZE(property_tokens) == __IPE_PROP_MAX + 1);
+
/**
* parse_property() - Parse a rule property given a token string.
* @t: Supplies the token string to be parsed.
--
2.55.0
next prev parent reply other threads:[~2026-10-03 2:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-03 2:51 [PATCH 0/6] ipe: cleanups, an audit fix and updated links Fan Wu
2026-10-03 2:51 ` [PATCH 1/6] ipe: constify token_default() Fan Wu
2026-10-03 2:56 ` sashiko-bot
2026-10-03 2:51 ` [PATCH 2/6] ipe: use designated initializers for audit name tables Fan Wu
2026-10-03 2:59 ` sashiko-bot
2026-10-03 2:51 ` Fan Wu [this message]
2026-10-03 2:56 ` [PATCH 3/6] ipe: check parser token table sizes sashiko-bot
2026-10-03 2:51 ` [PATCH 4/6] ipe: correct policy text ownership comment Fan Wu
2026-10-03 2:57 ` sashiko-bot
2026-10-03 2:51 ` [PATCH 5/6] ipe: fix enforcement audit Fan Wu
2026-10-03 2:55 ` sashiko-bot
2026-10-03 2:51 ` [PATCH 6/6] ipe: update the project and test suite links Fan Wu
2026-10-03 2:55 ` sashiko-bot
2026-10-06 16:59 ` [PATCH 0/6] ipe: cleanups, an audit fix and updated links Fan Wu
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=20261003025135.3666767-4-wufan@kernel.org \
--to=wufan@kernel.org \
--cc=linux-security-module@vger.kernel.org \
/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