* x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read()
@ 2018-04-27 16:37 Luck, Tony
0 siblings, 0 replies; 2+ messages in thread
From: Luck, Tony @ 2018-04-27 16:37 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: Borislav Petkov, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
the arch/x86 maintainers, linux-edac, LKML
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 <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
--
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 {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read()
@ 2018-04-27 16:59 Borislav Petkov
0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2018-04-27 16:59 UTC (permalink / raw)
To: Luck, Tony
Cc: Dmitry Vyukov, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
the arch/x86 maintainers, linux-edac, LKML
On Fri, Apr 27, 2018 at 09:37:08AM -0700, Luck, Tony wrote:
> 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.
... and I dumped the n here:
n = sprintf(buf, "%s\n", flags_options[inj_type])
and it was 3 but 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."
So I'll extend the commit message with that and apply it.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-04-27 16:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-27 16:59 x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read() Borislav Petkov
-- strict thread matches above, loose matches on Subject: below --
2018-04-27 16:37 Luck, Tony
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox