LKML Archive on lore.kernel.org
 help / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: "Luck, Tony" <tony.luck@intel.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	the arch/x86 maintainers <x86@kernel.org>,
	linux-edac@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read()
Date: Fri, 27 Apr 2018 18:59:39 +0200
Message-ID: <20180427165939.GG15229@pd.tnic> (raw)
In-Reply-To: <20180427163707.ktaiysvbk3yhk4wm@agluck-desk>

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.

-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  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     ` [PATCH] x86, mce: Fix stack out-of-bounds write in mce-inject.c:flags_read() Luck, Tony
2018-04-27 16:59       ` 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

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:
  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=20180427165939.GG15229@pd.tnic \
    --to=bp@alien8.de \
    --cc=dvyukov@google.com \
    --cc=hpa@zytor.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /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

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 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/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox