Thread (11 messages) 11 messages, 3 authors, 2013-09-25

Re: [PATCH] powerpc/kvm: Handle the boundary condition correctly

From: Alexander Graf <hidden>
Date: 2013-08-25 18:16:14

On 23.08.2013, at 04:31, Aneesh Kumar K.V wrote:
Alexander Graf [off-list ref] writes:
=20
quoted
On 22.08.2013, at 12:37, Aneesh Kumar K.V wrote:
=20
quoted
From: "Aneesh Kumar K.V" <redacted>
=20
Isn't this you?
=20
Yes. The patches are generated using git format-patch and sent by
git send-email. That's how it always created patches for me. I am not =
sure if
there is a config I can change to avoid having From:
=20
quoted
=20
quoted
=20
We should be able to copy upto count bytes
=20
Why?
=20
=20
Without this we end up doing
=20
+    struct kvm_get_htab_buf {
+        struct kvm_get_htab_header header;
+        /*
+         * Older kernel required one extra byte.
+         */
+        unsigned long hpte[3];
+    } hpte_buf;
=20
=20
even though we are only looking for one hpte entry.
Ok, please give me an example with real numbers and why it breaks.


Alex
=20
=
http://mid.gmane.org/1376995766-16526-4-git-send-email-aneesh.kumar@linux.=
vnet.ibm.com
=20
quoted
=20
Alex
=20
quoted
=20
Signed-off-by: Aneesh Kumar K.V <redacted>
---
arch/powerpc/kvm/book3s_64_mmu_hv.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
=20
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c =
b/arch/powerpc/kvm/book3s_64_mmu_hv.c
quoted
quoted
index 710d313..0ae6bb6 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -1362,7 +1362,7 @@ static ssize_t kvm_htab_read(struct file =
*file, char __user *buf,
quoted
quoted
	lbuf =3D (unsigned long __user *)buf;
=20
	nb =3D 0;
-	while (nb + sizeof(hdr) + HPTE_SIZE < count) {
+	while (nb + sizeof(hdr) + HPTE_SIZE <=3D count) {
		/* Initialize header */
		hptr =3D (struct kvm_get_htab_header __user *)buf;
		hdr.n_valid =3D 0;
@@ -1385,7 +1385,7 @@ static ssize_t kvm_htab_read(struct file =
*file, char __user *buf,
quoted
quoted
		/* Grab a series of valid entries */
		while (i < kvm->arch.hpt_npte &&
		       hdr.n_valid < 0xffff &&
-		       nb + HPTE_SIZE < count &&
+		       nb + HPTE_SIZE <=3D count &&
		       record_hpte(flags, hptp, hpte, revp, 1, =
first_pass)) {
quoted
quoted
			/* valid entry, write it out */
			++hdr.n_valid;
--=20
1.8.1.2
=20
=20
--
To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help