Validate an icmp header before accessing it

A header can't be smaller than header.ICMPv4MinimumSize.

Reported-by: syzbot+57b68b14b4f6a58bf985@syzkaller.appspotmail.com
PiperOrigin-RevId: 405748438
This commit is contained in:
Andrei Vagin
2021-10-26 15:23:34 -07:00
committed by gVisor bot
parent 722d7ca744
commit f54a25c1f0
+4
View File
@@ -572,6 +572,10 @@ func (p *protocol) returnError(reason icmpReason, pkt *stack.PacketBuffer) tcpip
// if problems arise this could be reversed. It was judged less of a breach
// of protocol to not respond to unknown non-error packets than to respond
// to unknown error packets so we take the first approach.
if len(transportHeader) < header.ICMPv4MinimumSize {
// The packet is malformed.
return nil
}
switch header.ICMPv4(transportHeader).Type() {
case
header.ICMPv4EchoReply,