Open awelzel opened 3 years ago
Well, we may argue that it is indeed not ip, since it is malformed. Maybe we may just add a if (iph->ip_hl < 5 || iph->ip_hl * 4 > iph->ip_len) return 0;
at the beginning of the function. Objections?
@giuseppelettieri , I've created an MR with you suggestion.
It might be nice to also add validation to stay within the bounds of the given packet being looked at, but that would be a fairly intrusive change.
Hello @giuseppelettieri and others,
we've observed
lb
spinning at 100% CPU (or crashing - depending on the optimization level) when hashing IP-IP packets with a IP header length set to 0.Find attached a single packet pcap that reproduces the issue (tested with FreeBSD 13 and Linux VMs).
The following netsniff-ng trafgen command creates a pcap that can be used for reproduction (seems I can't attach a pcap..):
Steps for reproducing, start
lb
and replay single packet.Other terminal:
When compiled without optimizations,
lb
crashes due to a stack overflow. When compile with-O2
as the default, it is spinning at 100% due to endless-tail-recursion indecode_ip_n_hash
.We've applied the following minimum patch. It produces
0
for such packets has hash, but also counts them as non-ip which is a bit unfortuante.Happy to open an MR, but wondering if you have other/better fixes in mind.