<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/ipc, branch linux-2.6.35.y</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=linux-2.6.35.y</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=linux-2.6.35.y'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2011-08-01T20:55:00+00:00</updated>
<entry>
<title>ipc/sem.c: fix race with concurrent semtimedop() timeouts</title>
<updated>2011-08-01T20:55:00+00:00</updated>
<author>
<name>Manfred Spraul</name>
<email>manfred@colorfullife.com</email>
</author>
<published>2011-07-26T00:11:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=ef652fd1d50af7236399055d621051aafffd1789'/>
<id>urn:sha1:ef652fd1d50af7236399055d621051aafffd1789</id>
<content type='text'>
[ upstream commit d694ad62bf539dbb20a0899ac2a954555f9e4a83 ]
 and IPC_RMID

If a semaphore array is removed and in parallel a sleeping task is woken
up (signal or timeout, does not matter), then the woken up task does not
wait until wake_up_sem_queue_do() is completed.  This will cause crashes,
because wake_up_sem_queue_do() will read from a stale pointer.

The fix is simple: Regardless of anything, always call get_queue_result().
This function waits until wake_up_sem_queue_do() has finished it's task.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=27142

Reported-by: Yuriy Yevtukhov &lt;yuriy@ucoz.com&gt;
Reported-by: Harald Laabs &lt;kernel@dasr.de&gt;
Signed-off-by: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Acked-by: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: &lt;stable@kernel.org&gt;		[2.6.35+]
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;

</content>
</entry>
<entry>
<title>ipc: shm: fix information leak to userland</title>
<updated>2010-12-14T22:40:07+00:00</updated>
<author>
<name>Vasiliy Kulikov</name>
<email>segooon@gmail.com</email>
</author>
<published>2010-10-30T14:22:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=e4b338bfb1e607111ab7b56cb6d497b08567c7e3'/>
<id>urn:sha1:e4b338bfb1e607111ab7b56cb6d497b08567c7e3</id>
<content type='text'>
commit 3af54c9bd9e6f14f896aac1bb0e8405ae0bc7a44 upstream.

The shmid_ds structure is copied to userland with shm_unused{,2,3}
fields unitialized.  It leads to leaking of contents of kernel stack
memory.

Signed-off-by: Vasiliy Kulikov &lt;segooon@gmail.com&gt;
Acked-by: Al Viro &lt;viro@ZenIV.linux.org.uk&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;

</content>
</entry>
<entry>
<title>ipc: initialize structure memory to zero for compat functions</title>
<updated>2010-12-14T22:40:07+00:00</updated>
<author>
<name>Dan Rosenberg</name>
<email>drosenberg@vsecurity.com</email>
</author>
<published>2010-10-27T22:34:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=154893c8527b3eba012328c43736dfb918627edb'/>
<id>urn:sha1:154893c8527b3eba012328c43736dfb918627edb</id>
<content type='text'>
commit 03145beb455cf5c20a761e8451e30b8a74ba58d9 upstream.

This takes care of leaking uninitialized kernel stack memory to
userspace from non-zeroed fields in structs in compat ipc functions.

Signed-off-by: Dan Rosenberg &lt;drosenberg@vsecurity.com&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@suse.de&gt;
Signed-off-by: Andi Kleen &lt;ak@linux.intel.com&gt;

</content>
</entry>
<entry>
<title>ipc/sem.c: bugfix for semop() not reporting successful operation</title>
<updated>2010-07-20T23:25:40+00:00</updated>
<author>
<name>Manfred Spraul</name>
<email>manfred@colorfullife.com</email>
</author>
<published>2010-07-20T20:24:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c61284e99191b2284fb74dae6961d4d09e4e59e8'/>
<id>urn:sha1:c61284e99191b2284fb74dae6961d4d09e4e59e8</id>
<content type='text'>
The last change to improve the scalability moved the actual wake-up out of
the section that is protected by spin_lock(sma-&gt;sem_perm.lock).

This means that IN_WAKEUP can be in queue.status even when the spinlock is
acquired by the current task.  Thus the same loop that is performed when
queue.status is read without the spinlock acquired must be performed when
the spinlock is acquired.

Thanks to kamezawa.hiroyu@jp.fujitsu.com for noticing lack of the memory
barrier.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=16255

[akpm@linux-foundation.org: clean up kerneldoc, checkpatch warning and whitespace]
Signed-off-by: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Reported-by: Luca Tettamanti &lt;kronos.it@gmail.com&gt;
Tested-by: Luca Tettamanti &lt;kronos.it@gmail.com&gt;
Reported-by: Christoph Lameter &lt;cl@linux-foundation.org&gt;
Cc: Maciej Rutecki &lt;maciej.rutecki@gmail.com&gt;
Cc: KAMEZAWA Hiroyuki &lt;kamezawa.hiroyu@jp.fujitsu.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>mqueue doesn't need make_bad_inode()</title>
<updated>2010-06-04T21:16:27+00:00</updated>
<author>
<name>Al Viro</name>
<email>viro@zeniv.linux.org.uk</email>
</author>
<published>2010-05-28T23:06:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0abbb609ac511fc226b8b1082613193c8ecf8324'/>
<id>urn:sha1:0abbb609ac511fc226b8b1082613193c8ecf8324</id>
<content type='text'>
It never hashes them anyway and does final iput() immediately
afterwards.  With -&gt;drop_inode() being generic_delete_inode()...

Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>drop unused dentry argument to -&gt;fsync</title>
<updated>2010-05-28T02:05:02+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2010-05-26T15:53:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=7ea8085910ef3dd4f3cad6845aaa2b580d39b115'/>
<id>urn:sha1:7ea8085910ef3dd4f3cad6845aaa2b580d39b115</id>
<content type='text'>
Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>ipc/sem.c: use ERR_CAST</title>
<updated>2010-05-27T16:12:49+00:00</updated>
<author>
<name>Julia Lawall</name>
<email>julia@diku.dk</email>
</author>
<published>2010-05-26T21:43:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4de85cd6d6018825e19f76f1208775f23ecc393f'/>
<id>urn:sha1:4de85cd6d6018825e19f76f1208775f23ecc393f</id>
<content type='text'>
Use ERR_CAST(x) rather than ERR_PTR(PTR_ERR(x)).  The former makes more
clear what is the purpose of the operation, which otherwise looks like a
no-op.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// &lt;smpl&gt;
@@
type T;
T x;
identifier f;
@@

T f (...) { &lt;+...
- ERR_PTR(PTR_ERR(x))
+ x
 ...+&gt; }

@@
expression x;
@@

- ERR_PTR(PTR_ERR(x))
+ ERR_CAST(x)
// &lt;/smpl&gt;

Signed-off-by: Julia Lawall &lt;julia@diku.dk&gt;
Cc: Manfred Spraul &lt;manfred@colorfullife.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/sem.c: update description of the implementation</title>
<updated>2010-05-27T16:12:49+00:00</updated>
<author>
<name>Manfred Spraul</name>
<email>manfred@colorfullife.com</email>
</author>
<published>2010-05-26T21:43:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c5cf6359ad1d322c16e159011247341849cc0d3a'/>
<id>urn:sha1:c5cf6359ad1d322c16e159011247341849cc0d3a</id>
<content type='text'>
ipc/sem.c begins with a 15 year old description about bugs in the initial
implementation in Linux-1.0.  The patch replaces that with a top level
description of the current code.

A TODO could be derived from this text:

The opengroup man page for semop() does not mandate FIFO.  Thus there is
no need for a semaphore array list of pending operations.

If

- this list is removed
- the per-semaphore array spinlock is removed (possible if there is no
  list to protect)
- sem_otime is moved into the semaphores and calculated on demand during
  semctl()

then the array would be read-mostly - which would significantly improve
scaling for applications that use semaphore arrays with lots of entries.

The price would be expensive semctl() calls:

	for(i=0;i&lt;sma-&gt;sem_nsems;i++) spin_lock(sma-&gt;sem_lock);
	&lt;do stuff&gt;
	for(i=0;i&lt;sma-&gt;sem_nsems;i++) spin_unlock(sma-&gt;sem_lock);

I'm not sure if the complexity is worth the effort, thus here is the
documentation of the current behavior first.

Signed-off-by: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Chris Mason &lt;chris.mason@oracle.com&gt;
Cc: Zach Brown &lt;zach.brown@oracle.com&gt;
Cc: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Cc: Nick Piggin &lt;npiggin@suse.de&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/sem.c: move wake_up_process out of the spinlock section</title>
<updated>2010-05-27T16:12:49+00:00</updated>
<author>
<name>Manfred Spraul</name>
<email>manfred@colorfullife.com</email>
</author>
<published>2010-05-26T21:43:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=0a2b9d4c79671b05956806ede5d054e03ae56280'/>
<id>urn:sha1:0a2b9d4c79671b05956806ede5d054e03ae56280</id>
<content type='text'>
The wake-up part of semtimedop() consists out of two steps:

- the right tasks must be identified.
- they must be woken up.

Right now, both steps run while the array spinlock is held.  This patch
reorders the code and moves the actual wake_up_process() behind the point
where the spinlock is dropped.

The code also moves setting sem-&gt;sem_otime to one place: It does not make
sense to set the last modify time multiple times.

[akpm@linux-foundation.org: repair kerneldoc]
[akpm@linux-foundation.org: fix uninitialised retval]
Signed-off-by: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Chris Mason &lt;chris.mason@oracle.com&gt;
Cc: Zach Brown &lt;zach.brown@oracle.com&gt;
Cc: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Cc: Nick Piggin &lt;npiggin@suse.de&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/sem.c: optimize update_queue() for bulk wakeup calls</title>
<updated>2010-05-27T16:12:49+00:00</updated>
<author>
<name>Manfred Spraul</name>
<email>manfred@colorfullife.com</email>
</author>
<published>2010-05-26T21:43:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fd5db42254518fbf241dc454e918598fbe494fa2'/>
<id>urn:sha1:fd5db42254518fbf241dc454e918598fbe494fa2</id>
<content type='text'>
The following series of patches tries to fix the spinlock contention
reported by Chris Mason - his benchmark exposes problems of the current
code:

- In the worst case, the algorithm used by update_queue() is O(N^2).
  Bulk wake-up calls can enter this worst case.  The patch series fix
  that.

  Note that the benchmark app doesn't expose the problem, it just should
  be fixed: Real world apps might do the wake-ups in another order than
  perfect FIFO.

- The part of the code that runs within the semaphore array spinlock is
  significantly larger than necessary.

  The patch series fixes that.  This change is responsible for the main
  improvement.

- The cacheline with the spinlock is also used for a variable that is
  read in the hot path (sem_base) and for a variable that is unnecessarily
  written to multiple times (sem_otime).  The last step of the series
  cacheline-aligns the spinlock.

This patch:

The SysV semaphore code allows to perform multiple operations on all
semaphores in the array as atomic operations.  After a modification,
update_queue() checks which of the waiting tasks can complete.

The algorithm that is used to identify the tasks is O(N^2) in the worst
case.  For some cases, it is simple to avoid the O(N^2).

The patch adds a detection logic for some cases, especially for the case
of an array where all sleeping tasks are single sembuf operations and a
multi-sembuf operation is used to wake up multiple tasks.

A big database application uses that approach.

The patch fixes wakeup due to semctl(,,SETALL,) - the initial version of
the patch breaks that.

[akpm@linux-foundation.org: make do_smart_update() static]
Signed-off-by: Manfred Spraul &lt;manfred@colorfullife.com&gt;
Cc: Chris Mason &lt;chris.mason@oracle.com&gt;
Cc: Zach Brown &lt;zach.brown@oracle.com&gt;
Cc: Jens Axboe &lt;jens.axboe@oracle.com&gt;
Cc: Nick Piggin &lt;npiggin@suse.de&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>
