[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[win-pv-devel] [PATCH 3/3] Avoid incorrecly extending checksum accumulator



It was noticed that checksums were occasionally being incorrectly verified.
The reason for this turned out to be that the value passed to
ChecksumVerify as a USHORT was being extended to ULONG prior to being
inverted, thus leaving bits 16-31 set and thus an overflow from the lower
bits was not being correctly folded.

Signed-off-by: Ben Chalmers <ben.chalmers@xxxxxxxxxx>
Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvif/checksum.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/xenvif/checksum.c b/src/xenvif/checksum.c
index 5f9c800..19a9616 100644
--- a/src/xenvif/checksum.c
+++ b/src/xenvif/checksum.c
@@ -87,6 +87,12 @@ ChecksumVerify(
 {
     ULONG       Accumulator = ~Calculated;
 
+    // 
+    // MSVC extends Calculated to ULONG prior to inverting it
+    // so we must explicitly zero out the upper half
+    //
+    Accumulator &= 0xFFFF;
+
     // See RFC 1624, section 5
     __AccumulateChecksum(&Accumulator, (PUCHAR)&Embedded, sizeof (USHORT));
 
-- 
2.1.1


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.