From owner-svn-src-head@freebsd.org  Thu Jan  5 17:22:10 2017
Return-Path: <owner-svn-src-head@freebsd.org>
Delivered-To: svn-src-head@mailman.ysv.freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org
 [IPv6:2001:1900:2254:206a::19:1])
 by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7370CCA1CEE;
 Thu,  5 Jan 2017 17:22:10 +0000 (UTC)
 (envelope-from hiren@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 mx1.freebsd.org (Postfix) with ESMTPS id 429381FCC;
 Thu,  5 Jan 2017 17:22:10 +0000 (UTC)
 (envelope-from hiren@FreeBSD.org)
Received: from repo.freebsd.org ([127.0.1.37])
 by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v05HM9GH098700;
 Thu, 5 Jan 2017 17:22:09 GMT (envelope-from hiren@FreeBSD.org)
Received: (from hiren@localhost)
 by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05HM9LM098699;
 Thu, 5 Jan 2017 17:22:09 GMT (envelope-from hiren@FreeBSD.org)
Message-Id: <201701051722.v05HM9LM098699@repo.freebsd.org>
X-Authentication-Warning: repo.freebsd.org: hiren set sender to
 hiren@FreeBSD.org using -f
From: Hiren Panchasara <hiren@FreeBSD.org>
Date: Thu, 5 Jan 2017 17:22:09 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
 svn-src-head@freebsd.org
Subject: svn commit: r311453 - head/sys/netinet
X-SVN-Group: head
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BeenThere: svn-src-head@freebsd.org
X-Mailman-Version: 2.1.23
Precedence: list
List-Id: SVN commit messages for the src tree for head/-current
 <svn-src-head.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-head/>
List-Post: <mailto:svn-src-head@freebsd.org>
List-Help: <mailto:svn-src-head-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/svn-src-head>,
 <mailto:svn-src-head-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 05 Jan 2017 17:22:10 -0000

Author: hiren
Date: Thu Jan  5 17:22:09 2017
New Revision: 311453
URL: https://svnweb.freebsd.org/changeset/base/311453

Log:
  sysctl net.inet.tcp.hostcache.list in a jail can see connections from other
  jails and the host. This commit fixes it.
  
  PR:		200361
  Submitted by:	bz (original version), hiren (minor corrections)
  Reported by:	Marcus Reid <marcus at blazingdot dot com>
  Reviewed by:	bz, gnn
  Tested by:	Lohith Bellad <lohithbsd at gmail dot com>
  MFC after:	1 week
  Sponsored by:	Limelight Networks (minor corrections)

Modified:
  head/sys/netinet/tcp_hostcache.c

Modified: head/sys/netinet/tcp_hostcache.c
==============================================================================
--- head/sys/netinet/tcp_hostcache.c	Thu Jan  5 17:19:26 2017	(r311452)
+++ head/sys/netinet/tcp_hostcache.c	Thu Jan  5 17:22:09 2017	(r311453)
@@ -69,10 +69,12 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/jail.h>
 #include <sys/kernel.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/malloc.h>
+#include <sys/proc.h>
 #include <sys/sbuf.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
@@ -625,6 +627,9 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
 	char ip6buf[INET6_ADDRSTRLEN];
 #endif
 
+	if (jailed_without_vnet(curthread->td_ucred) != 0)
+		return (EPERM);
+
 	sbuf_new(&sb, NULL, linesize * (V_tcp_hostcache.cache_count + 1),
 		SBUF_INCLUDENUL);