From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jann Horn <jannh@google.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/mtrr: don't copy out-of-bounds data in mtrr_write
Date: Mon, 09 Jul 2018 09:52:56 +0300 [thread overview]
Message-ID: <f9c8cf81df29006bc9c79932f3bcd599b559b408.camel@linux.intel.com> (raw)
In-Reply-To: <20180706215003.156702-1-jannh@google.com>
On Fri, 2018-07-06 at 23:50 +0200, Jann Horn wrote:
> Don't access the provided buffer out of bounds - this can cause a
> kernel
> out-of-bounds read when invoked through sys_splice() or other things
> that
> use kernel_write()/__kernel_write().
>
Can you elaborate a bit this change?
Only few places in the kernel do this way and I would like to understand
why in most of the cases it's okay to supply maximum available length
and here is not the one.
> Fixes: 7f8ec5a4f01a ("x86/mtrr: Convert to use strncpy_from_user()
> helper")
> Signed-off-by: Jann Horn <jannh@google.com>
> ---
> arch/x86/kernel/cpu/mtrr/if.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/cpu/mtrr/if.c
> b/arch/x86/kernel/cpu/mtrr/if.c
> index 4021d3859499..40eee6cc4124 100644
> --- a/arch/x86/kernel/cpu/mtrr/if.c
> +++ b/arch/x86/kernel/cpu/mtrr/if.c
> @@ -106,7 +106,8 @@ mtrr_write(struct file *file, const char __user
> *buf, size_t len, loff_t * ppos)
>
> memset(line, 0, LINE_SIZE);
>
> - length = strncpy_from_user(line, buf, LINE_SIZE - 1);
> + len = min_t(size_t, len, LINE_SIZE - 1);
> + length = strncpy_from_user(line, buf, len);
> if (length < 0)
> return length;
>
--
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
next prev parent reply other threads:[~2018-07-09 6:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 21:50 [PATCH] x86/mtrr: don't copy out-of-bounds data in mtrr_write Jann Horn
2018-07-07 17:04 ` [tip:x86/urgent] x86/mtrr: Don't " tip-bot for Jann Horn
2018-07-09 6:52 ` Andy Shevchenko [this message]
2018-07-09 7:41 ` [PATCH] x86/mtrr: don't " Jann Horn
2018-07-09 8:20 ` Andy Shevchenko
2018-07-15 22:03 ` Ingo Molnar
2018-07-16 1:32 ` Jann Horn
2018-07-16 1:46 ` Linus Torvalds
2018-07-16 2:26 ` Al Viro
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=f9c8cf81df29006bc9c79932f3bcd599b559b408.camel@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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