wwbmmm opened a new pull request, #3765:
URL: https://github.com/apache/brpc/pull/3765
### What problem does this PR solve?
Issue Number: resolve
Problem Summary:
UBRing ring segments were created with mode 0666 on both shared-memory
backends. Segment names are predictable, so any local user could open and map
an active connection's segments, read or rewrite the payloads, or squat the
names.
### What is changed and the side effects?
Changed:
- Add `SHM_SEGMENT_MODE` (0600) to `src/brpc/ubshm/shm/shm_def.h`;
`SHM_IPC_MODE` now aliases it, and `UbsShmLocalMalloc` passes it to
`ubsmem_shmem_allocate`. Both backends therefore share one constant.
- Add unittests in `test/brpc_ubring_unittest.cpp`: a freshly created IPC
segment is created under a permissive umask (0) and its permission bits are
asserted to be 0600; a peer of the same user still maps and releases it. UBS
allocation goes through the external ubsm SDK, which is not available in the
test environment, so only the constant it passes to `ubsmem_shmem_allocate` is
covered there.
- Document in `docs/{en,cn}/ubring.md` that IPC peers must run as the same
user.
Side effects:
- Performance effects: none.
- Breaking backward compatibility: the client and the server of the IPC
backend must now run as the same user. Segments left over from an older version
keep their previous mode until they are reclaimed.
Tests run:
- `cmake -S . -B build -DBUILD_UNIT_TESTS=ON -DWITH_UBRING=ON
-DDOWNLOAD_GTEST=OFF -DBRPC_SYSTEM_GTEST_SOURCE_DIR=/usr/src/googletest && make
-j10`
- `./test/brpc_ubring_unittest` — 33 tests passed
---
🤖 This PR was automatically created by brpc-oncall
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]