diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 66ddcb60519a16..dcdd5aed7eb1b1 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -662,6 +662,10 @@ int ping_common_sendmsg(int family, struct msghdr *msg, size_t len, if (len > 0xFFFF) return -EMSGSIZE; + /* Must have at least a full ICMP header. */ + if (len < icmph_len) + return -EINVAL; + /* * Check the flags. */