From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751236AbdE2U3t (ORCPT ); Mon, 29 May 2017 16:29:49 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33409 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750873AbdE2U3r (ORCPT ); Mon, 29 May 2017 16:29:47 -0400 Date: Mon, 29 May 2017 13:29:43 -0700 From: Nick Desaulniers To: kbuild test robot Cc: kbuild-all@01.org, Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , 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 Message-ID: <20170529202943.k3kx7z2c2hbyd7ye@lostoracle.net> References: <20170529195538.27419-1-nick.desaulniers@gmail.com> <201705300433.ljrAGQlZ%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201705300433.ljrAGQlZ%fengguang.wu@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.