Commit e0b510a4 authored by Tony Luck's avatar Tony Luck Committed by Greg Kroah-Hartman

x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read()

commit 985c78d3 upstream.

Each of the strings that we want to put into the buf[MAX_FLAG_OPT_SIZE]
in flags_read() is two characters long. But the sprintf() adds
a trailing newline and will add a terminating NUL byte. So
MAX_FLAG_OPT_SIZE needs to be 4.

sprintf() calls vsnprintf() and *that* does return:

" * The return value is the number of characters which would
 * be generated for the given input, excluding the trailing
 * '\0', as per ISO C99."

Note the "excluding".
Reported-by: default avatarDmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Cc: linux-edac <linux-edac@vger.kernel.org>
Link: http://lkml.kernel.org/r/20180427163707.ktaiysvbk3yhk4wm@agluck-deskSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c5c00990
...@@ -48,7 +48,7 @@ static struct dentry *dfs_inj; ...@@ -48,7 +48,7 @@ static struct dentry *dfs_inj;
static u8 n_banks; static u8 n_banks;
#define MAX_FLAG_OPT_SIZE 3 #define MAX_FLAG_OPT_SIZE 4
#define NBCFG 0x44 #define NBCFG 0x44
enum injection_type { enum injection_type {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment