From owner-svn-src-all@freebsd.org Fri May 17 18:09:50 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D2C67159C425; Fri, 17 May 2019 18:09:49 +0000 (UTC) (envelope-from stevek@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 481228664C; Fri, 17 May 2019 18:09:49 +0000 (UTC) (envelope-from stevek@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 1CB6EBF3E; Fri, 17 May 2019 18:09:49 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x4HI9mrW091345; Fri, 17 May 2019 18:09:48 GMT (envelope-from stevek@FreeBSD.org) Received: (from stevek@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x4HI9m8B091344; Fri, 17 May 2019 18:09:48 GMT (envelope-from stevek@FreeBSD.org) Message-Id: <201905171809.x4HI9m8B091344@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: stevek set sender to stevek@FreeBSD.org using -f From: "Stephen J. Kiernan" Date: Fri, 17 May 2019 18:09:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r347936 - head/sys/security/mac_veriexec X-SVN-Group: head X-SVN-Commit-Author: stevek X-SVN-Commit-Paths: head/sys/security/mac_veriexec X-SVN-Commit-Revision: 347936 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 481228664C X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.950,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] 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: Fri, 17 May 2019 18:09:50 -0000 Author: stevek Date: Fri May 17 18:09:48 2019 New Revision: 347936 URL: https://svnweb.freebsd.org/changeset/base/347936 Log: sysctls which should be restricted when securelevel is raised should also be restricted when veriexec is enforced. Add mpo_system_check_sysctl method to mac_veriexec which does this. Obtained from: Juniper Networks, Inc. MFC after: 1 week Modified: head/sys/security/mac_veriexec/mac_veriexec.c Modified: head/sys/security/mac_veriexec/mac_veriexec.c ============================================================================== --- head/sys/security/mac_veriexec/mac_veriexec.c Fri May 17 18:06:24 2019 (r347935) +++ head/sys/security/mac_veriexec/mac_veriexec.c Fri May 17 18:09:48 2019 (r347936) @@ -1,7 +1,7 @@ /* * $FreeBSD$ * - * Copyright (c) 2011, 2012, 2013, 2015, 2016, Juniper Networks, Inc. + * Copyright (c) 2011, 2012, 2013, 2015, 2016, 2019 Juniper Networks, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -424,6 +424,23 @@ mac_veriexec_priv_check(struct ucred *cred, int priv) return (0); } +static int +mac_veriexec_sysctl_check(struct ucred *cred, struct sysctl_oid *oidp, + void *arg1, int arg2, struct sysctl_req *req) +{ + struct sysctl_oid *oid; + + /* If we are not enforcing veriexec, nothing for us to check */ + if ((mac_veriexec_state & VERIEXEC_STATE_ENFORCE) == 0) + return (0); + + oid = oidp; + if (oid->oid_kind & CTLFLAG_SECURE) { + return (EPERM); /* XXX call mac_veriexec_priv_check? */ + } + return 0; +} + /** * @internal * @brief A program is being executed and needs to be validated. @@ -700,12 +717,13 @@ cleanup_file: static struct mac_policy_ops mac_veriexec_ops = { .mpo_init = mac_veriexec_init, - .mpo_syscall = mac_veriexec_syscall, .mpo_kld_check_load = mac_veriexec_kld_check_load, .mpo_mount_destroy_label = mac_veriexec_mount_destroy_label, .mpo_mount_init_label = mac_veriexec_mount_init_label, .mpo_priv_check = mac_veriexec_priv_check, .mpo_proc_check_debug = mac_veriexec_proc_check_debug, + .mpo_syscall = mac_veriexec_syscall, + .mpo_system_check_sysctl = mac_veriexec_sysctl_check, .mpo_vnode_check_exec = mac_veriexec_vnode_check_exec, .mpo_vnode_check_open = mac_veriexec_vnode_check_open, .mpo_vnode_check_setmode = mac_veriexec_vnode_check_setmode,