summaryrefslogtreecommitdiffstats
path: root/fs/ext3/file.c
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2014-01-27 17:07:00 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2014-01-27 21:02:39 -0800
commit78f5009cc35eb5e52d276a046d90ee2f41b60f8c (patch)
treeea7a64dd1bf5b00e5c6c1bb4c709ac51aa3f7675 /fs/ext3/file.c
parent729abd2ba7007cc2be9e77718ba52d0866d3f60f (diff)
downloadop-kernel-dev-78f5009cc35eb5e52d276a046d90ee2f41b60f8c.zip
op-kernel-dev-78f5009cc35eb5e52d276a046d90ee2f41b60f8c.tar.gz
ipc/sem.c: avoid overflow of semop undo (semadj) value
When trying to understand semop code, I found a small mistake in the check for semadj (undo) value overflow. The new undo value is not stored immediately and next potential checks are done against the old value. The failing scenario is not much practical. One semop call has to do more operations on the same semaphore. Also semval and semadj must have different values, so there has to be some operations without SEM_UNDO flag. For example: struct sembuf depositor_op[1]; struct sembuf collector_op[2]; depositor_op[0].sem_num = 0; depositor_op[0].sem_op = 20000; depositor_op[0].sem_flg = 0; collector_op[0].sem_num = 0; collector_op[0].sem_op = -10000; collector_op[0].sem_flg = SEM_UNDO; collector_op[1].sem_num = 0; collector_op[1].sem_op = -10000; collector_op[1].sem_flg = SEM_UNDO; if (semop(semid, depositor_op, 1) == -1) { perror("Failed to do 1st deposit"); return 1; } if (semop(semid, collector_op, 2) == -1) { perror("Failed to do 1st collect"); return 1; } if (semop(semid, depositor_op, 1) == -1) { perror("Failed to do 2nd deposit"); return 1; } if (semop(semid, collector_op, 2) == -1) { perror("Failed to do 2nd collect"); return 1; } return 0; It passes without error now but the semadj value has overflown in the 2nd collector operation. [akpm@linux-foundation.org: restore lessened scope of local `undo'] [davidlohr@hp.com: correct header comment for perform_atomic_semop] Signed-off-by: Petr Mladek <pmladek@suse.cz> Acked-by: Davidlohr Bueso <davidlohr@hp.com> Acked-by: Manfred Spraul <manfred@colorfullife.com> Cc: Jiri Kosina <jkosina@suse.cz> Signed-off-by: Davidlohr Bueso <davidlohr@hp.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ext3/file.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud