fix: detect IMA across legacy and modern kernel integration - #66
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An initialized Linux 6.8 IMA instance can expose
securityfs/integrity/ima(and itsimacompatibility symlink), withruntime_measurements_count=42, while its LSM list containsintegrity,bpfbut noima. Previously bothIMAEnabledandIMAAnyMeasurementActivewere false: availability depended solely on the LSM list, and the measurement probe was skipped. Both now succeed for that fixture.Runtime evidence and error behavior
imaLSM entry or a visible IMA-specific securityfs directory at/sys/kernel/security/imaor/sys/kernel/security/integrity/ima. Follow symlinks and verify both directory type andSECURITYFS_MAGICwithstatfson the resolved directory. Ordinary directories and mount placeholders are rejected. No version branching, configuration-only positive, orintegrity-only positive.ActiveLSMsand BPF LSM detection retain their existing behavior.IMADirectorynegatives; permission/type and filesystem-lookup failures remain errors unless another IMA directory is verified on securityfs. Without any positive evidence, availability carries an unavailable-evidence error with underlying failures, rather than diagnosing IMA as disabled because securityfs is hidden./bin/truestimulus semantics are unchanged.The old unconditional
lsm=...,imaadvice was incorrect: Linux 6.8 initializes IMA viainit_ima()without a separate IMA LSM; Linux 6.9 registers IMA asLSM_ORDER_LAST, which is automatically included. Linux 6.8 already implementsbpf_ima_file_hash, and its underlying file-hash implementation can calculate a hash without a cached measurement. Availability does not guarantee measurement policy, appraisal enforcement, a file's cached hash, or BPF helper-call success.Validation
The securityfs correction in
6d22f66reproduced the ordinary-directory false positive before the fix using real Linux statfs (no mounts), then passed Linux race tests, coverage, vet, dependency verification, and the full Linux/macOS Bats suites.go test -race -count=1 ./...,make cover-check,make vet, andmake verify-depspassed. All six gated files remain above 90%; thresholds and exclusions are unchanged.bats test/passed on Linux with Bats 1.13.0, run unprivileged (root-only mount tests and platform-inapplicable cases skipped). Debian's older Bats initially failed its non-Linux suite skip; using the CI version resolved that harness failure.go test ./...and full Bats 1.13.0 suite passed, with Linux-only cases skipped.6d22f66: Linux Test (Go 1.24), Linux Integration, macOS CLI, Lint, CodeQL/security analysis, and labeler all passed.Limits and scope
This is a fixture-based Linux reproduction, not a live IMA-enabled legacy-kernel reproduction. Runtime visibility cannot establish appraisal or per-file/helper usability. Standalone exec/file-check algorithms and their existing compatibility-path reads are unchanged. Root mount integration and lint passed in PR CI on
6d22f66. No host policy, boot settings, or security mounts were changed; no generated kernel-version files or validator gaps were touched. The separate RHASH/BCC refresh failure is outside this change.Primary sources verified: Linux 6.8 initialization and file hashing, IMA securityfs paths, integrity infrastructure, Linux 6.9 IMA registration, LSM ordering, policy initialization, and BPF IMA helpers.