Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5598409ybv; Tue, 11 Feb 2020 19:34:14 -0800 (PST) X-Google-Smtp-Source: APXvYqyyTfCwSbRM4eb3wNh7xY0+X/kBgSlp7sP63HU19u5rDmyG/KmQj8Er/MxUrvNtsqBHIyQs X-Received: by 2002:a05:6808:8cd:: with SMTP id k13mr5037313oij.4.1581478454227; Tue, 11 Feb 2020 19:34:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581478454; cv=none; d=google.com; s=arc-20160816; b=O3TIkRKg0AFuJ30jp8WtZveiNaJRvPF8aUlnJZN4Da35snk4GxcM2NgomAbkyX2yT/ NE7nFIJh2PrvxktLfR533b+iyxUuaTuSfM1kFLSgxvEUWgohxJACYJuA15wefFw+ePDH c0DJfj2HjBLMIsMaeFpEqxzCE9QLxDcf5rvd6NilEtKJj3UtrGnYB3o3+ISjGA9V0/oL 5tDaE8WZUXZhH5NQSkayu4bDv7JOp7Q9vFVnoAc8nH0mphZ9ZbFUQyrOU+ejPKo8lNwW D9XALDb7CuJMF/8y7xfKIU4iDY/8Y/k1EKNavmBQUYaJyt+AeUtYqtxz8NNCbMg1qeaX BH3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:reply-to:to:from:dkim-signature; bh=htcdU5T0D8OR3ppk6AYpmxBamwG5M+cpNLqueWSVxNA=; b=mntoB7VNxq0P0sR8sWDJbSPFQL/ITJYUcxBL0Zu49BIC7XjWBA8s4Rq7eZ+wsWYflA SoENcxNQ54a9inUHpzcT0FnBEV9y33HvP07H9ccY9+CTCqk7XEg6DcyYdFhsuO/ylV0m XBRF5I/ySUElDzAbH+unGsnpdjOmbw6GjGEx5Ydc9ipoCR+EIET3wRyceBHk8ENwmQw3 EcbhXRpn6hOiNusDdHeYYocLU21mx6JqVffWXtr3hw1hNFX1KWOelDCB5wkcDSfwexuh lWM1c69pMOn0m4AGrBpz7jzRiLChTPl/ZBO9kDwjt7zZg76pXNjaz61TCNOVkOFLqBIy hryQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=l3FsLTWA; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si2388719oic.12.2020.02.11.19.34.10; Tue, 11 Feb 2020 19:34:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@coker.com.au header.s=2008 header.b=l3FsLTWA; spf=pass (google.com: best guess record for domain of selinux-refpolicy-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=selinux-refpolicy-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=coker.com.au Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727710AbgBLDeK (ORCPT + 13 others); Tue, 11 Feb 2020 22:34:10 -0500 Received: from smtp.sws.net.au ([46.4.88.250]:45454 "EHLO smtp.sws.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727602AbgBLDeK (ORCPT ); Tue, 11 Feb 2020 22:34:10 -0500 Received: from xev.coker.com.au (localhost [127.0.0.1]) by smtp.sws.net.au (Postfix) with ESMTP id 56369ED69 for ; Wed, 12 Feb 2020 14:34:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=coker.com.au; s=2008; t=1581478448; bh=htcdU5T0D8OR3ppk6AYpmxBamwG5M+cpNLqueWSVxNA=; l=4298; h=From:To:Reply-To:Subject:Date:From; b=l3FsLTWAb/k3FmL1z6pEl2h43vsFH7evm5LRrCMMET5V7fNLA7hym+JyqVw8Am/UB 3zKqOAqxTMe2vUF58RscCZviKtQ0Kow69JCzaBNXRN7Xf2QrQ0Qj4Py7+4rMgmPLi5 138jpVICyZyUsv1mA2hU8BjJd7dOmaUBZrx/B8H0= Received: by xev.coker.com.au (Postfix, from userid 1001) id AA98AF2C901; Wed, 12 Feb 2020 14:34:03 +1100 (AEDT) From: Russell Coker To: "selinux-refpolicy@vger.kernel.org" Reply-To: russell@coker.com.au Subject: memlockd Date: Wed, 12 Feb 2020 14:34:03 +1100 Message-ID: <1920940.Lkz1Kncxd7@xev> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1762782.9ePdB4Saut" Content-Transfer-Encoding: 7Bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org This is a multi-part message in MIME format. --nextPart1762782.9ePdB4Saut Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" The attach patch adds policy for memlockd, this is a daemon that locks important programs and config files into RAM so that if the system is paging heavily the sysadmin still has a good chance of being able to login to diagnose problems. -- My Main Blog http://etbe.coker.com.au/ My Documents Blog http://doc.coker.com.au/ --nextPart1762782.9ePdB4Saut Content-Disposition: attachment; filename="memlockd.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="memlockd.diff" Index: refpolicy-2.20200209/policy/modules/services/memlockd.fc =================================================================== --- /dev/null +++ refpolicy-2.20200209/policy/modules/services/memlockd.fc @@ -0,0 +1 @@ +/usr/sbin/memlockd -- gen_context(system_u:object_r:memlockd_exec_t,s0) Index: refpolicy-2.20200209/policy/modules/services/memlockd.if =================================================================== --- /dev/null +++ refpolicy-2.20200209/policy/modules/services/memlockd.if @@ -0,0 +1,2 @@ +## memory lock daemon, keeps important files in RAM. + Index: refpolicy-2.20200209/policy/modules/services/memlockd.te =================================================================== --- /dev/null +++ refpolicy-2.20200209/policy/modules/services/memlockd.te @@ -0,0 +1,42 @@ +policy_module(memlockd, 1.0.0) + +######################################## +# +# Declarations +# + +type memlockd_t; +type memlockd_exec_t; +init_daemon_domain(memlockd_t, memlockd_exec_t) + +######################################## +# +# Local policy +# + +allow memlockd_t self:capability { setgid setuid ipc_lock }; +allow memlockd_t self:fifo_file rw_file_perms; +allow memlockd_t self:unix_dgram_socket { create connect }; + +# cache /etc/shadow too +auth_read_shadow(memlockd_t) +auth_map_shadow(memlockd_t) + +sysnet_map_config(memlockd_t) +files_read_etc_files(memlockd_t) + +# for ldd +corecmd_exec_bin(memlockd_t) +corecmd_exec_shell(memlockd_t) +libs_exec_ld_so(memlockd_t) + +corecmd_search_bin(memlockd_t) +files_map_etc_files(memlockd_t) +# has to exec for ldd +corecmd_exec_all_executables(memlockd_t) +corecmd_read_all_executables(memlockd_t) + +logging_send_syslog_msg(memlockd_t) + +miscfiles_read_localization(memlockd_t) + Index: refpolicy-2.20200209/policy/modules/system/sysnetwork.if =================================================================== --- refpolicy-2.20200209.orig/policy/modules/system/sysnetwork.if +++ refpolicy-2.20200209/policy/modules/system/sysnetwork.if @@ -366,6 +366,31 @@ interface(`sysnet_read_config',` ####################################### ## +## map network config files. +## +## +##

+## Allow the specified domain to mmap the +## general network configuration files. +##

+##
+## +## +## Domain allowed access. +## +## +# +interface(`sysnet_map_config',` + gen_require(` + type net_conf_t; + ') + + files_search_etc($1) + allow $1 net_conf_t:file { read_file_perms map }; +') + +####################################### +## ## Do not audit attempts to read network config files. ## ## Index: refpolicy-2.20200209/policy/modules/system/authlogin.if =================================================================== --- refpolicy-2.20200209.orig/policy/modules/system/authlogin.if +++ refpolicy-2.20200209/policy/modules/system/authlogin.if @@ -577,6 +577,23 @@ interface(`auth_read_shadow',` ######################################## ## +## Map the shadow passwords file (/etc/shadow) +## +## +## +## Domain allowed access. +## +## +# +interface(`auth_map_shadow',` + gen_require(` + type shadow_t; + ') + allow $1 shadow_t:file map; +') + +######################################## +## ## Pass shadow assertion for reading. ## ## --nextPart1762782.9ePdB4Saut--