[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f9c8cf81df29006bc9c79932f3bcd599b559b408.camel@linux.intel.com>
Date: Mon, 09 Jul 2018 09:52:56 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Jann Horn <jannh@...gle.com>, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/mtrr: don't copy out-of-bounds data in mtrr_write
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@...gle.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@...ux.intel.com>
Intel Finland Oy
Powered by blists - more mailing lists