diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2018-03-23 00:42:21 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2018-03-27 15:53:41 -0500 |
commit | 39a4940eaa185910bb802ca9829c12268fd2c855 (patch) | |
tree | fdc9b438417ca1b272303d3a724212be26979d27 /net/rose/rose_loopback.c | |
parent | 98f929b1bd4d0b7c7a77d0d9776d1b924db2e454 (diff) | |
download | linux-39a4940eaa185910bb802ca9829c12268fd2c855.tar.gz linux-39a4940eaa185910bb802ca9829c12268fd2c855.tar.bz2 linux-39a4940eaa185910bb802ca9829c12268fd2c855.zip |
ipc/msg: Fix msgctl(..., IPC_STAT, ...) between pid namespaces
Today msg_lspid and msg_lrpid are remembered in the pid namespace of
the creator and the processes that last send or received a sysvipc
message. If you have processes in multiple pid namespaces that is
just wrong. The process ids reported will not make the least bit of
sense.
This fix is slightly more susceptible to a performance problem than
the related fix for System V shared memory. By definition the pids
are updated by msgsnd and msgrcv, the fast path of System V message
queues. The only concern over the previous implementation is the
incrementing and decrementing of the pid reference count. As that is
the only difference and multiple updates by of the task_tgid by
threads in the same process have been shown in af_unix sockets to
create a cache line ping-pong between cpus of the same processor.
In this case I don't expect cache lines holding pid reference counts
to ping pong between cpus. As senders and receivers update different
pids there is a natural separation there. Further if multiple threads
of the same process either send or receive messages the pid will be
updated to the same value and ipc_update_pid will avoid the reference
count update.
Which means in the common case I expect msg_lspid and msg_lrpid to
remain constant, and reference counts not to be updated when messages
are sent.
In rare cases it may be possible to trigger the issue which was
observed for af_unix sockets, but it will require multiple processes
with multiple threads to be either sending or receiving messages. It
just does not feel likely that anyone would do that in practice.
This change updates msgctl(..., IPC_STAT, ...) to return msg_lspid and
msg_lrpid in the pid namespace of the process calling stat.
This change also updates cat /proc/sysvipc/msg to return print msg_lspid
and msg_lrpid in the pid namespace of the process that opened the proc
file.
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>
Diffstat (limited to 'net/rose/rose_loopback.c')
0 files changed, 0 insertions, 0 deletions