On Sun, 18 Sep 2016, Manfred Spraul wrote:I looked at it by comparing how we handle ipcperms and security_msg_queue_xx():
Just as with msgrcv (along with the rest of sysvipc since a few yearsThinking about it: isn't this wrong?
ago), perform the security checks without holding the ipc object lock.
CPU1:
* msgrcv()
* ipcperms()
<sleep>
CPU2:
* msgctl(), change permissions
** msgctl() returns, new permissions should now be in effect
* msgsnd(), send secret message
** msgsnd() returns, new message stored.
CPU1: resumes, receives secret message
Hmm, would this not apply to everything IPC_SET, we do lockless ipcperms()
all over the place.
Obviously, we could argue that the msgrcv() was already ongoing and therefore the old permissions still apply - but then we don't need to recheck after sleeping at all.
There is that, and furthermore we make no such guarantees under concurrency.
Another way of looking at it could perhaps be IPC_SET returning EPERM if
there's an unserviced msgrcv -- but I'm not suggesting doing this btw ;)