linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Davidlohr Bueso <dave@stgolabs.net>,
	"Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	"Carlos O'Donell" <carlos@redhat.com>,
	Ingo Molnar <mingo@elte.hu>, Jakub Jelinek <jakub@redhat.com>,
	"linux-man@vger.kernel.org" <linux-man@vger.kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Steven Rostedt <rostedt@goodmis.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Linux API <linux-api@vger.kernel.org>,
	Torvald Riegel <triegel@redhat.com>,
	Roland McGrath <roland@redhat.com>,
	Darren Hart <dvhart@infradead.org>,
	Anton Blanchard <anton@samba.org>, Petr Baudis <pasky@suse.cz>,
	Eric Dumazet <edumazet@google.com>,
	bill o gallmeister <bgallmeister@gmail.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Daniel Wagner <wagi@monom.org>, Rich Felker <dalias@libc.org>
Subject: Re: futex(2) man page update help request
Date: Fri, 16 Jan 2015 17:11:49 -0800	[thread overview]
Message-ID: <D0DEF5CA.B7F02%dvhart@linux.intel.com> (raw)
In-Reply-To: <1421456216.27134.2.camel@stgolabs.net>

On 1/16/15, 4:56 PM, "Davidlohr Bueso" <dave@stgolabs.net> wrote:


>On Fri, 2015-01-16 at 21:54 +0100, Michael Kerrisk (man-pages) wrote:
>> On 01/16/2015 04:20 PM, Thomas Gleixner wrote:
>> > On Fri, 16 Jan 2015, Michael Kerrisk (man-pages) wrote:
>> > 
>> >> Hello Thomas,
>> >>
>> >> On 01/15/2015 11:23 PM, Thomas Gleixner wrote:
>> >>> On Thu, 15 Jan 2015, Michael Kerrisk (man-pages) wrote:
>> >>>>> [EINVAL] uaddr equal uaddr2. Requeue to same futex.
>> >>>>
>> >>>> ??? I added this, but does this error not occur only for PI
>>requeues?
>> >>>
>> >>> It's equally wrong for normal futexes. And its actually the same
>>code
>> >>> checking for this for all variants.
>> >>
>> >> I don't understand "equally wrong" in your reply, I'm sorry. Do you
>> >> mean:
>> >>
>> >> a) This error text should be there for both normal and PI requeues
>> > 
>> > It is there for both. The requeue code has that check independent of
>> > the requeue type (normal/pi). It never makes sense to requeue
>> > something to itself whether normal or pi futex. We added this for PI,
>> > because there it is harmful, but we did not special case it. So normal
>> > futexes get the same treatment.
>> 
>> Hello Thomas, 
>> 
>> Color me stupid, but I can't see this in futex_requeue(). Where is that
>> check that is "independent of the requeue type (normal/pi)"?
>> 
>> When I look through futex_requeue(), all the likely looking sources
>> of EINVAL are governed by a check on the 'requeue_pi' argument.
>
>Yeah, its not very straightforward, I was also scratching my head. First
>we do:
>
>	if (requeue_pi) {
>		/*
>		 * Requeue PI only works on two distinct uaddrs. This
>		 * check is only valid for private futexes. See below.
>		 */
>		if (uaddr1 == uaddr2)
>			return -EINVAL;

We check here to abort as early as possible for the usual security reasons.

>
>Then:
>
>	/*
>	 * The check above which compares uaddrs is not sufficient for
>	 * shared futexes. We need to compare the keys:
>	 */
>	if (requeue_pi && match_futex(&key1, &key2)) {
>		ret = -EINVAL;
>		goto out_put_keys;
>	}
>
>I wonder why we're checking for requeue_pi again, when, at least
>according to the comments, it should be for shared. I guess it would
>make sense depending on the mappings as the keys are the only true way
>of determining if both futexes are the same, so perhaps:
>
>	if ((requeue_pi || (flags & FLAGS_SHARED)) && match_futex())

No, the rule only applies to requeue_pi. This check is the for-sure
version of the uaddr comparison above. We could add if flags &
FLAGS_SHARED, but I'm not sure it's worth it.

--
Darren Hart
Intel Open Source Technology Center




  reply	other threads:[~2015-01-17  1:12 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 10:35 futex(2) man page update help request Michael Kerrisk (man-pages)
2014-05-14 16:18 ` Darren Hart
2014-05-14 19:03   ` Michael Kerrisk (man-pages)
2014-05-14 19:59     ` Darren Hart
2014-05-14 20:23     ` Carlos O'Donell
2014-05-14 20:44       ` Andy Lutomirski
2014-05-14 23:34       ` Thomas Gleixner
2014-05-15  3:12         ` Carlos O'Donell
2014-05-15  4:49           ` Michael Kerrisk (man-pages)
2014-05-15  4:53         ` Michael Kerrisk (man-pages)
2014-05-15 14:14           ` Thomas Gleixner
2014-05-15 20:19             ` Michael Kerrisk (man-pages)
2014-08-04 14:46               ` Carlos O'Donell
2014-05-15 20:35             ` Darren Hart
2015-01-15 15:12               ` Michael Kerrisk (man-pages)
2015-01-17  1:33                 ` Darren Hart
2015-01-17  9:16                   ` Michael Kerrisk (man-pages)
2015-01-17 19:26                     ` Darren Hart
2015-01-18 10:18                       ` Michael Kerrisk (man-pages)
2015-01-15 15:10             ` Michael Kerrisk (man-pages)
2015-01-15 22:23               ` Thomas Gleixner
2015-01-16 15:17                 ` Michael Kerrisk (man-pages)
2015-01-16 15:20                   ` Thomas Gleixner
2015-01-16 20:54                     ` Michael Kerrisk (man-pages)
2015-01-17  0:46                       ` Darren Hart
2015-01-19 10:45                         ` Thomas Gleixner
2015-01-19 14:07                           ` Michael Kerrisk (man-pages)
2015-01-23 18:19                         ` Torvald Riegel
2015-01-24 10:05                           ` Thomas Gleixner
2015-01-24 12:58                             ` Torvald Riegel
2015-01-24 16:25                               ` Thomas Gleixner
2015-01-17  0:56                       ` Davidlohr Bueso
2015-01-17  1:11                         ` Darren Hart [this message]
2015-01-23 18:29               ` Torvald Riegel
2015-01-24 11:35                 ` Thomas Gleixner
2015-01-24 13:12                   ` Torvald Riegel
2015-01-27  7:48                     ` Michael Kerrisk (man-pages)
2015-02-05 19:57                   ` Darren Hart
2014-05-15  8:13       ` Peter Zijlstra
2014-05-15 15:43         ` Darren Hart
2014-05-15  8:14       ` Peter Zijlstra
2014-05-15 13:18         ` Carlos O'Donell
2014-05-15 13:22           ` Peter Zijlstra
2014-05-15 13:49             ` Michael Kerrisk (man-pages)
2014-05-15 13:55               ` Peter Zijlstra
2014-05-15 14:39               ` Carlos O'Donell
2014-05-15 15:11                 ` Peter Zijlstra
2014-05-14 20:56     ` Davidlohr Bueso
2014-05-14 21:03       ` Darren Hart
2014-05-14 22:21         ` Paul E. McKenney
2014-05-15  0:28       ` H. Peter Anvin
2014-05-15  0:35         ` Andy Lutomirski
2014-05-15  0:41           ` H. Peter Anvin
2014-05-15 19:10         ` Carlos O'Donell
2014-05-14 21:05   ` Davidlohr Bueso
2014-05-15 15:15     ` Joseph S. Myers
2014-05-15  0:18   ` H. Peter Anvin
2014-05-15  5:21     ` Darren Hart
2014-05-15  8:23       ` Peter Zijlstra
2014-05-15 13:46       ` Michael Kerrisk (man-pages)
2014-05-15 14:59         ` H. Peter Anvin
2014-05-15 15:42         ` chrubis
2014-05-15 15:52           ` H. Peter Anvin
2014-05-15 16:01             ` chrubis
2014-05-15 16:07               ` H. Peter Anvin
2014-05-15 16:17                 ` chrubis
2014-05-15 16:56                   ` H. Peter Anvin
2014-05-15 17:06                     ` chrubis
2014-05-15 15:47         ` Darren Hart
2014-05-15 15:35     ` chrubis
2014-05-15 15:28   ` chrubis
2014-05-15 15:40     ` Steven Rostedt
2014-05-15 16:14     ` Darren Hart
2014-05-15 16:30       ` chrubis
2014-05-15 18:17         ` Darren Hart
2014-05-15 19:05           ` chrubis
2014-05-15 19:38             ` Darren Hart
2014-08-11 10:19               ` chrubis
2014-11-26 13:41               ` Cyril Hrubis
2015-02-16 13:14               ` Cyril Hrubis

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=D0DEF5CA.B7F02%dvhart@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=anton@samba.org \
    --cc=arnd@arndb.de \
    --cc=bgallmeister@gmail.com \
    --cc=carlos@redhat.com \
    --cc=dalias@libc.org \
    --cc=dave@stgolabs.net \
    --cc=dvhart@infradead.org \
    --cc=edumazet@google.com \
    --cc=jakub@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtk.manpages@gmail.com \
    --cc=pasky@suse.cz \
    --cc=peterz@infradead.org \
    --cc=roland@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=triegel@redhat.com \
    --cc=wagi@monom.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;
as well as URLs for NNTP newsgroup(s).