]> git.neil.brown.name Git - history.git/commit
[PATCH] sysv semundo fixes
authorAndrew Morton <akpm@digeo.com>
Fri, 20 Jun 2003 15:13:53 +0000 (08:13 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Fri, 20 Jun 2003 15:13:53 +0000 (08:13 -0700)
commit1327ca85e19e5ea19c9fcab0b54f093ddaaca31a
treeeb468430b12517233fb32fac4e4ef9032f810a22
parent0d5ff9d0ca5801ccc5dd8f1f6023629bbc6090da
[PATCH] sysv semundo fixes

From: Manfred Spraul <manfred@colorfullife.com>

The CLONE_SYSVSEM implementation is racy: it does an (atomic_read(->refcnt)
==1) instead of atomic_dec_and_test calls in the exit handling.  The patch
fixes that.

Additionally, the patch contains the following changes:

- lock_undo() locks the list of undo structures.  The lock is held
  throughout the semop() syscall, but that's unnecessary - we can drop it
  immediately after the lookup.

- undo structures are only allocated when necessary.  The need for undo
  structures is only noticed in the middle of the semop operation, while
  holding the semaphore array spinlock.  The result is a convoluted
  unlock&revalidate implementation.  I've reordered the code, and now the
  undo allocation can happen before acquiring the semaphore array spinlock.
   As a bonus, less code runs under the semaphore array spinlock.

- sysvsem.sleep_list looks like code to handle oopses: if an oops kills a
  thread that sleeps in sys_timedsemop(), then sem_exit tries to recover.
  I've removed that - too fragile.
include/linux/sem.h
ipc/sem.c
ipc/util.c
kernel/exit.c
kernel/fork.c