From: Avi Kivity <avi@redhat.com>
To: Fengguang Wu <fengguang.wu@intel.com>
Cc: Amos Kong <akong@redhat.com>,
kernel-janitors@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [kvm:next 1/1] arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_r
Date: Wed, 12 Sep 2012 07:37:56 +0000 [thread overview]
Message-ID: <50503BD4.7090604@redhat.com> (raw)
In-Reply-To: <20120912060710.GA24997@localhost>
On 09/12/2012 09:07 AM, Fengguang Wu wrote:
> On Wed, Sep 12, 2012 at 01:58:22PM +0800, Amos Kong wrote:
>> On 11/09/12 22:31, Fengguang Wu wrote:
>> >Hi Avi,
>> >
>> >In the kvm/next branch, sparse warns about
>> >
>> >arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_regs' 9 <= 15
>> >
>> >This is because the array definition is ctxt._regs[NR_VCPU_REGS] where
>> >NR_VCPU_REGS=9 for i386 and 17 for x86_64.
>> >
>> >It could be fixed by changing the hard coded 16 to (NR_VCPU_REGS-1).
>>
>> Hi Fengguang,
>>
>> You replaced 16 to NR_VCPU_REGS in your patch, not (NR_VCPU_REGS-1).
>> I guess it's a mistake in your commitlog, right?
>
> 16 = (NR_VCPU_REGS-1). So I mean, if replacing 16 with (NR_VCPU_REGS-1),
> there will be no behavior change for the x86_64 case. However I
> *suspect* the right value is (NR_VCPU_REGS), as I said in the below
> sentence.
>
>> >And I wonder whether you actually want NR_VCPU_REGS here?
>
> For your convenience, here is the relevant code for NR_VCPU_REGS:
>
> enum kvm_reg {
> VCPU_REGS_RAX = 0,
> VCPU_REGS_RCX = 1,
> VCPU_REGS_RDX = 2,
> VCPU_REGS_RBX = 3,
> VCPU_REGS_RSP = 4,
> VCPU_REGS_RBP = 5,
> VCPU_REGS_RSI = 6,
> VCPU_REGS_RDI = 7,
> #ifdef CONFIG_X86_64
> VCPU_REGS_R8 = 8,
> VCPU_REGS_R9 = 9,
> VCPU_REGS_R10 = 10,
> VCPU_REGS_R11 = 11,
> VCPU_REGS_R12 = 12,
> VCPU_REGS_R13 = 13,
> VCPU_REGS_R14 = 14,
> VCPU_REGS_R15 = 15,
> #endif
> VCPU_REGS_RIP,
> => NR_VCPU_REGS
> };
The right value is NR-1, since the loop excludes RIP.
Note the warning does not point to an actual error, since the high bits
of regs_dirty will be clear on i386.
--
error compiling committee.c: too many arguments to function
prev parent reply other threads:[~2012-09-12 7:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 14:31 [kvm:next 1/1] arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_regs' Fengguang Wu
2012-09-12 5:58 ` [kvm:next 1/1] arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_r Amos Kong
2012-09-12 6:07 ` Fengguang Wu
2012-09-12 7:37 ` Avi Kivity [this message]
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=50503BD4.7090604@redhat.com \
--to=avi@redhat.com \
--cc=akong@redhat.com \
--cc=fengguang.wu@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.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