Skip to content

evmctl: reject a zero-length IMA digest field - #47

Open
Eusgor wants to merge 1 commit into
linux-integrity:next-testingfrom
Eusgor:evmctl-digest-field-bounds
Open

Eusgor wants to merge 1 commit into
linux-integrity:next-testingfrom
Eusgor:evmctl-digest-field-bounds

Conversation

@Eusgor

@Eusgor Eusgor commented Sep 23, 2026

Copy link
Copy Markdown

ima_ng_show() already rejects a digest field longer than the remaining template data. A zero length still passes that test: field_len - 1 wraps to UINT32_MAX and is passed to strnlen(), which reads past the template buffer. Subtracting that length from field_len can wrap as well.

Require a non-zero digest field before using field_len - 1 as the strnlen() limit. strnlen() then returns at most field_len - 1, so the existing field_len - len subtraction stays in range.

ima_ng_show() already rejects a digest field longer than the
remaining template data. A zero length still passes that test:
field_len - 1 wraps to UINT32_MAX and is passed to strnlen(), which
reads past the template buffer. Subtracting that length from
field_len can wrap as well.

Require a non-zero digest field before using field_len - 1 as the
strnlen() limit. strnlen() then returns at most field_len - 1, so
the existing field_len - len subtraction stays in range.

Signed-off-by: Evgeniy Gorbanyov <esgor@altlinux.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant