All of lore.kernel.org
 help / color / mirror / Atom feed
From: Meng Xu <meng.xu@gatech.edu>
To: mingo@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org
Cc: meng.xu@gatech.edu, sanidhya@gatech.edu, taesoo@gatech.edu,
	Meng Xu <mengxu.gatech@gmail.com>
Subject: [PATCH] sched/core: Fix a potential double fetch bug on attr->size
Date: Tue, 29 Aug 2017 15:10:16 -0400	[thread overview]
Message-ID: <1504033816-50159-1-git-send-email-meng.xu@gatech.edu> (raw)

From: Meng Xu <mengxu.gatech@gmail.com>

`attr->size` after the second fetch `copy_from_user(attr, uattr, size)`,
can be different from what is initially fetched in and checked
`get_user(size, &uattr->size)` by racing condition in the userspace.

The issue and the patch are both similar to commit f12f42a
(in kernel/events/core.c).

Signed-off-by: Meng Xu <mengxu.gatech@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 0869b20..c22d2b4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -4349,6 +4349,8 @@ static int sched_copy_attr(struct sched_attr __user *uattr, struct sched_attr *a
 	if (ret)
 		return -EFAULT;
 
+	attr->size = size;
+
 	/*
 	 * XXX: Do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
-- 
2.7.4

             reply	other threads:[~2017-08-29 19:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-29 19:10 Meng Xu [this message]
     [not found] ` <12F594E4-B8AA-436B-933A-4E1DFDDC7E0C@gmail.com>
2017-09-25  7:31   ` [PATCH] sched/core: Fix a potential double fetch bug on attr->size Peter Zijlstra
2017-09-25 12:53     ` Meng Xu
2017-09-25 12:53 Meng Xu

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=1504033816-50159-1-git-send-email-meng.xu@gatech.edu \
    --to=meng.xu@gatech.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mengxu.gatech@gmail.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sanidhya@gatech.edu \
    --cc=taesoo@gatech.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.