From: JingYi Hou <houjingyi647@gmail.com>
To: mingo@redhat.com, peterz@infradead.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sched/core: fix double fetch in sched_copy_attr()
Date: Mon, 15 Jul 2019 20:33:42 -0700 [thread overview]
Message-ID: <20190716033342.GA32294@ubuntu> (raw)
In sched_copy_attr(), attr->size was fetched twice in get_user()
and copy_from_user().
If change it between two fetches may cause security problems
or unexpected behaivor.
We can apply the same pattern used in perf_copy_attr(). That
is, use value fetched first time to overwrite it after second fetch.
Signed-off-by: JingYi Hou <houjingyi647@gmail.com>
---
kernel/sched/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 2b037f195473..60088b907ef4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4945,6 +4945,8 @@ static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *a
ret = copy_from_user(attr, uattr, size);
if (ret)
return -EFAULT;
+
+ attr->size = size;
if ((attr->sched_flags & SCHED_FLAG_UTIL_CLAMP) &&
size < SCHED_ATTR_SIZE_VER1)
--
2.20.1
reply other threads:[~2019-07-16 3:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190716033342.GA32294@ubuntu \
--to=houjingyi647@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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;
as well as URLs for NNTP newsgroup(s).