Skip to content

netstack/ipv4: drop TTL=1 packets instead of forwarding with TTL=0#13521

Open
TristanInSec wants to merge 1 commit into
google:masterfrom
TristanInSec:fix-ipv4-ttl1-forwarding
Open

netstack/ipv4: drop TTL=1 packets instead of forwarding with TTL=0#13521
TristanInSec wants to merge 1 commit into
google:masterfrom
TristanInSec:fix-ipv4-ttl1-forwarding

Conversation

@TristanInSec

Copy link
Copy Markdown

The TTL check in forwardUnicastPacket uses ttl == 0, so packets arriving with TTL=1 pass the check, get decremented to TTL=0 in forwardPacketWithRoute, and are forwarded with a zero TTL. There is no post-decrement TTL check.

Linux ip_forward() checks ip_hdr(skb)->ttl <= 1 before forwarding, which correctly drops TTL=1 packets and sends ICMP Time Exceeded.

This changes the pre-decrement check from ttl == 0 to ttl <= 1 so that packets that would reach zero after the mandatory decrement are dropped with an ICMP Time Exceeded response.

The TTL check in forwardUnicastPacket uses ttl == 0, so packets
arriving with TTL=1 pass the check, get decremented to TTL=0 in
forwardPacketWithRoute, and are forwarded with a zero TTL. There
is no post-decrement TTL check.

Linux ip_forward() checks ip_hdr(skb)->ttl <= 1 before forwarding,
which correctly drops TTL=1 packets and sends ICMP Time Exceeded.

Change the pre-decrement check from ttl == 0 to ttl <= 1 so that
packets that would reach zero after the mandatory decrement are
dropped with an ICMP Time Exceeded response.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant