All of lore.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Borislav Petkov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dvyukov@google.com, tony.luck@intel.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com,
	bp@suse.de, linux-edac@vger.kernel.org
Subject: [tip:ras/core] x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read()
Date: Sun, 6 May 2018 03:52:35 -0700	[thread overview]
Message-ID: <tip-985c78d3ff8e9c74450fa2bb08eb55e680d999ca@git.kernel.org> (raw)

Commit-ID:  985c78d3ff8e9c74450fa2bb08eb55e680d999ca
Gitweb:     https://git.kernel.org/tip/985c78d3ff8e9c74450fa2bb08eb55e680d999ca
Author:     Luck, Tony <tony.luck@intel.com>
AuthorDate: Fri, 27 Apr 2018 09:37:08 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 6 May 2018 12:46:39 +0200

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 <dvyukov@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas 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-desk
---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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 {

WARNING: multiple messages have this Message-ID (diff)
From: "tip-bot for Luck, Tony" <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dvyukov@google.com, tony.luck@intel.com, tglx@linutronix.de,
	linux-kernel@vger.kernel.org, mingo@kernel.org, hpa@zytor.com,
	bp@suse.de, linux-edac@vger.kernel.org
Subject: [tip:ras/core] x86/MCE: Fix stack out-of-bounds write in mce-inject.c: Flags_read()
Date: Sun, 6 May 2018 03:52:35 -0700	[thread overview]
Message-ID: <tip-985c78d3ff8e9c74450fa2bb08eb55e680d999ca@git.kernel.org> (raw)
In-Reply-To: <20180427163707.ktaiysvbk3yhk4wm@agluck-desk>

Commit-ID:  985c78d3ff8e9c74450fa2bb08eb55e680d999ca
Gitweb:     https://git.kernel.org/tip/985c78d3ff8e9c74450fa2bb08eb55e680d999ca
Author:     Luck, Tony <tony.luck@intel.com>
AuthorDate: Fri, 27 Apr 2018 09:37:08 -0700
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sun, 6 May 2018 12:46:39 +0200

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 <dvyukov@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas 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-desk
---
 arch/x86/kernel/cpu/mcheck/mce-inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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	other threads:[~2018-05-06 10:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-06 10:52 tip-bot for Borislav Petkov [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2018-04-27 16:59 x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read() Borislav Petkov
2018-04-27 16:59 ` [PATCH] " Borislav Petkov
2018-04-27 16:37 Luck, Tony
2018-04-27 16:37 ` [PATCH] " Luck, Tony
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

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=tip-985c78d3ff8e9c74450fa2bb08eb55e680d999ca@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@suse.de \
    --cc=dvyukov@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.