summaryrefslogtreecommitdiffstats
path: root/sys/netinet6
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-12-05 15:52:27 -0200
committerRenato Botelho <renato@netgate.com>2016-12-05 15:52:27 -0200
commitec84a59afa973e7e021ba2ae8ecae4cb6ba37b1d (patch)
treed7d40ac77bda3d6fc35814a1a6484eb324b3c7df /sys/netinet6
parentca825f0a56d174ca9d3478d87cdca9f318a50cc6 (diff)
parent356fbc072920d7e71c42b310d6bfa2d1a3d36f9f (diff)
downloadFreeBSD-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.c15
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;
OpenPOWER on IntegriCloud