Skip to content

Commit 985c78d

Browse files
aeglKAGA-KOKO
authored andcommitted
x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read()
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: Dmitry Vyukov <[email protected]> Signed-off-by: Tony Luck <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: linux-edac <[email protected]> Link: http://lkml.kernel.org/r/20180427163707.ktaiysvbk3yhk4wm@agluck-desk
1 parent 13e8582 commit 985c78d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kernel/cpu/mcheck/mce-inject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static struct dentry *dfs_inj;
4848

4949
static u8 n_banks;
5050

51-
#define MAX_FLAG_OPT_SIZE 3
51+
#define MAX_FLAG_OPT_SIZE 4
5252
#define NBCFG 0x44
5353

5454
enum injection_type {

0 commit comments

Comments
 (0)