LKML Archive on
 help / Atom feed
From: "Luck, Tony" <>
To: Dmitry Vyukov <>
Cc: Borislav Petkov <>,
	Thomas Gleixner <>,
	Ingo Molnar <>, "H. Peter Anvin" <>,
	the arch/x86 maintainers <>,, LKML <>
Subject: [PATCH] x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read()
Date: Fri, 27 Apr 2018 09:37:08 -0700
Message-ID: <20180427163707.ktaiysvbk3yhk4wm@agluck-desk> (raw)
In-Reply-To: <>

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

Reported-by: Dmitry Vyukov <>
Cc: <>
Signed-off-by: Tony Luck <>


diff --git a/arch/x86/kernel/cpu/mcheck/mce-inject.c b/arch/x86/kernel/cpu/mcheck/mce-inject.c
index 475cb4f5f14f..c805a06e14c3 100644
--- a/arch/x86/kernel/cpu/mcheck/mce-inject.c
+++ b/arch/x86/kernel/cpu/mcheck/mce-inject.c
@@ -48,7 +48,7 @@ static struct dentry *dfs_inj;
 static u8 n_banks;
-#define MAX_FLAG_OPT_SIZE	3
+#define MAX_FLAG_OPT_SIZE	4
 #define NBCFG			0x44
 enum injection_type {

  reply index

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-27 15:24 stack out-of-bounds write in mce-inject.c Dmitry Vyukov
2018-04-27 15:41 ` Borislav Petkov
2018-04-27 16:06   ` Dmitry Vyukov
2018-04-27 16:37     ` Luck, Tony [this message]
2018-04-27 16:59       ` [PATCH] x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read() Borislav Petkov
2018-05-06 10:52       ` [tip:ras/core] x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read() tip-bot for Luck, Tony

Reply instructions:

You may reply publically 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180427163707.ktaiysvbk3yhk4wm@agluck-desk \ \ \ \ \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on

Archives are clonable:
	git clone --mirror lkml/git/0.git
	git clone --mirror lkml/git/1.git
	git clone --mirror lkml/git/2.git
	git clone --mirror lkml/git/3.git
	git clone --mirror lkml/git/4.git
	git clone --mirror lkml/git/5.git
	git clone --mirror lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ \
	public-inbox-index lkml

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox