From owner-svn-src-stable@FreeBSD.ORG Fri Oct 25 16:36:17 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 9EB30E32; Fri, 25 Oct 2013 16:36:17 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 71AED2259; Fri, 25 Oct 2013 16:36:17 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9PGaHHW037213; Fri, 25 Oct 2013 16:36:17 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9PGaHT6037211; Fri, 25 Oct 2013 16:36:17 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201310251636.r9PGaHT6037211@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 25 Oct 2013 16:36:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r257123 - in stable/10/sys: kern sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2013 16:36:17 -0000 Author: kib Date: Fri Oct 25 16:36:16 2013 New Revision: 257123 URL: http://svnweb.freebsd.org/changeset/base/257123 Log: MFC r256504: Add a sysctl kern.disallow_high_osrel which disables executing the images compiled on the world with higher major version number than the high version number of the booted kernel. Default to disable. Approved by: re (glebius) Modified: stable/10/sys/kern/kern_exec.c stable/10/sys/sys/param.h Directory Properties: stable/10/sys/ (props changed) Modified: stable/10/sys/kern/kern_exec.c ============================================================================== --- stable/10/sys/kern/kern_exec.c Fri Oct 25 16:33:24 2013 (r257122) +++ stable/10/sys/kern/kern_exec.c Fri Oct 25 16:36:16 2013 (r257123) @@ -123,6 +123,11 @@ u_long ps_arg_cache_limit = PAGE_SIZE / SYSCTL_ULONG(_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW, &ps_arg_cache_limit, 0, ""); +static int disallow_high_osrel; +SYSCTL_INT(_kern, OID_AUTO, disallow_high_osrel, CTLFLAG_RW, + &disallow_high_osrel, 0, + "Disallow execution of binaries built for higher version of the world"); + static int map_at_zero = 0; TUNABLE_INT("security.bsd.map_at_zero", &map_at_zero); SYSCTL_INT(_security_bsd, OID_AUTO, map_at_zero, CTLFLAG_RW, &map_at_zero, 0, @@ -552,6 +557,15 @@ interpret: vn_fullpath(td, imgp->vp, &imgp->execpath, &imgp->freepath) != 0)) imgp->execpath = args->fname; + if (disallow_high_osrel && + P_OSREL_MAJOR(p->p_osrel) > P_OSREL_MAJOR(__FreeBSD_version)) { + error = ENOEXEC; + uprintf("Osrel %d for image %s too high\n", p->p_osrel, + imgp->execpath != NULL ? imgp->execpath : ""); + vn_lock(imgp->vp, LK_SHARED | LK_RETRY); + goto exec_fail_dealloc; + } + /* * Copy out strings (args and env) and initialize stack base */ Modified: stable/10/sys/sys/param.h ============================================================================== --- stable/10/sys/sys/param.h Fri Oct 25 16:33:24 2013 (r257122) +++ stable/10/sys/sys/param.h Fri Oct 25 16:36:16 2013 (r257123) @@ -80,6 +80,8 @@ #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004 #define P_OSREL_MAP_ANON 800104 + +#define P_OSREL_MAJOR(x) ((x) / 100000) #endif #ifndef LOCORE