diff options
author | Mark Johnston <markj@FreeBSD.org> | 2021-07-26 20:39:18 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2021-08-02 19:01:54 +0000 |
commit | 14a06b083b56572868f82759f5f74d17523e8afa (patch) | |
tree | 6f66633b144b9a69689fe0b2f4c2ff306ec0394f | |
parent | ef87250124b12216c4e8e608d73008ca13448cba (diff) | |
download | src-14a06b083b56572868f82759f5f74d17523e8afa.tar.gz src-14a06b083b56572868f82759f5f74d17523e8afa.zip |
rip: Add missing minimum length validation in rip_output()
If the socket is configured such that the sender is expected to supply
the IP header, then we need to verify that it actually did so.
Reported by: syzkaller+KMSAN
Reviewed by: donner
Sponsored by: The FreeBSD Foundation
(cherry picked from commit ba21825202737a8b7e90e1ef669c7fe7e7d50325)
-rw-r--r-- | sys/netinet/raw_ip.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 1fd621a068f4..f15a3bca3a90 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -508,8 +508,15 @@ rip_output(struct mbuf *m, struct socket *so, ...) } else { if (m->m_pkthdr.len > IP_MAXPACKET) { m_freem(m); - return(EMSGSIZE); + return (EMSGSIZE); } + if (m->m_pkthdr.len < sizeof(*ip)) { + m_freem(m); + return (EINVAL); + } + m = m_pullup(m, sizeof(*ip)); + if (m == NULL) + return (ENOMEM); ip = mtod(m, struct ip *); hlen = ip->ip_hl << 2; if (m->m_len < hlen) { |