diff options
author | Renato Botelho <renato@netgate.com> | 2016-12-05 15:52:27 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-12-05 15:52:27 -0200 |
commit | ec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d (patch) | |
tree | d7d40ac77bda3d6fc35814a1a6484eb324b3c7df /sys/netinet6 | |
parent | ca825f0a56d174ca9d3478d87cdca9f318a50cc6 (diff) | |
parent | 356fbc072920d7e71c42b310d6bfa2d1a3d36f9f (diff) | |
download | FreeBSD-src-ec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d.zip FreeBSD-src-ec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d.tar.gz |
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'sys/netinet6')
-rw-r--r-- | sys/netinet6/ip6_output.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 2b0e50d..2674f8a 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1398,6 +1398,15 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) int retval; #endif +/* + * Don't use more than a quarter of mbuf clusters. N.B.: + * nmbclusters is an int, but nmbclusters * MCLBYTES may overflow + * on LP64 architectures, so cast to u_long to avoid undefined + * behavior. ILP32 architectures cannot have nmbclusters + * large enough to overflow for other reasons. + */ +#define IPV6_PKTOPTIONS_MBUF_LIMIT ((u_long)nmbclusters * MCLBYTES / 4) + level = sopt->sopt_level; op = sopt->sopt_dir; optname = sopt->sopt_name; @@ -1453,6 +1462,12 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt) { struct mbuf *m; + if (optlen > IPV6_PKTOPTIONS_MBUF_LIMIT) { + printf("ip6_ctloutput: mbuf limit hit\n"); + error = ENOBUFS; + break; + } + error = soopt_getm(sopt, &m); /* XXX */ if (error != 0) break; |