svn commit: r357489 - stable/11/tests/sys/net

Kristof Provost kp at FreeBSD.org
Tue Feb 4 04:29:54 UTC 2020


Author: kp
Date: Tue Feb  4 04:29:53 2020
New Revision: 357489
URL: https://svnweb.freebsd.org/changeset/base/357489

Log:
  MFC r357234, r357365, r357375:
  
  tests: Test for an epair panic
  
  if_epair abused the ifr_data field to insert its second interface in
  IFC_IFLIST. If userspace provides a value for ifr_data it would get
  dereferenced by the kernel leading to a panic.
  
  Reported by:	Ilja Van Sprundel <ivansprundel at ioactive.com>

Added:
  stable/11/tests/sys/net/if_epair.c
     - copied, changed from r357234, head/tests/sys/net/if_epair.c
Modified:
  stable/11/tests/sys/net/Makefile
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/net/Makefile
==============================================================================
--- stable/11/tests/sys/net/Makefile	Tue Feb  4 03:31:28 2020	(r357488)
+++ stable/11/tests/sys/net/Makefile	Tue Feb  4 04:29:53 2020	(r357489)
@@ -7,6 +7,7 @@ BINDIR=		${TESTSDIR}
 
 ATF_TESTS_SH+=	if_lagg_test
 ATF_TESTS_SH+=	if_clone_test
+ATF_TESTS_C+=	if_epair
 
 # The tests are written to be run in parallel, but doing so leads to random
 # panics.  I think it's because the kernel's list of interfaces isn't properly
@@ -14,7 +15,7 @@ ATF_TESTS_SH+=	if_clone_test
 TEST_METADATA+=	is_exclusive=true
 
 MAN=
-PROG=		randsleep
+PROGS+=		randsleep
 
 WARNS?=		6
 

Copied and modified: stable/11/tests/sys/net/if_epair.c (from r357234, head/tests/sys/net/if_epair.c)
==============================================================================
--- head/tests/sys/net/if_epair.c	Tue Jan 28 22:46:51 2020	(r357234, copy source)
+++ stable/11/tests/sys/net/if_epair.c	Tue Feb  4 04:29:53 2020	(r357489)
@@ -25,17 +25,19 @@
  * $FreeBSD$
  */
 
+#include <sys/param.h>
 #include <sys/ioctl.h>
 #include <sys/linker.h>
 #include <sys/module.h>
-#include <sys/param.h>
 #include <sys/socket.h>
 #include <sys/types.h>
 
 #include <net/if.h>
 
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
+#include <strings.h>
 
 #include <atf-c.h>
 
@@ -51,7 +53,7 @@ ATF_TC_BODY(params, tc)
 	int s;
 
 	s = kldload("if_epair");
-	if (s != 0)
+	if (s == -1 && errno != EEXIST)
 		atf_tc_fail("Failed to load if_epair");
 
 	s = socket(AF_INET, SOCK_DGRAM, 0);


More information about the svn-src-all mailing list