cache: fix shm sizing on large-page Linux - #13536
Merged
Merged
Conversation
POSIX shared-memory objects on Linux retain the exact length passed to ftruncate(), but the cache shm gates accepted any size through the next page boundary. On 64 KiB-page systems, a foreign control layout could therefore be treated as compatible, causing cleanup and tooling paths to walk an untrusted stripe table and leave segments behind. This patch requires exact shared-memory object sizes outside macOS while preserving macOS's page-rounded allowance. It keeps the foreign-layout test at its original size and directly covers the platform-specific sizing contract. Fixes: apache#13534
bneradt
force-pushed
the
fix-cache-shm-large-page-test
branch
from
August 11, 2026 19:00
614c314 to
f56930f
Compare
Contributor
|
Confirmed this resolves my test failure on ppc64le! |
masaori335
approved these changes
Aug 12, 2026
masaori335
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Thank you!
cmcfarlen
pushed a commit
that referenced
this pull request
Aug 12, 2026
POSIX shared-memory objects on Linux retain the exact length passed to ftruncate(), but the cache shm gates accepted any size through the next page boundary. On 64 KiB-page systems, a foreign control layout could therefore be treated as compatible, causing cleanup and tooling paths to walk an untrusted stripe table and leave segments behind. This patch requires exact shared-memory object sizes outside macOS while preserving macOS's page-rounded allowance. It keeps the foreign-layout test at its original size and directly covers the platform-specific sizing contract. Fixes: #13534 (cherry picked from commit f0668e1)
Contributor
|
Cherry-picked to the 10.2.x branch as 21f5363 for the 10.2.0 release. |
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.
Problem
Linux POSIX shared-memory objects retain the exact length passed to
ftruncate(). ATS instead accepted any reported object size from the requested length through the next page boundary. On a 64 KiB-page system, that range can include a foreignCacheShmControllayout.The normal server attach still rejects an ABI mismatch before reusing cache data, but its cleanup path,
traffic_ctl cache shm status, andtraffic_ctl cache shm clearcould treat the foreign stripe table as trusted. Walking that table with the current build's layout can misidentify stripe segments and leave them behind.Fix
Require exact POSIX shared-memory object sizes outside macOS. Preserve the page-rounded allowance on macOS, where the reported object size is rounded, and use the same platform-specific predicate for both control and stripe objects.
The foreign-layout purge test keeps its original
CONTROL_SIZE * 2fixture. A focused unit test also covers the platform-specific object-size contract.Reproduction and verification
I reproduced this in a container built from CI's
ci.trafficserver.apache.org/ats/fedora:44image. To exercise the 64 KiB sizing path without special hardware, a temporaryLD_PRELOADshim overrode onlysysconf(_SC_PAGESIZE)to return 65,536; shared-memory creation, sizing, mapping, and cleanup remained unchanged.On unmodified master (
46be2f500), the actual CacheShm CTest failed with the original fixture:After this patch, the same forced-64 KiB command and original fixture pass:
Normal verification in the same CI-image-based container also passed:
Fixes: #13534