summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorFan Wu <wufan@kernel.org>2026-10-02 19:51:32 -0700
committerFan Wu <wufan@kernel.org>2026-10-19 17:21:22 -0700
commit6adc404a9867eee83e9555eac36dfd0066fa3839 (patch)
treeea455e6f8164c1fe5d24d9abcfe5b19bc0365f2d /security
parente4933dbcb7eccf98ecb059d9b740420a477b1520 (diff)
ipe: check parser token table sizes
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>
Diffstat (limited to 'security')
-rw-r--r--security/ipe/policy_parser.c8
1 files changed, 8 insertions, 0 deletions
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.