driver: do not allow compiler to reload PacketSize

In theory, the compiler could reload PacketSize after the bounds check
but before it's passed to NdisAllocateNetBufferAndNetBufferList. In
practice, it's not actually doing that, but better safe than sorry.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-11-09 22:21:12 +01:00
parent 0f6296516a
commit 87ef399d1c

View File

@ -483,7 +483,7 @@ TunProcessReceiveData(_Inout_ TUN_CTX *Ctx)
break;
TUN_PACKET *Packet = (TUN_PACKET *)(Ring->Data + RingHead);
ULONG PacketSize = Packet->Size;
ULONG PacketSize = *(volatile ULONG *)&Packet->Size;
if (PacketSize > TUN_MAX_IP_PACKET_SIZE)
break;