From: Matthew Daley <mattjd@gmail.com>
To: JBeulich@suse.com
Cc: Matthew Daley <mattjd@gmail.com>, xen-devel@lists.xen.org
Subject: [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check
Date: Tue, 13 Nov 2012 23:17:46 +1300 [thread overview]
Message-ID: <1352801866-9512-1-git-send-email-mattjd@gmail.com> (raw)
In-Reply-To: <50A214B902000078000A7F88@nat28.tlf.novell.com>
xenctl_cpumap_to_cpumask incorrectly uses sizeof when checking whether
bits should be masked off from the input cpumap bitmap or not.
Fix and make clearer by simply comparing the amount of bytes given in
the input cpumap to the amount actually copied; if equal, bits may need
to be masked off.
This does not have security impact: _xmalloc never returns allocations
smaller than the size of a pointer, hence the uncorrected buffer size
check would still not allow writes to unallocated memory.
Signed-off-by: Matthew Daley <mattjd@gmail.com>
---
Jan: Agreed with both of your points. Here's a v2.
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index e153cb4..a7a6b9f 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -78,7 +78,7 @@ int xenctl_cpumap_to_cpumask(
{
if ( copy_from_guest(bytemap, xenctl_cpumap->bitmap, copy_bytes) )
err = -EFAULT;
- if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes <= sizeof(bytemap)) )
+ if ( (xenctl_cpumap->nr_cpus & 7) && (guest_bytes == copy_bytes) )
bytemap[guest_bytes-1] &= ~(0xff << (xenctl_cpumap->nr_cpus & 7));
}
--
1.7.10.4
next prev parent reply other threads:[~2012-11-13 10:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-13 6:04 [PATCH] xen: Fix xenctl_cpumap_to_cpumask buffer size check Matthew Daley
2012-11-13 8:36 ` Jan Beulich
2012-11-13 10:10 ` Keir Fraser
2012-11-13 10:17 ` Matthew Daley [this message]
2012-11-13 10:58 ` Keir Fraser
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=1352801866-9512-1-git-send-email-mattjd@gmail.com \
--to=mattjd@gmail.com \
--cc=JBeulich@suse.com \
--cc=xen-devel@lists.xen.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).