<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/ipc/shm.c, branch linux-2.6.22.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-2.6.22.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-2.6.22.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2007-08-09T21:27:36+00:00</updated>
<entry>
<title>Fix user struct leakage with locked IPC shem segment</title>
<updated>2007-08-09T21:27:36+00:00</updated>
<author>
<name>Pavel Emelianov</name>
<email>xemul@openvz.org</email>
</author>
<published>2007-07-31T07:38:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=68a0460bbcc7571753b57b83f21e8c1c5029a46a'/>
<id>urn:sha1:68a0460bbcc7571753b57b83f21e8c1c5029a46a</id>
<content type='text'>
When user locks an ipc shmem segmant with SHM_LOCK ctl and the segment is
already locked the shmem_lock() function returns 0.  After this the
subsequent code leaks the existing user struct:

== ipc/shm.c: sys_shmctl() ==
     ...
     err = shmem_lock(shp-&gt;shm_file, 1, user);
     if (!err) {
          shp-&gt;shm_perm.mode |= SHM_LOCKED;
          shp-&gt;mlock_user = user;
     }
     ...
==

Other results of this are:
1. the new shp-&gt;mlock_user is not get-ed and will point to freed
   memory when the task dies.
2. the RLIMIT_MEMLOCK is screwed on both user structs.

The exploit looks like this:

==
    id = shmget(...);
    setresuid(uid, 0, 0);
    shmctl(id, SHM_LOCK, NULL);
    setresuid(uid + 1, 0, 0);
    shmctl(id, SHM_LOCK, NULL);
==

My solution is to return 0 to the userspace and do not change the
segment's user.

Signed-off-by: Pavel Emelianov &lt;xemul@openvz.org&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;

</content>
</entry>
<entry>
<title>shm: fix the filename of hugetlb sysv shared memory</title>
<updated>2007-06-16T20:16:16+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2007-06-16T17:16:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9d66586f7723b73c5925c7c7819c260484627851'/>
<id>urn:sha1:9d66586f7723b73c5925c7c7819c260484627851</id>
<content type='text'>
Some user space tools need to identify SYSV shared memory when examining
/proc/&lt;pid&gt;/maps.  To do so they look for a block device with major zero, a
dentry named SYSV&lt;sysv key&gt;, and having the minor of the internal sysv
shared memory kernel mount.

To help these tools and to make it easier for people just browsing
/proc/&lt;pid&gt;/maps this patch modifies hugetlb sysv shared memory to use the
SYSV&lt;key&gt; dentry naming convention.

User space tools will still have to be aware that hugetlb sysv shared
memory lives on a different internal kernel mount and so has a different
block device minor number from the rest of sysv shared memory.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: "Serge E. Hallyn" &lt;serge@hallyn.com&gt;
Cc: Albert Cahalan &lt;acahalan@gmail.com&gt;
Cc: Badari Pulavarty &lt;pbadari@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>hugetlb: fix get_policy for stacked shared memory files</title>
<updated>2007-06-16T20:16:16+00:00</updated>
<author>
<name>Adam Litke</name>
<email>agl@us.ibm.com</email>
</author>
<published>2007-06-16T17:16:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=22741925d268e8479ef66312749bd8d96ed35365'/>
<id>urn:sha1:22741925d268e8479ef66312749bd8d96ed35365</id>
<content type='text'>
Here's another breakage as a result of shared memory stacked files :(

The NUMA policy for a VMA is determined by checking the following (in the
order given):

1) vma-&gt;vm_ops-&gt;get_policy() (if defined)
2) vma-&gt;vm_policy (if defined)
3) task-&gt;mempolicy (if defined)
4) Fall back to default_policy

By switching to stacked files for shared memory, get_policy() is now always
set to shm_get_policy which is a wrapper function.  This causes us to stop
at step 1, which yields NULL for hugetlb instead of task-&gt;mempolicy which
was the previous (and correct) result.

This patch modifies the shm_get_policy() wrapper to maintain steps 1-3 for
the wrapped vm_ops.

(akpm: the refcounting of mempolicies is busted and this patch does nothing to
improve it)

Signed-off-by: Adam Litke &lt;agl@us.ibm.com&gt;
Acked-by: William Irwin &lt;bill.irwin@oracle.com&gt;
Cc: dean gaudet &lt;dean@arctic.org&gt;
Cc: Christoph Lameter &lt;clameter@sgi.com&gt;
Cc: Andi Kleen &lt;ak@suse.de&gt;
Cc: &lt;stable@kernel.org&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>Restore shmid as inode# to fix /proc/pid/maps ABI breakage</title>
<updated>2007-06-16T20:16:15+00:00</updated>
<author>
<name>Badari Pulavarty</name>
<email>pbadari@us.ibm.com</email>
</author>
<published>2007-06-16T17:15:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=30475cc12a50816f290828fb7e3cd7036cd622df'/>
<id>urn:sha1:30475cc12a50816f290828fb7e3cd7036cd622df</id>
<content type='text'>
shmid used to be stored as inode# for shared memory segments. Some of
the proc-ps tools use this from /proc/pid/maps.  Recent cleanups
to newseg() changed it.  This patch sets inode number back to shared
memory id to fix breakage.

Signed-off-by: Badari Pulavarty &lt;pbadari@us.ibm.com&gt;
Cc: "Albert Cahalan" &lt;acahalan@gmail.com&gt;
Cc: "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>[PATCH] Fix get_unmapped_area and fsync for hugetlb shm segments</title>
<updated>2007-03-02T01:18:39+00:00</updated>
<author>
<name>Adam Litke</name>
<email>agl@us.ibm.com</email>
</author>
<published>2007-03-01T23:46:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=516dffdcd8827a40532798602830dfcfc672294c'/>
<id>urn:sha1:516dffdcd8827a40532798602830dfcfc672294c</id>
<content type='text'>
This patch provides the following hugetlb-related fixes to the recent stacked
shm files changes:
 - Update is_file_hugepages() so it will reconize hugetlb shm segments.
 - get_unmapped_area must be called with the nested file struct to handle
   the sfd-&gt;file-&gt;f_ops-&gt;get_unmapped_area == NULL case.
 - The fsync f_op must be wrapped since it is specified in the hugetlbfs
   f_ops.

This is based on proposed fixes from Eric Biederman that were debugged and
tested by me.  Without it, attempting to use hugetlb shared memory segments
on powerpc (and likely ia64) will kill your box.

Signed-off-by: Adam Litke &lt;agl@us.ibm.com&gt;
Cc: Eric Biederman &lt;ebiederm@xmission.com&gt;
Cc: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Acked-by: William Irwin &lt;bill.irwin@oracle.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>[PATCH] make ipc/shm.c:shm_nopage() static</title>
<updated>2007-03-01T22:53:35+00:00</updated>
<author>
<name>Adrian Bunk</name>
<email>bunk@stusta.de</email>
</author>
<published>2007-03-01T04:11:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=de01bad2f5dec2977143aa242e7eba71d11a4363'/>
<id>urn:sha1:de01bad2f5dec2977143aa242e7eba71d11a4363</id>
<content type='text'>
shm_nopage() can become static.

Signed-off-by: Adrian Bunk &lt;bunk@stusta.de&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>[PATCH] shm: make sysv ipc shared memory use stacked files</title>
<updated>2007-02-21T01:10:13+00:00</updated>
<author>
<name>Eric W. Biederman</name>
<email>ebiederm@xmission.com</email>
</author>
<published>2007-02-20T21:57:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=bc56bba8f31bd99f350a5ebfd43d50f411b620c7'/>
<id>urn:sha1:bc56bba8f31bd99f350a5ebfd43d50f411b620c7</id>
<content type='text'>
The current ipc shared memory code runs into several problems because it
does not quite use files like the rest of the kernel.  With the option of
backing ipc shared memory with either hugetlbfs or ordinary shared memory
the problems got worse.  With the added support for ipc namespaces things
behaved so unexpected that we now have several bad namespace reference
counting bugs when using what appears at first glance to be a reasonable
idiom.

So to attack these problems and hopefully make the code more maintainable
this patch simply uses the files provided by other parts of the kernel and
builds it's own files out of them.  The shm files are allocated in do_shmat
and freed when their reference count drops to zero with their last unmap.
The file and vm operations that we don't want to implement or we don't
implement completely we just delegate to the operations of our backing
file.

This means that we now get an accurate shm_nattch count for we have a
hugetlbfs inode for backing store, and the shm accounting of last attach
and last detach time work as well.

This means that getting a reference to the ipc namespace when we create the
file and dropping the referenece in the release method is now safe and
correct.

This means we no longer need a special case for clearing VM_MAYWRITE
as our file descriptor now only has write permissions when we have
requested write access when calling shmat.  Although VM_SHARED is now
cleared as well which I believe is harmless and is mostly likely a
minor bug fix.

By using the same set of operations for both the hugetlb case and regular
shared memory case shmdt is not simplified and made slightly more correct
as now the test "vma-&gt;vm_ops == &amp;shm_vm_ops" is 100% accurate in spotting
all shared memory regions generated from sysvipc shared memory.

Signed-off-by: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Michal Piotrowski &lt;michal.k.k.piotrowski@gmail.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>[PATCH] mark struct file_operations const 7</title>
<updated>2007-02-12T17:48:46+00:00</updated>
<author>
<name>Arjan van de Ven</name>
<email>arjan@linux.intel.com</email>
</author>
<published>2007-02-12T08:55:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9a32144e9d7b4e21341174b1a83b82a82353be86'/>
<id>urn:sha1:9a32144e9d7b4e21341174b1a83b82a82353be86</id>
<content type='text'>
Many struct file_operations in the kernel can be "const".  Marking them const
moves these to the .rodata section, which avoids false sharing with potential
dirty data.  In addition it'll catch accidental writes at compile time to
these shared resources.

Signed-off-by: Arjan van de Ven &lt;arjan@linux.intel.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>[PATCH] correct sys_shmget allocation check</title>
<updated>2007-01-23T19:18:50+00:00</updated>
<author>
<name>Guy Streeter</name>
<email>guy.streeter@gmail.com</email>
</author>
<published>2007-01-23T18:20:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f66d45e99eb7ca91822c3e3f6d7a98843c9626cb'/>
<id>urn:sha1:f66d45e99eb7ca91822c3e3f6d7a98843c9626cb</id>
<content type='text'>
As written, sys_shmget will return ENOSPC when one page is still
available for allocation. This patch corrects the test.

Signed-off-by: Guy Streeter &lt;guy.streeter+lkml@gmail.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
--
</content>
</entry>
<entry>
<title>[PATCH] struct path: convert ipc</title>
<updated>2006-12-08T16:28:46+00:00</updated>
<author>
<name>Josef Sipek</name>
<email>jsipek@fsl.cs.sunysb.edu</email>
</author>
<published>2006-12-08T10:37:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6d63079adde80bb549528371e6407f88e9d27bc3'/>
<id>urn:sha1:6d63079adde80bb549528371e6407f88e9d27bc3</id>
<content type='text'>
Signed-off-by: Josef Sipek &lt;jsipek@fsl.cs.sunysb.edu&gt;
Signed-off-by: Andrew Morton &lt;akpm@osdl.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@osdl.org&gt;
</content>
</entry>
</feed>
