From: Ingo Molnar <mingo@kernel.org>
To: Davidlohr Bueso <dave@stgolabs.net>
Cc: tglx@linutronix.de, peterz@infradead.org, dvhart@linux.intel.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] futex: Robustify wake_futex()
Date: Wed, 18 Feb 2015 18:07:04 +0100 [thread overview]
Message-ID: <20150218170704.GA29024@gmail.com> (raw)
In-Reply-To: <1424148397.2046.101.camel@stgolabs.net>
* Davidlohr Bueso <dave@stgolabs.net> wrote:
> Current code assumes that wake_futex() will never fail,
> thus we are rather sloppy when incrementing the return
> value in wake related calls, accounting for the newly
> woken task. Of course this will never occur, thus not a
> problem. This bug is as real as the need for the
> redundant pi checks in wake_futex().
>
> These redundant checks are fine and past discussion
> indicates that they will stay. However, it does introduce
> this mismatch, thus it is better to robustify the
> function and avoid any assumptions that could bite us in
> the arse the future.
So can the current code crash or hang if the WARN()
triggers?
> kernel/futex.c | 45 +++++++++++++++++++++++++++++++++------------
> 1 file changed, 33 insertions(+), 12 deletions(-)
My counter argument is that we add quite a bit of pointless
complexity:
> - if (WARN(q->pi_state || q->rt_waiter, "refusing to wake PI futex\n"))
> - return;
> + if (unlikely(WARN(q->pi_state || q->rt_waiter,
> + "refusing to wake PI futex\n")))
> + return false;
> - wake_futex(this);
> + if (!wake_futex(this)) {
> + ret = -EINVAL;
> + break;
> + }
+ [ 4 more usage sites ]
while the WARN() already told the user that the kernel is
broken.
So what's the point? Does it avoid any real badness, state
corruption, crash, hang, etc.?
Thanks,
Ingo
next prev parent reply other threads:[~2015-02-18 17:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 4:46 [PATCH] futex: Robustify wake_futex() Davidlohr Bueso
2015-02-18 17:07 ` Ingo Molnar [this message]
2015-02-19 1:28 ` Davidlohr Bueso
2015-02-19 9:56 ` Ingo Molnar
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=20150218170704.GA29024@gmail.com \
--to=mingo@kernel.org \
--cc=dave@stgolabs.net \
--cc=dvhart@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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