From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@kernel.org
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
gorcunov@gmail.com, Sasha Levin <levinsasha928@gmail.com>,
Alessandro Zummo <a.zummo@towertech.it>,
rtc-linux@googlegroups.com
Subject: [PATCH 3/3] kvm tools: Add boundry check for rtc cmos index
Date: Tue, 29 Nov 2011 10:35:35 +0200 [thread overview]
Message-ID: <1322555735-32163-3-git-send-email-levinsasha928@gmail.com> (raw)
In-Reply-To: <1322555735-32163-1-git-send-email-levinsasha928@gmail.com>
A guest could overwrite host memory by writing to cmos index bigger than 128.
This patch adds a boundry check to limit it to that size.
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: rtc-linux@googlegroups.com
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
tools/kvm/hw/rtc.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/tools/kvm/hw/rtc.c b/tools/kvm/hw/rtc.c
index fad140f..1471521 100644
--- a/tools/kvm/hw/rtc.c
+++ b/tools/kvm/hw/rtc.c
@@ -50,6 +50,8 @@ static bool cmos_ram_data_in(struct ioport *ioport, struct kvm *kvm, u16 port, v
ioport__write8(data, bin2bcd(tm->tm_year));
break;
default:
+ if (rtc.cmos_idx >= 128)
+ break;
ioport__write8(data, rtc.cmos_data[rtc.cmos_idx]);
break;
}
@@ -65,6 +67,8 @@ static bool cmos_ram_data_out(struct ioport *ioport, struct kvm *kvm, u16 port,
/* Read-only */
break;
default:
+ if (rtc.cmos_idx >= 128)
+ break;
rtc.cmos_data[rtc.cmos_idx] = ioport__read8(data);
break;
}
--
1.7.8.rc3
next prev parent reply other threads:[~2011-11-29 8:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-29 8:35 [PATCH 1/3] rtc: Allow including mc146818 rtc header from userspace Sasha Levin
2011-11-29 8:35 ` [PATCH 2/3] kvm tools: Include RTC headers directly Sasha Levin
2011-11-29 8:35 ` Sasha Levin [this message]
2011-11-29 13:07 ` [PATCH 3/3] kvm tools: Add boundry check for rtc cmos index Pekka Enberg
2011-11-29 20:11 ` Sasha Levin
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=1322555735-32163-3-git-send-email-levinsasha928@gmail.com \
--to=levinsasha928@gmail.com \
--cc=a.zummo@towertech.it \
--cc=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=rtc-linux@googlegroups.com \
/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