FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Ubuntu > Ubuntu Kernel Team

 
 
LinkBack Thread Tools
 
Old 03-02-2012, 03:18 PM
"Herton R. Krzesinski"
 
Default ipc/sem.c: fix race with concurrent semtimedop() timeouts and IPC_RMID

SRU justification
=================

Impact
------
Kernel crash, due to race explained in upstream bug report:
https://bugzilla.kernel.org/show_bug.cgi?id=27142
In practice likely to happen on a highly loaded webserver

Fix
---
Upstream commit d694ad62bf539dbb20a0899ac2a954555f9e4a83

Testcase
--------
https://bugzilla.kernel.org/attachment.cgi?id=66162
I'll attach to this bug as well.
- Build with gcc -o timedrm timedrm.cpp -lpthread
- Run with "test 250", sometimes you have to run more than one time to get the
oops, but it's very easy to get the crash.

Note: only needed for natty. The problem affects 2.6.35 and later, but
we already got fixes for Maverick/Oneiric through stable, Precise has
the fix in also.

--
[]'s
Herton

--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
 
Old 03-02-2012, 03:18 PM
"Herton R. Krzesinski"
 
Default ipc/sem.c: fix race with concurrent semtimedop() timeouts and IPC_RMID

From: Manfred Spraul <manfred@colorfullife.com>

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 <yuriy@ucoz.com>
Reported-by: Harald Laabs <kernel@dasr.de>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: <stable@kernel.org> [2.6.35+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry-picked from commit d694ad62bf539dbb20a0899ac2a954555f9e4a83 upstream)
BugLink: http://bugs.launchpad.net/bugs/943815
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
---
ipc/sem.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index 0e0d49b..9769b47 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1454,15 +1454,24 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
}

sma = sem_lock(ns, semid);
+
+ /*
+ * Wait until it's guaranteed that no wakeup_sem_queue_do() is ongoing.
+ */
+ error = get_queue_result(&queue);
+
+ /*
+ * Array removed? If yes, leave without sem_unlock().
+ */
if (IS_ERR(sma)) {
error = -EIDRM;
goto out_free;
}

- error = get_queue_result(&queue);

/*
- * If queue.status != -EINTR we are woken up by another process
+ * If queue.status != -EINTR we are woken up by another process.
+ * Leave without unlink_queue(), but with sem_unlock().
*/

if (error != -EINTR) {
--
1.7.5.4


--
kernel-team mailing list
kernel-team@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/kernel-team
 

Thread Tools




All times are GMT. The time now is 05:29 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org