Skip to content

cache: fix shm sizing on large-page Linux - #13536

Merged
bneradt merged 1 commit into
apache:masterfrom
bneradt:fix-cache-shm-large-page-test
Aug 12, 2026
Merged

cache: fix shm sizing on large-page Linux#13536
bneradt merged 1 commit into
apache:masterfrom
bneradt:fix-cache-shm-large-page-test

Conversation

@bneradt

@bneradt bneradt commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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 foreign CacheShmControl layout.

The normal server attach still rejects an ABI mismatch before reusing cache data, but its cleanup path, traffic_ctl cache shm status, and traffic_ctl cache shm clear could 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 * 2 fixture. 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:44 image. To exercise the 64 KiB sizing path without special hardware, a temporary LD_PRELOAD shim overrode only sysconf(_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:

CHECK(report.table_untrusted)
  expansion: false
CHECK_FALSE(segment_exists(stripe_name))
  expansion: !true

9 of 10 test cases passed
56 of 58 assertions passed

After this patch, the same forced-64 KiB command and original fixture pass:

All tests passed (61 assertions in 11 test cases)

Normal verification in the same CI-image-based container also passed:

  • CMake format target
  • Complete build and install
  • Full CTest suite: 186/186 passed

Fixes: #13534

Copilot AI lite review requested due to automatic review settings August 11, 2026 18:41
@bneradt bneradt added this to the 11.0.0 milestone Aug 11, 2026
@bneradt bneradt self-assigned this Aug 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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
bneradt force-pushed the fix-cache-shm-large-page-test branch from 614c314 to f56930f Compare August 11, 2026 19:00
Copilot AI review requested due to automatic review settings August 11, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@bneradt bneradt changed the title Fix CacheShm test on large-page systems cache: fix shm sizing on large-page Linux Aug 11, 2026
@jeredfloyd

Copy link
Copy Markdown
Contributor

Confirmed this resolves my test failure on ppc64le!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@masaori335 masaori335 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you!

@bneradt
bneradt merged commit f0668e1 into apache:master Aug 12, 2026
15 checks passed
@bneradt
bneradt deleted the fix-cache-shm-large-page-test branch August 12, 2026 02:11
@github-project-automation github-project-automation Bot moved this to For v10.2.0 in ATS v10.2.x Aug 12, 2026
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)
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Aug 12, 2026
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.0 Aug 12, 2026
@cmcfarlen

Copy link
Copy Markdown
Contributor

Cherry-picked to the 10.2.x branch as 21f5363 for the 10.2.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

test_cache_CacheShm fails on ppc64le architecture

5 participants