From: Peter Zijlstra <peterz@infradead.org>
To: Daniel Bristot de Oliveira <bristot@redhat.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
tglx@linutronix.de, stable@vger.kernel.org, rostedt@goodmis.org
Subject: Re: [PATCH] sched: fix sched_setparam() policy=-1 logic
Date: Wed, 23 Jul 2014 16:36:32 +0200 [thread overview]
Message-ID: <20140723143632.GV3935@laptop> (raw)
In-Reply-To: <9ebe0566a08dbbb3999759d3f20d6004bb2dbcfa.1406079891.git.bristot@redhat.com>
On Tue, Jul 22, 2014 at 11:27:41PM -0300, Daniel Bristot de Oliveira wrote:
> The scheduler uses policy=-1 to preserve the current policy state to
> implement sched_setparam(). But, as (int) -1 is equals to 0xffffffff,
> it's matching the if (policy & SCHED_RESET_ON_FORK) on
> _sched_setscheduler(). This match changes the policy value to an
> invalid value, breaking the sched_setparam() syscall.
>
> This patch checks policy=-1 before check the SCHED_RESET_ON_FORK flag.
>
> The following program shows the bug:
>
> int main(void)
> {
> struct sched_param param = {
> .sched_priority = 5,
> };
>
> sched_setscheduler(0, SCHED_FIFO, ¶m);
> param.sched_priority = 1;
> sched_setparam(0, ¶m);
> param.sched_priority = 0;
> sched_getparam(0, ¶m);
> if (param.sched_priority != 1)
> printf("failed priority setting (found %d instead of 1)\n",
> param.sched_priority);
> else
> printf("priority setting fine\n");
> }
>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: stable@vger.kernel.org # 3.14+
> Fixes: 7479f3c9cf67 "sched: Move SCHED_RESET_ON_FORK into attr::sched_flags"
> Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
Thanks!
next prev parent reply other threads:[~2014-07-23 14:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-23 2:27 [PATCH] sched: fix sched_setparam() policy=-1 logic Daniel Bristot de Oliveira
2014-07-23 14:36 ` Peter Zijlstra [this message]
2014-07-28 8:28 ` [tip:sched/core] sched: Fix sched_setparam() policy == -1 logic tip-bot for Daniel Bristot de Oliveira
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=20140723143632.GV3935@laptop \
--to=peterz@infradead.org \
--cc=bristot@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=stable@vger.kernel.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