<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/ipc/msg.c, branch v2.6.25</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.25</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.25'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2008-02-08T17:22:26Z</updated>
<entry>
<title>IPC: consolidate sem_exit_ns(), msg_exit_ns() and shm_exit_ns()</title>
<updated>2008-02-08T17:22:26Z</updated>
<author>
<name>Pierre Peiffer</name>
<email>pierre.peiffer@bull.net</email>
</author>
<published>2008-02-08T12:18:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=01b8b07a5d77d22e609267dcae74d15e3e9c5f13'/>
<id>urn:sha1:01b8b07a5d77d22e609267dcae74d15e3e9c5f13</id>
<content type='text'>
sem_exit_ns(), msg_exit_ns() and shm_exit_ns() are all called when an
ipc_namespace is released to free all ipcs of each type.  But in fact, they
do the same thing: they loop around all ipcs to free them individually by
calling a specific routine.

This patch proposes to consolidate this by introducing a common function,
free_ipcs(), that do the job.  The specific routine to call on each
individual ipcs is passed as parameter.  For this, these ipc-specific
'free' routines are reworked to take a generic 'struct ipc_perm' as
parameter.

Signed-off-by: Pierre Peiffer &lt;pierre.peiffer@bull.net&gt;
Cc: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Cc: Pavel Emelyanov &lt;xemul@openvz.org&gt;
Cc: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IPC: make struct ipc_ids static in ipc_namespace</title>
<updated>2008-02-08T17:22:26Z</updated>
<author>
<name>Pierre Peiffer</name>
<email>pierre.peiffer@bull.net</email>
</author>
<published>2008-02-08T12:18:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ed2ddbf88c0ddeeae4c78bb306a116dfd867c55c'/>
<id>urn:sha1:ed2ddbf88c0ddeeae4c78bb306a116dfd867c55c</id>
<content type='text'>
Each ipc_namespace contains a table of 3 pointers to struct ipc_ids (3 for
msg, sem and shm, structure used to store all ipcs) These 'struct ipc_ids'
are dynamically allocated for each icp_namespace as the ipc_namespace
itself (for the init namespace, they are initialized with pointers to
static variables instead)

It is so for historical reason: in fact, before the use of idr to store the
ipcs, the ipcs were stored in tables of variable length, depending of the
maximum number of ipc allowed.  Now, these 'struct ipc_ids' have a fixed
size.  As they are allocated in any cases for each new ipc_namespace, there
is no gain of memory in having them allocated separately of the struct
ipc_namespace.

This patch proposes to make this table static in the struct ipc_namespace.
Thus, we can allocate all in once and get rid of all the code needed to
allocate and free these ipc_ids separately.

Signed-off-by: Pierre Peiffer &lt;pierre.peiffer@bull.net&gt;
Acked-by: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Cc: Pavel Emelyanov &lt;xemul@openvz.org&gt;
Cc: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>namespaces: move the IPC namespace under IPC_NS option</title>
<updated>2008-02-08T17:22:23Z</updated>
<author>
<name>Pavel Emelyanov</name>
<email>xemul@openvz.org</email>
</author>
<published>2008-02-08T12:18:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ae5e1b22f17983da929a0d0178896269e19da186'/>
<id>urn:sha1:ae5e1b22f17983da929a0d0178896269e19da186</id>
<content type='text'>
Currently the IPC namespace management code is spread over the ipc/*.c files.
I moved this code into ipc/namespace.c file which is compiled out when needed.

The linux/ipc_namespace.h file is used to store the prototypes of the
functions in namespace.c and the stubs for NAMESPACES=n case.  This is done
so, because the stub for copy_ipc_namespace requires the knowledge of the
CLONE_NEWIPC flag, which is in sched.h.  But the linux/ipc.h file itself in
included into many many .c files via the sys.h-&gt;sem.h sequence so adding the
sched.h into it will make all these .c depend on sched.h which is not that
good.  On the other hand the knowledge about the namespaces stuff is required
in 4 .c files only.

Besides, this patch compiles out some auxiliary functions from ipc/sem.c,
msg.c and shm.c files.  It turned out that moving these functions into
namespaces.c is not that easy because they use many other calls and macros
from the original file.  Moving them would make this patch complicated.  On
the other hand all these functions can be consolidated, so I will send a
separate patch doing this a bit later.

Signed-off-by: Pavel Emelyanov &lt;xemul@openvz.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Cc: Cedric Le Goater &lt;clg@fr.ibm.com&gt;
Cc: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Cc: Herbert Poetzl &lt;herbert@13thfloor.at&gt;
Cc: Kirill Korotaev &lt;dev@sw.ru&gt;
Cc: Sukadev Bhattiprolu &lt;sukadev@us.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IPC: fix error check in all new xxx_lock() and xxx_exit_ns() functions</title>
<updated>2008-02-06T18:41:01Z</updated>
<author>
<name>Pierre Peiffer</name>
<email>pierre.peiffer@bull.net</email>
</author>
<published>2008-02-06T09:36:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b1ed88b47f5e18c6efb8041275c16eeead5377df'/>
<id>urn:sha1:b1ed88b47f5e18c6efb8041275c16eeead5377df</id>
<content type='text'>
In the new implementation of the [sem|shm|msg]_lock[_check]() routines, we
use the return value of ipc_lock() in container_of() without any check.
But ipc_lock may return a errcode.  The use of this errcode in
container_of() may alter this errcode, and we don't want this.

And in xxx_exit_ns, the pointer return by idr_find is of type 'struct
kern_ipc_per'...

Today, the code will work as is because the member used in these
container_of() is the first member of its container (offset == 0), the
errcode isn't changed then.  But in the general case, we can't count on
this assumption and this may lead later to a real bug if we don't correct
this.

Again, the proposed solution is simple and correct.  But, as pointed by
Nadia, with this solution, the same check will be done several times (in
all sub-callers...), what is not very funny/optimal...

Signed-off-by: Pierre Peiffer &lt;pierre.peiffer@bull.net&gt;
Cc: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>IPC: fix error case when idr-cache is empty in ipcget()</title>
<updated>2007-10-19T18:53:49Z</updated>
<author>
<name>Pierre Peiffer</name>
<email>Pierre.Peiffer@bull.net</email>
</author>
<published>2007-10-19T06:40:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=283bb7fada7e33a759d8fc9bd7a44532e4ad420e'/>
<id>urn:sha1:283bb7fada7e33a759d8fc9bd7a44532e4ad420e</id>
<content type='text'>
With the use of idr to store the ipc, the case where the idr cache is
empty, when idr_get_new is called (this may happen even if we call
idr_pre_get() before), is not well handled: it lets
semget()/shmget()/msgget() return ENOSPC when this cache is empty, what 1.
does not reflect the facts and 2.  does not conform to the man(s).

This patch fixes this by retrying the whole process of allocation in this case.

Signed-off-by: Pierre Peiffer &lt;pierre.peiffer@bull.net&gt;
Cc: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>virtualization of sysv msg queues is incomplete</title>
<updated>2007-10-19T18:53:48Z</updated>
<author>
<name>Kirill Korotaev</name>
<email>dev@openvz.org</email>
</author>
<published>2007-10-19T06:40:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3ac88a41ff747b8c2f290f86b5243b2f8fce2cc0'/>
<id>urn:sha1:3ac88a41ff747b8c2f290f86b5243b2f8fce2cc0</id>
<content type='text'>
Virtualization of sysv msg queues is incomplete: msg_hdrs and msg_bytes
variables visible from userspace are global.  Let's make them
per-namespace.

Signed-off-by: Alexey Kuznetsov &lt;alexey@openvz.org&gt;
Signed-off-by: Kirill Korotaev &lt;dev@openvz.org&gt;
Cc: Pierre Peiffer &lt;pierre.peiffer@bull.net&gt;
Cc: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Cc: Serge Hallyn &lt;serue@us.ibm.com&gt;
Acked-by: "Eric W. Biederman" &lt;ebiederm@xmission.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>ipc: remove unneeded parameters</title>
<updated>2007-10-19T18:53:48Z</updated>
<author>
<name>Nadia Derbey</name>
<email>Nadia.Derbey@bull.net</email>
</author>
<published>2007-10-19T06:40:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1b531f213661657d6e1c55cf5c97f649d630c227'/>
<id>urn:sha1:1b531f213661657d6e1c55cf5c97f649d630c227</id>
<content type='text'>
Remvoe the unneeded parameters from ipc_checkid() and ipc_buildid()
interfaces.

Signed-off-by: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>fix idr_find() locking</title>
<updated>2007-10-19T18:53:48Z</updated>
<author>
<name>Nadia Derbey</name>
<email>Nadia.Derbey@bull.net</email>
</author>
<published>2007-10-19T06:40:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3e148c79938aa39035669c1cfa3ff60722134535'/>
<id>urn:sha1:3e148c79938aa39035669c1cfa3ff60722134535</id>
<content type='text'>
This is a patch that fixes the way idr_find() used to be called in ipc_lock():
in all the paths that don't imply an update of the ipcs idr, it was called
without the idr tree being locked.

The changes are:
  . in ipc_ids, the mutex has been changed into a reader/writer semaphore.
  . ipc_lock() now takes the mutex as a reader during the idr_find().
  . a new routine ipc_lock_down() has been defined: it doesn't take the
    mutex, assuming that it is being held by the caller. This is the routine
    that is now called in all the update paths.

Signed-off-by: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Acked-by: Jarek Poplawski &lt;jarkao2@o2.pl&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>ipc: fix wrong comments</title>
<updated>2007-10-19T18:53:47Z</updated>
<author>
<name>Nadia Derbey</name>
<email>Nadia.Derbey@bull.net</email>
</author>
<published>2007-10-19T06:40:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f4566f04854d78acfc74b9acb029744acde9d033'/>
<id>urn:sha1:f4566f04854d78acfc74b9acb029744acde9d033</id>
<content type='text'>
This patch fixes the wrong / obsolete comments in the ipc code.  Also adds
a missing lock around ipc_get_maxid() in shm_get_stat().

Signed-off-by: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Storing ipcs into IDRs</title>
<updated>2007-10-19T18:53:46Z</updated>
<author>
<name>Nadia Derbey</name>
<email>Nadia.Derbey@bull.net</email>
</author>
<published>2007-10-19T06:40:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=03f02c7657f7948ab980280c54c9366f962b1474'/>
<id>urn:sha1:03f02c7657f7948ab980280c54c9366f962b1474</id>
<content type='text'>
This patch converts casts of struct kern_ipc_perm to
   . struct msg_queue
   . struct sem_array
   . struct shmid_kernel
into the equivalent container_of() macro. It improves code maintenance
because the code need not change if kern_ipc_perm is no longer at the
beginning of the containing struct.

Signed-off-by: Nadia Derbey &lt;Nadia.Derbey@bull.net&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
