kern/55886: mbuf exhaustion can cause panic

Robert Watson rwatson at FreeBSD.org
Mon Aug 25 12:53:16 PDT 2003


Try the attached patch for -CURRENT, or variation on -STABLE.  Basically,
M_PREPEND() can fail leaving (m == NULL) even with M_TRYWAIT.  Most
consumers of M_PREPEND seem to know that.  Raw IP output seems not to.

Robert N M Watson             FreeBSD Core Team, TrustedBSD Projects
robert at fledge.watson.org      Network Associates Laboratories

Index: raw_ip.c
===================================================================
RCS file: /data/fbsd-cvs/ncvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.114
diff -u -r1.114 raw_ip.c
--- raw_ip.c	20 Aug 2003 14:46:40 -0000	1.114
+++ raw_ip.c	25 Aug 2003 19:50:07 -0000
@@ -288,6 +288,8 @@
 			return(EMSGSIZE);
 		}
 		M_PREPEND(m, sizeof(struct ip), M_TRYWAIT);
+		if (m == NULL)
+			return(ENOBUFS);
 		ip = mtod(m, struct ip *);
 		ip->ip_tos = inp->inp_ip_tos;
 		ip->ip_off = 0;



More information about the freebsd-bugs mailing list