From: Fengguang Wu <fengguang.wu@intel.com>
To: Avi Kivity <avi@redhat.com>
Cc: kernel-janitors@vger.kernel.org, kvm@vger.kernel.org
Subject: [kvm:next 1/1] arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_regs' 9 <= 15
Date: Tue, 11 Sep 2012 22:31:36 +0800 [thread overview]
Message-ID: <20120911143136.GA5736@localhost> (raw)
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).
And I wonder whether you actually want NR_VCPU_REGS here?
Thanks,
Fengguang
---
--- linux-next.orig/arch/x86/kvm/emulate.c 2012-09-11 20:14:00.537475301 +0800
+++ linux-next/arch/x86/kvm/emulate.c 2012-09-11 22:21:57.569227558 +0800
@@ -228,7 +228,7 @@ static void writeback_registers(struct x
{
unsigned reg;
- for_each_set_bit(reg, (ulong *)&ctxt->regs_dirty, 16)
+ for_each_set_bit(reg, (ulong *)&ctxt->regs_dirty, NR_VCPU_REGS)
ctxt->ops->write_gpr(ctxt, reg, ctxt->_regs[reg]);
}
next reply other threads:[~2012-09-11 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-11 14:31 Fengguang Wu [this message]
2012-09-12 5:58 ` [kvm:next 1/1] arch/x86/kvm/emulate.c:232 writeback_registers() error: buffer overflow 'ctxt->_regs' 9 <= 15 Amos Kong
2012-09-12 6:07 ` Fengguang Wu
2012-09-12 7:37 ` Avi Kivity
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=20120911143136.GA5736@localhost \
--to=fengguang.wu@intel.com \
--cc=avi@redhat.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;
as well as URLs for NNTP newsgroup(s).