SABITHSAHEB opened a new pull request, #14071:
URL: https://github.com/apache/trafficserver/pull/14071

   The experimental shared-memory cache directory 
(`proxy.config.cache.shm.enabled`) adopts existing segments by name at startup: 
`open_control_segment()` opens `<prefix>control` and `open_and_map_shm()` opens 
each `<prefix>s<N>` stripe segment read-write and maps it `MAP_SHARED` as that 
stripe's live `raw_dir`. Neither checked who owns the object or what its mode 
is, and the POSIX shm name space is shared by every local account (`/dev/shm` 
is 1777 on Linux, and `fs.protected_regular` does not help because the attach 
opens without `O_CREAT`), so another user can create `/ats-control` and the 
stripe segments with mode 0666 whenever they do not exist yet, for example 
before the feature is first enabled or after `traffic_ctl cache shm clear`. 
Every control gate (magic, schema version, `abi_hash`, `clean_shutdown`, stripe 
key hash, recorded size) is a value that writer chooses. 
`Stripe::_shm_directory_is_valid()` checks the directory once at attach, while 
the planting account can keep it
 s own writable mapping and rewrite dir links, freelist heads or entry offsets 
afterwards, which the validator's own comments name as out-of-bounds sinks (an 
out-of-stripe offset becomes a huge read length in `CacheVC::handleRead()`). 
The create path already uses `O_EXCL` with 0600 so it never adopts a planted 
object, and this applies the matching rule on attach: an existing segment must 
be owned by `geteuid()` with no group or other access, otherwise the control 
segment disables shm for the run (another account's segment is not ours to 
unlink) and a stripe segment is recreated fresh. The two new cases in 
`test_CacheShmShutdown.cc` replant the control and a stripe segment with mode 
0666 and fail on master (the control is adopted as `AttachExisting`, and the 
planted stripe bytes are attached), and all cache unit tests pass with the 
change.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to