Skip to content

Fix #2828, use PLATFORM not MISSION bound in ES pool bucket check - #2838

Open
NAVEENKUMARKR777 wants to merge 1 commit into
nasa:mainfrom
NAVEENKUMARKR777:fix-2828-pool-bounds
Open

NAVEENKUMARKR777 wants to merge 1 commit into
nasa:mainfrom
NAVEENKUMARKR777:fix-2828-pool-bounds

Conversation

@NAVEENKUMARKR777

Copy link
Copy Markdown

Closes #2828

Summary

CFE_ES_PoolCreateEx_WithAlignment() bounds-checks NumBlockSizes against CFE_MISSION_ES_POOL_MAX_BUCKETS:

if (NumBlockSizes > CFE_MISSION_ES_POOL_MAX_BUCKETS)

but the array it populates a few lines later, CFE_ES_GenPoolRecord_t::Buckets[] (modules/es/fsw/src/cfe_es_generic_pool.h), is sized with the platform constant:

CFE_ES_GenPoolBucket_t Buckets[CFE_PLATFORM_ES_POOL_MAX_BUCKETS];

cfe_es_verify.h only enforces CFE_MISSION_ES_POOL_MAX_BUCKETS >= CFE_PLATFORM_ES_POOL_MAX_BUCKETS, which is a valid, supported configuration relationship (the mission constant also sizes the BlockStats[] telemetry array in CFE_ES_MemPoolStats_t, which is intentionally mission-wide for cross-platform telemetry compatibility - that usage at line ~708 of the same file is correct and untouched by this PR). So on any mission where MISSION > PLATFORM, a caller-supplied NumBlockSizes between PLATFORM+1 and MISSION passes this check and then writes past the end of Buckets[].

This fix changes the check to use CFE_PLATFORM_ES_POOL_MAX_BUCKETS, matching the array it actually guards.

Why the existing unit test didn't catch this

The reference/sample config (cmake/sample_defs/example_mission_cfg.h and example_platform_cfg.h) sets both constants to 17, so they're indistinguishable in the default unit-test build - the existing boundary test (PLATFORM_MAX_BUCKETS + 2) passed identically before and after this fix. I tightened it to the exact boundary (PLATFORM_MAX_BUCKETS + 1) and added a comment explaining why PLATFORM, not MISSION, is the correct bound, so the intent is documented even though this specific config can't exercise the divergence.

Testing

Built and ran the ES module's full coverage-test suite (coverage-es-ALL-testrunner) via the standard simple.mk / ENABLE_UNIT_TESTS=true native build: 1347/1347 assertions pass, including the updated TestESMempool case.

CFE_ES_PoolCreateEx_WithAlignment() checked NumBlockSizes against
CFE_MISSION_ES_POOL_MAX_BUCKETS, but the Buckets[] array it populates
(CFE_ES_GenPoolRecord_t::Buckets) is sized with the platform constant.
cfe_es_verify.h only requires MISSION >= PLATFORM, so a valid mission
config with MISSION > PLATFORM passed the check and then wrote past
the end of the array. Check against CFE_PLATFORM_ES_POOL_MAX_BUCKETS
instead, matching the array's real size.

Also tightens the existing unit test to the exact boundary and
documents why PLATFORM (not MISSION) is the correct bound.
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