diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-03-23 00:29:57 -0500 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2018-10-21 08:45:03 +0100 |
commit | ecc23ca1da7596dcf39d2ef98fe33e4e05532a8a (patch) | |
tree | 7eb14d834daad8480204d837863f40cd2a839d44 /include/linux | |
parent | f042dd1bdaea0960ac374510b75650ab6c9e765d (diff) | |
download | linux-stable-ecc23ca1da7596dcf39d2ef98fe33e4e05532a8a.tar.gz linux-stable-ecc23ca1da7596dcf39d2ef98fe33e4e05532a8a.tar.bz2 linux-stable-ecc23ca1da7596dcf39d2ef98fe33e4e05532a8a.zip |
ipc/shm: Fix shmctl(..., IPC_STAT, ...) between pid namespaces.
commit 98f929b1bd4d0b7c7a77d0d9776d1b924db2e454 upstream.
Today shm_cpid and shm_lpid are remembered in the pid namespace of the
creator and the processes that last touched a sysvipc shared memory
segment. If you have processes in multiple pid namespaces that
is just wrong, and I don't know how this has been over-looked for
so long.
As only creation and shared memory attach and shared memory detach
update the pids I do not expect there to be a repeat of the issues
when struct pid was attached to each af_unix skb, which in some
notable cases cut the performance in half. The problem was threads of
the same process updating same struct pid from different cpus causing
the cache line to be highly contended and bounce between cpus.
As creation, attach, and detach are expected to be rare operations for
sysvipc shared memory segments I do not expect that kind of cache line
ping pong to cause probems. In addition because the pid is at a fixed
location in the structure instead of being dynamic on a skb, the
reference count of the pid does not need to be updated on each
operation if the pid is the same. This ability to simply skip the pid
reference count changes if the pid is unchanging further reduces the
likelihood of the a cache line holding a pid reference count
ping-ponging between cpus.
Fixes: b488893a390e ("pid namespaces: changes to show virtual ids to user")
Reviewed-by: Nagarathnam Muthusamy <nagarathnam.muthusamy@oracle.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
[bwh: Backported to 3.16: adjust filename, context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/shm.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/linux/shm.h b/include/linux/shm.h index 57d77709fbe2..559033e5b9f5 100644 --- a/include/linux/shm.h +++ b/include/linux/shm.h @@ -14,8 +14,8 @@ struct shmid_kernel /* private to the kernel */ time_t shm_atim; time_t shm_dtim; time_t shm_ctim; - pid_t shm_cprid; - pid_t shm_lprid; + struct pid *shm_cprid; + struct pid *shm_lprid; struct user_struct *mlock_user; /* The task created the shm object. NULL if the task is dead. */ |