From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: mtk.manpages@gmail.com, Nicholas Miell <nmiell@gmail.com>,
Torvald Riegel <triegel@redhat.com>,
Roland McGrath <roland@hack.frob.com>,
"linux-man@vger.kernel.org" <linux-man@vger.kernel.org>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
Carlos O'Donell <carlos@redhat.com>
Subject: Re: For review: nptl(7) man page
Date: Thu, 06 Aug 2015 12:06:18 +0200 [thread overview]
Message-ID: <55C3319A.7020408@gmail.com> (raw)
In-Reply-To: <20150805194613.GB14639@brightrain.aerifal.cx>
On 08/05/2015 09:46 PM, Rich Felker wrote:
> On Wed, Aug 05, 2015 at 08:59:55PM +0200, Michael Kerrisk (man-pages) wrote:
>>>>> The semaphore example shows that there can be a disadvantage to
>>>>> guaranteeing 32/64b interoperability (specifically, the 64b code is more
>>>>> efficient). For mutex, I *currently* don't see a reason why we couldn't
>>>>> get away with just doing 32b stuff for the pshared case, but there's no
>>>>> guarantee that I can foresee all future needs either.
>>>>>
>>>>> Thus, if we would decide to guarantee 32/64b interoperability, we'd need
>>>>> to have at least strong use cases for that and a decent amount of
>>>>> confidence that making such a guarantee is unlikely to constrain the
>>>>> implementation in the future.
>>>>
>>>> Well, POSIX semaphores are supposed to be a replacement for System V
>>>> semaphores (and this extends to the rest of the POSIX IPC
>>>> primitives); right now they aren't.
>>>
>>> Only for some usage cases. As far as I can tell, POSIX semaphores are
>>> not intended to be required to be implemented as a kernel resource.
>>
>> That last is also true of SysV semaphores, surely?
>
> The grammar of my sentence was rather complicated and perhaps
> confusing. The intent was to say that SysV semaphores absolutely have
> to be a kernel resource, but POSIX semaphores don't (and aren't).
I'm still puzzled. POSIX certainly doesn't make any requirements here.
So who does or doesn't "require" this? Also, I am not sure of the
distinction you're trying to make here. In the Linux implementation of
POSIX semaphores, kernel involvement is required in the contended case.
>>> They don't have permissions enforcement/safety against malicious
>>> processes,
>>
>> (I'm a little lost here. POSIX semaphores do have a permissions mask.)
>
> Yes, named semaphores have fs-like permissions, and of course you can
> do that with unnamed ones in named shared memory objects or files.
> However, as implemented in the real world, that provides no protection
> from a malicious process that _does_ have access permissions. With SysV
> semaphores, the worst a malicious process with access can do is
> wait/post the semaphore. With current implementations of POSIX
> semaphores, and other process-shared pthread sync objects, a malicious
> process that has access can utterly corrupt the state of the object. I
> am not sure of the extent of damage that can be achieved here, but
> there is not explicit effort to harden against it.
Again, I'm clear on the distinction here. By "corrupted", I assume
you're talking about (say) directly opening the SHM object used
to implement the semaphore and tweaking bits arbitrarily.
But, if someone can wait/post maliciously, you're pretty much
hosed anyway.
>>> backout on async process termination, etc.
>>
>> Actually, System V semaphores don't reliably have this either (see BUGS
>> in semop(2)).
>
> That's something of a design bug, but irrelevant to the reasonable
> usage which would be to post, not wait.
Why is that the only reasonable usage?
It totally depends on the design of the sync protocol that you're
layering on top of SysV semaphores. SEM_UNDO is a fundamentally
broken concept, AFAICS.
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
next prev parent reply other threads:[~2015-08-06 10:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-22 14:38 For review: nptl(7) man page Michael Kerrisk (man-pages)
[not found] ` <550ED3F4.1080403-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-03-22 15:51 ` Bert Wesarg
[not found] ` <CAKPyHN2VTcP3eOPA-er+iOs0VCRd4ALzuqPY4HJOVOmDH7Arug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-03-22 19:02 ` Michael Kerrisk (man-pages)
2015-03-22 19:56 ` Szabolcs Nagy
[not found] ` <20150322195632.GM16260-4P1ElwuDYu6sTnJN9+BGXg@public.gmane.org>
2015-07-24 7:56 ` Michael Kerrisk (man-pages)
2015-03-22 21:38 ` Nicholas Miell
[not found] ` <550F363B.801-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-24 7:57 ` Michael Kerrisk (man-pages)
[not found] ` <CAODz2cDq4o85NOzqCDg9cH8eCvqt3Tq5QXKMMJtXbik5h5bL+Q@mail.gmail.com>
[not found] ` <CAODz2cDq4o85NOzqCDg9cH8eCvqt3Tq5QXKMMJtXbik5h5bL+Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-26 20:24 ` Michael Kerrisk (man-pages)
2015-07-26 20:27 ` Nicholas Miell
[not found] ` <CAODz2cAmqVtkoNSwUA5p0_=pcFAdrS3ovohyjwnXMapgEhc4qg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-26 20:29 ` Michael Kerrisk (man-pages)
[not found] ` <55B54215.6070502-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-03 15:45 ` Torvald Riegel
2015-08-03 20:08 ` Rich Felker
2015-08-04 15:06 ` Roland McGrath
[not found] ` <20150804150648.9E9F42C3B01-j1d2VQoJOwwHfwO+Tb3JRVaTQe2KTcn/@public.gmane.org>
2015-08-04 18:50 ` Nicholas Miell
[not found] ` <3848244D-C3FE-4FD1-B137-AF7AD6252659-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05 9:36 ` Torvald Riegel
[not found] ` <1438767393.20974.211.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2015-08-05 18:14 ` Nicholas Miell
[not found] ` <BCB9D422-563C-4317-B0CB-B14001FE0EA3-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05 18:23 ` Rich Felker
[not found] ` <20150805182327.GA14639-C3MtFaGISjmo6RMmaWD+6Sb1p8zYI1N1@public.gmane.org>
2015-08-05 18:59 ` Michael Kerrisk (man-pages)
[not found] ` <55C25D2B.4040905-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-05 19:46 ` Rich Felker
2015-08-06 10:06 ` Michael Kerrisk (man-pages) [this message]
[not found] ` <55C3319A.7020408-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-08-06 13:54 ` Rich Felker
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=55C3319A.7020408@gmail.com \
--to=mtk.manpages@gmail.com \
--cc=carlos@redhat.com \
--cc=dalias@libc.org \
--cc=libc-alpha@sourceware.org \
--cc=linux-man@vger.kernel.org \
--cc=nmiell@gmail.com \
--cc=roland@hack.frob.com \
--cc=triegel@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).