mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	akpm@linux-foundation.org
Subject: Re: [PATCH 4/5] ipc/msg: Lockless security checks for msgsnd
Date: Thu, 22 Sep 2016 21:42:54 +0200	[thread overview]
Message-ID: <0106cf74-e308-fc20-b76f-e8a6253c3d66@colorfullife.com> (raw)
In-Reply-To: <20160921222122.GA13358@linux-80c1.suse>

On 09/22/2016 12:21 AM, Davidlohr Bueso wrote:
> On Sun, 18 Sep 2016, Manfred Spraul wrote:
>
>>> Just as with msgrcv (along with the rest of sysvipc since a few years
>>>    ago), perform the security checks without holding the ipc object 
>>> lock.
>> Thinking about it: isn't this wrong?
>>
>> 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 ;)
I looked at it by comparing how we handle ipcperms and 
security_msg_queue_xx():
The security_msg_queue_xx are called under the lock, or actually the 
msgrcv even looks at the message that is transferred.

For ipc/sem.c and ipc/shm.c, both operations are called outside the lock.

So, my proposal would be that ipcperms and security_xx should show the 
same behavior regarding concurrent ops.
And this would mean that we should not move ipcperms() in msgrcv outside 
of the lock, i.e. drop the patch.

But if you have a better rational, feel free. But please document it in 
the changelog.

--
     Manfred

  reply	other threads:[~2016-09-22 19:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18  5:10 Manfred Spraul
2016-09-21 22:21 ` Davidlohr Bueso
2016-09-22 19:42   ` Manfred Spraul [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-07-28 23:33 [PATCH 0/5] ipc/msg: Sender/receiver optimizations Davidlohr Bueso
2016-07-28 23:33 ` [PATCH 4/5] ipc/msg: Lockless security checks for msgsnd Davidlohr Bueso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0106cf74-e308-fc20-b76f-e8a6253c3d66@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave@stgolabs.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®