Module Name:    src
Committed By:   maxv
Date:           Thu May  3 16:52:42 UTC 2018

Modified Files:
        src/sys/net: if_pppoe.c

Log Message:
Drop early if there's no PPPoE interface. Otherwise it is easy for someone
to flood dmesg over the local subnet.


To generate a diff of this commit:
cvs rdiff -u -r1.136 -r1.137 src/sys/net/if_pppoe.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.136 src/sys/net/if_pppoe.c:1.137
--- src/sys/net/if_pppoe.c:1.136	Wed Apr 18 07:40:40 2018
+++ src/sys/net/if_pppoe.c	Thu May  3 16:52:42 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.136 2018/04/18 07:40:40 knakahara Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.137 2018/05/03 16:52:42 maxv Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.136 2018/04/18 07:40:40 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.137 2018/05/03 16:52:42 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "pppoe.h"
@@ -944,13 +944,16 @@ done:
 static void
 pppoe_disc_input(struct mbuf *m)
 {
+	KASSERT(m->m_flags & M_PKTHDR);
 
-	/* avoid error messages if there is not a single pppoe instance */
+	/*
+	 * Avoid error messages if there is not a single PPPoE instance.
+	 */
 	if (!LIST_EMPTY(&pppoe_softc_list)) {
-		KASSERT(m->m_flags & M_PKTHDR);
 		pppoe_dispatch_disc_pkt(m, 0);
-	} else
+	} else {
 		m_freem(m);
+	}
 }
 
 static bool
@@ -977,6 +980,13 @@ pppoe_data_input(struct mbuf *m)
 
 	KASSERT(m->m_flags & M_PKTHDR);
 
+	/*
+	 * Avoid error messages if there is not a single PPPoE instance.
+	 */
+	if (LIST_EMPTY(&pppoe_softc_list)) {
+		goto drop;
+	}
+
 	if (term_unknown) {
 		memcpy(shost, mtod(m, struct ether_header*)->ether_shost,
 		    ETHER_ADDR_LEN);

Reply via email to