mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Desaulniers <nick.desaulniers@gmail.com>
To: kbuild test robot <lkp@intel.com>
Cc: kbuild-all@01.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Ingo Molnar" <mingo@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] KVM: x86: avoid large stack allocations in em_fxrstor
Date: Mon, 29 May 2017 13:29:43 -0700	[thread overview]
Message-ID: <20170529202943.k3kx7z2c2hbyd7ye@lostoracle.net> (raw)
In-Reply-To: <201705300433.ljrAGQlZ%fengguang.wu@intel.com>

On Tue, May 30, 2017 at 04:14:50AM +0800, kbuild test robot wrote:
>    arch/x86/kvm/emulate.c: In function 'em_fxrstor':
> >> arch/x86/kvm/emulate.c:4015:5: warning: 'size' may be used uninitialized in this function [-Wmaybe-uninitialized]
>      rc = segmented_read_std(ctxt, ctxt->memop.addr.mem, &fx_state, size);
>      ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I definitely thought about this before submitting.  size is initialized
in the case ctxt->mode < X86EMUL_MODE_PROT64, and
ctxt->mode == X86EMUL_MODE_PROT64, but uninitialized in the case
ctxt->mode > X86EMUL_MODE_PROT64.

Paulo mentions this is impossible in:

https://lkml.org/lkml/2017/5/26/62

>>> ctxt->mode is never > X86EMUL_MODE_PROT64
>>> (see the definition of enum x86emul_mode in
>>> arch/x86/include/asm/kvm_emulate.h.)

>From arch/x86/include/asm/kvm_emulate.h:

272 enum x86emul_mode {
273   X86EMUL_MODE_REAL,  /* Real mode.             */
274   X86EMUL_MODE_VM86,  /* Virtual 8086 mode.     */
275   X86EMUL_MODE_PROT16,  /* 16-bit protected mode. */
276   X86EMUL_MODE_PROT32,  /* 32-bit protected mode. */
277   X86EMUL_MODE_PROT64,  /* 64-bit (long) mode.    */
278 };

I would still rather err on the side of safety, and initialize the
variable. So I will submit a v3 initializing size to 0, and check that
size was set to a reasonable value at some point before invoke
segmented_read_std.

  reply	other threads:[~2017-05-29 20:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24  6:24 [PATCH] KVM: x86: dynamically allocate large struct " Nick Desaulniers
2017-05-24 14:19 ` Radim Krčmář
2017-05-25  1:36   ` Nick Desaulniers
2017-05-25 14:07     ` Paolo Bonzini
2017-05-26  4:13       ` Nick Desaulniers
2017-05-26  7:18         ` Paolo Bonzini
2017-05-29 19:55           ` [PATCH v2] KVM: x86: avoid large stack allocations " Nick Desaulniers
2017-05-29 20:14             ` kbuild test robot
2017-05-29 20:29               ` Nick Desaulniers [this message]
2017-05-29 20:39             ` [PATCH v3] " Nick Desaulniers
2017-05-29 22:40               ` Nick Desaulniers
2017-05-29 22:48               ` [PATCH v4] " Nick Desaulniers
2017-05-30 10:15                 ` Paolo Bonzini
2017-05-30 14:05                   ` Radim Krčmář
2017-05-31  3:08                 ` [PATCH v5] " Nick Desaulniers
2017-05-31 11:01                   ` Paolo Bonzini
2017-06-01  1:05                     ` Nick Desaulniers
2017-06-01  7:36                       ` Paolo Bonzini
2017-06-02  2:10                         ` Nick Desaulniers

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=20170529202943.k3kx7z2c2hbyd7ye@lostoracle.net \
    --to=nick.desaulniers@gmail.com \
    --cc=hpa@zytor.com \
    --cc=kbuild-all@01.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rkrcmar@redhat.com \
    --cc=tglx@linutronix.de \
    --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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®