From owner-svn-src-all@freebsd.org Tue Jan 28 22:46:52 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0FF85244926; Tue, 28 Jan 2020 22:46:52 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 486hZ36jn8z3H9X; Tue, 28 Jan 2020 22:46:51 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E1BED25AA; Tue, 28 Jan 2020 22:46:51 +0000 (UTC) (envelope-from kp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00SMkpVr077620; Tue, 28 Jan 2020 22:46:51 GMT (envelope-from kp@FreeBSD.org) Received: (from kp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00SMkpQN077618; Tue, 28 Jan 2020 22:46:51 GMT (envelope-from kp@FreeBSD.org) Message-Id: <202001282246.00SMkpQN077618@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kp set sender to kp@FreeBSD.org using -f From: Kristof Provost Date: Tue, 28 Jan 2020 22:46:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357234 - head/tests/sys/net X-SVN-Group: head X-SVN-Commit-Author: kp X-SVN-Commit-Paths: head/tests/sys/net X-SVN-Commit-Revision: 357234 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jan 2020 22:46:52 -0000 Author: kp Date: Tue Jan 28 22:46:51 2020 New Revision: 357234 URL: https://svnweb.freebsd.org/changeset/base/357234 Log: 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 MFC after: 3 days Added: head/tests/sys/net/if_epair.c (contents, props changed) Modified: head/tests/sys/net/Makefile Modified: head/tests/sys/net/Makefile ============================================================================== --- head/tests/sys/net/Makefile Tue Jan 28 22:44:24 2020 (r357233) +++ head/tests/sys/net/Makefile Tue Jan 28 22:46:51 2020 (r357234) @@ -9,6 +9,7 @@ ATF_TESTS_SH+= if_lagg_test ATF_TESTS_SH+= if_clone_test ATF_TESTS_SH+= if_tun_test ATF_TESTS_SH+= if_vlan +ATF_TESTS_C+= if_epair TESTS_SUBDIRS+= routing @@ -18,7 +19,7 @@ TESTS_SUBDIRS+= routing TEST_METADATA+= is_exclusive=true MAN= -PROG= randsleep +PROGS+= randsleep WARNS?= 6 Added: head/tests/sys/net/if_epair.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tests/sys/net/if_epair.c Tue Jan 28 22:46:51 2020 (r357234) @@ -0,0 +1,73 @@ +/*- + * Copyright (c) 2020 Kristof Provost + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include + +ATF_TC(params); +ATF_TC_HEAD(params, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); +} + +ATF_TC_BODY(params, tc) +{ + struct ifreq ifr; + int s; + + s = kldload("if_epair"); + if (s != 0) + atf_tc_fail("Failed to load if_epair"); + + s = socket(AF_INET, SOCK_DGRAM, 0); + if (s < 0) + atf_tc_fail("Failed to create socket"); + + bzero(&ifr, sizeof(ifr)); + ifr.ifr_data = (caddr_t)-1; + (void) strlcpy(ifr.ifr_name, "epair", sizeof(ifr.ifr_name)); + + ioctl(s, SIOCIFCREATE2, &ifr); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, params); + + return (atf_no_error()); +}