Reading — step 1 of 5
Read
IPC Namespace
The IPC namespace isolates two old but still-used interprocess communication families:
- System V IPC —
shmget,msgget,semget(key-based, identifier-returning) - POSIX message queues mounted under
/dev/mqueue
Things not in the IPC namespace: pipes, UNIX domain sockets, signals, eventfd — those are isolated by other namespaces (mount, PID).
Why it matters
A shared-memory segment in one container should be invisible to another. Without IPC namespacing, a container that knows the host's SysV key could shmat() a segment created by a sibling — a cross-container data leak.
(no IPC ns)
Container A: shmget(0xDEAD, 4096, IPC_CREAT) -> id 32768
Container B: shmget(0xDEAD, 0, 0) -> id 32768 (!!)
Container B: shmat(32768) -> reads A's memory
With CLONE_NEWIPC, the second shmget returns ENOENT or creates a brand-new segment in B's own namespace.
The simulator
We model two operations: shared memory (key -> id) and message queues (key -> id with a FIFO of messages). Each namespace has its own key tables and id allocators — but ids are globally unique (matches the kernel: SysV ids come from a single global allocator, but they're only resolvable within the namespace they were created in).
Reference: man 7 ipc_namespaces; Kerrisk, TLPI, ch. 45-48.
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…