Re: linux-next 20170519 - semaphores broken

From: Manfred Spraul
Date: Sun May 21 2017 - 10:10:00 EST


Hi valdis,

On 05/20/2017 10:18 PM, valdis.kletnieks@xxxxxx wrote:
Seeing problems with programs that use semaphores. The one
that I'm getting bit by is jackd. strace says:

getuid() = 967
semget(0x282929, 0, 000) = 229376
semop(229376, [{0, -1, SEM_UNDO}], 1) = -1 EIDRM (Identifier removed)
write(2, "JACK semaphore error: semop (Ide"..., 49JACK semaphore error: semop (Identifier removed)
) = 49

Bisects down to this commit, and reverting it from 20170519 makes things work
again. No idea why this causes indigestion, there's probably something subtly
wrong here....
Duh, thanks.
There was another report that got a 99% improvement, which I did not understand.

Probable root cause:
sma = container_of(ipc_rcu_alloc(size), struct sem_array, sem_perm);
if (!sma)
return -ENOMEM;

memset(sma, 0, size);

sma->sem_perm.refcount was initialized by ipc_rcu_alloc.
And due to the SEM_UNDO, the refcount is relevant.

Thanks for bisecting it, I'll update the patch.

--
Manfred