IPC Namespace
Author
longjin <longjin@dragonos.org>
This page describes the current support status and future plans for IPC namespaces in DragonOS. The goal is to expose semantics consistent with Linux to users while gradually improving upon DragonOS's existing framework.
Supported Features
Integration of IpcNamespace object with NsProxy:
- Added
IpcNamespaceand connected toNsProxy, allowing each task to access its associated IPC namespace viansproxy.ipc_ns. - Namespace creation/inheritance follows
clone/unsharesemantics:- Inherits the parent namespace when
CLONE_NEWIPCis not included; - Creates an independent IPC namespace when
CLONE_NEWIPCis included; - Mutually exclusive with
CLONE_SYSVSEM, with behavior consistent with Linux.
- Inherits the parent namespace when
- Added
SysV SHM (Shared Memory) isolated by namespace:
- Refactored the original global
SHM_MANAGERinto per-nsShmManager, with allshmget/shmat/shmdt/shmctltaking effect undercurrent.nsproxy.ipc_ns. shmat/shmdt: VMA recordsShmId, precisely maintainingmap_countduring unmapping; afterIPC_RMID, physical reclamation is completed whenSHM_DEST && map_count==0.- Basic semantics and error codes aligned:
IPC_CREAT|IPC_EXCL,ENOENT, rejection ofSHM_HUGETLB, etc.
- Refactored the original global
Basic test cases: (in
test_ipc_ns_shm.rs)- After
unshare(CLONE_NEWIPC), keys in parent/child namespaces are not visible; - Same keys across namespaces do not conflict;
- After
IPC_RMID, the same key can be recreated; - Outputs PASS/FAIL and summary results.
- After
Not Yet Implemented / Planned
/proc/[pid]/ns/ipcandsetns:- Temporarily postponed, with only planning for read-only placeholders and the simplest
setnspath; permission validation and switching sequencing will be added in subsequent versions.
- Temporarily postponed, with only planning for read-only placeholders and the simplest
Other SysV IPC subsystems:
msg/semframework not yet incorporated; UNDO lists forsemand coordination withunshare/setnsneed to be implemented simultaneously when introduced.
POSIX mqueue:
- Per-ns mqueuefs kernel mounting, quotas, and sysctl not yet provided.
Permissions and quotas:
ipcperms(),ns_capable(user_ns, CAP_IPC_OWNER);- ucounts/RLIMIT and per-ns sysctl such as
/proc/sys/kernel/shm*.
Compatibility and Notes
- At this stage, only SysV SHM provides namespace isolation; other IPC types still operate under global semantics.
- Code evolves in a modular manner: when adding
msg/sem/mqueuelater, stability and consistency of user-side semantics will be maintained.
References
- Code locations:
kernel/src/process/namespace/ipc_namespace.rskernel/src/process/namespace/nsproxy.rskernel/src/ipc/syscall/withinsys_shm*kernel/src/mm/ucontext/(VMA and SHM count maintenance)