Skip to content

feat: add ProbeIMAExecMeasurementActive#59

Merged
leodido merged 6 commits into
mainfrom
add-probe-ima-exec-measurement-active
May 12, 2026
Merged

feat: add ProbeIMAExecMeasurementActive#59
leodido merged 6 commits into
mainfrom
add-probe-ima-exec-measurement-active

Conversation

@leodido
Copy link
Copy Markdown
Owner

@leodido leodido commented May 12, 2026

Added

ProbeIMAExecMeasurementActive() ProbeResult — checks whether an IMA measurement rule covering exec (e.g., func=BPRM_CHECK) is active by creating a fresh temporary executable (new inode), running it, and checking for a measurement count increase.

Semantic contract

  • Returns Supported=true only when the controlled exec stimulus increments the IMA measurement count
  • No count > 1 shortcut (unlike ProbeIMAAnyMeasurementActive)
  • Uses a fresh inode (copy of /bin/true in a temp dir) to avoid false negatives from IMA's per-inode measurement cache
  • Materializes the temp binary before reading the baseline count, so the measurement window contains only the exec and its kernel-side effects — avoids false positives from FILE_CHECK rules measuring the source read or temp-file write
  • Failed count read or failed temp exec → Supported=false with Error set
  • Direct Linux-only helper, not wired into Feature/Check/SystemFeatures yet

Also in this PR

  • readMeasurementCountFrom switched from fmt.Sscanf to strconv.Atoi — rejects trailing junk like "42abc" that Sscanf would silently accept
  • Tests for createFreshTempBinary (executable path, cleanup), execTempBinary (success, nonexistent path error), and a trailing-junk subtest for readMeasurementCountFrom

Series

This is PR 2 of 3 after #57:

  1. feat: add ReadIMARuntimeMeasurementsCount exported helper #58ReadIMARuntimeMeasurementsCount
  2. This PRProbeIMAExecMeasurementActive
  3. ProbeIMAFileCheckMeasurementActive — fresh temp file, same pattern

leodido and others added 6 commits May 12, 2026 12:58
Rejects trailing junk (e.g. '42abc') that fmt.Sscanf would silently
accept. The kernel file should never contain such content, but this
is stricter parser hygiene for a public helper's internals.

Co-authored-by: Ona <no-reply@ona.com>
Checks whether an IMA measurement rule covering exec (e.g.,
func=BPRM_CHECK) is active by creating a fresh temporary executable
(new inode), running it, and checking for a measurement count increase.

No count > 1 shortcut: returns Supported=true only when the controlled
exec stimulus increments the count. A fresh inode avoids false negatives
from IMA's per-inode measurement cache.

Co-authored-by: Ona <no-reply@ona.com>
Tests that execFreshTempBinary creates, executes, and cleans up the
temp binary. Adds a trailing-junk subtest for readMeasurementCountFrom
to verify the strconv.Atoi strictness.

Co-authored-by: Ona <no-reply@ona.com>
Materialize the temp binary before reading the baseline count so the
counted window contains only the exec stimulus. Splits execFreshTempBinary
into createFreshTempBinary (returns path + cleanup) and execTempBinary
(takes path). Avoids false positives from FILE_CHECK rules measuring
the source read or temp-file write during setup.

Co-authored-by: Ona <no-reply@ona.com>
Tests createFreshTempBinary (executable path, cleanup removes dir),
execTempBinary (success, nonexistent path error).

Co-authored-by: Ona <no-reply@ona.com>
@github-actions github-actions Bot added the enhancement New feature or request label May 12, 2026
@leodido leodido changed the title feat: add ProbeIMAExecMeasurementActive feat: add ProbeIMAExecMeasurementActive May 12, 2026
@leodido leodido self-assigned this May 12, 2026
@leodido leodido merged commit 1184cbc into main May 12, 2026
8 checks passed
@leodido leodido deleted the add-probe-ima-exec-measurement-active branch May 12, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant