Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4035062ybv; Sun, 16 Feb 2020 12:03:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyKnTCaw7GJvfv5nR/0Yo09fwPz33yuy1pDUipUqGYL6SsU5QwpcSZlaJEujbKHVUY5nTl1 X-Received: by 2002:a05:6808:315:: with SMTP id i21mr7782749oie.139.1581883420332; Sun, 16 Feb 2020 12:03:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581883420; cv=none; d=google.com; s=arc-20160816; b=ywYkpiA5Zs054RvN0a9Cp7anZMwOULqflI3X5Gwbunqk3AqzlkxUAVJUkzW7C14q+/ 0R94qOVZtmdG03MyBk1Mft5yiLxhnSp8mCNRx2SGBsvQ0QofM4oxDwzi/IoKYo6DRlSi el1VsQTkuaCZ6k5Euw6WGlFi2BwgUfaNYhpLSzXwObptgEUAAVISP6fIaSHsWVzT1xwi P8C+1QISC1ZODohhycKKXgBwoUG+NpO+tQ6cDSgvYv1+wswCoFnjBNMK4W5mAwtMmNpu LdJenW0L6fi6x6ejOn2UWDZ6qYwTcTCtvm7w8I+jOniVMq7y6rN6TH+KSBVF9ryi92HX jUaw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gyCcXS0xMuahvsWAz/Ov8h5qOlZMU5+SuIJ6fbGlzQ8=; b=KWyIuxIZVbra/mm68wfeOhNV+bjGK8XYjCUK29I7f9hDfmfP256s4G5LoRzC+dN+AK p/Nxu9U7eJ54OmmUu0KNOq0s7z5UZOZIDVd1nIBzq6y7qi1QNTn8ncvIqHJDwCPfUGNF No11YP87zGw5Xw+f/CsOU6ub7xsbB9NieN716DX1KrUMdkBpZG0wzmTsztXvfy5Egc1Q yOKWN9Lg/MVpeNqdfTysSX36ACqsw5To71Z+djn2eosjcyjK0QDgUbyVou3dbrNy7pDB 5SX34fGgTcP64/oNyA+qtxPy3XFruC89ApiDBMfKM6MAw83Kx7aV21xuwHgNS64pb1+L KSyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=buecDSqv; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s22si5287396oij.35.2020.02.16.12.03.38; Sun, 16 Feb 2020 12:03:40 -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=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=buecDSqv; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726036AbgBPUDf (ORCPT + 13 others); Sun, 16 Feb 2020 15:03:35 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42080 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725989AbgBPUDf (ORCPT ); Sun, 16 Feb 2020 15:03:35 -0500 Received: by mail-pg1-f196.google.com with SMTP id w21so7902358pgl.9 for ; Sun, 16 Feb 2020 12:03:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=perfinion-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gyCcXS0xMuahvsWAz/Ov8h5qOlZMU5+SuIJ6fbGlzQ8=; b=buecDSqv3/wjvnIOuf8+ik9n4A7lfpsNRjDm1EF7OIRrcqRyemBS6WBHYLX4kYFGTg HTcBvlNIc3Rba2S2ujAYxH9WMUT3cHYSgA7VakBDJRwBcQjofdNxeiFQ5JgCQbUfujpf dThYaOWaeRJWyIM/o0fzv3NRF8aslQXYTOx8e/iGDM/rlvcp1w5R29fd5IJncW7tpHBe hYi3ZsrZ2q6Yym9hqF7FK/v6sB1Cf3fN6MsloG7q2qgLTuP8FdSN1Nl2+x2kHo+JQBPc RZO0CuQxD/pPU9QDf/3485VpQBJCiYgafq+aZ0iVZ5Fq0kjhcU+OvuTIYpBwzp8MXuTB rPdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gyCcXS0xMuahvsWAz/Ov8h5qOlZMU5+SuIJ6fbGlzQ8=; b=CZnTy74s8vw9hN1eUjX6IoSdi+M4D6N6IWplECZ7j/envlWbnkPuXXqMqpczzdhVdr twX926DO4Vel1IWrYdATQ5yBNHFbDxoNL2HZIli3zywAqi22Z9jMaFoqWI0lTNbVJVRY kqdVXXQwa/BVYXItsusEIBMh8V6gyulCcChZ6jiLkq9DpZRt7mumKmabGQchxfibLGTY q4PqLP30eHAeM4oKThgUanWAMah8RJC7vVcz9XavEhzsD3qAaF8vQ1sCkSrcyIozcnxI 9CL+jgfXp9+r/l1Bto8092dnyeF+jNlpDFnXMFoJUNfpIh9x/aQacZMJvz4wC1NhRi7i dUSA== X-Gm-Message-State: APjAAAVljlIyHrTt+Id/Iy5sOuyQCZL3aUzyMRtbuOTBoX0Dg/tocjg9 aSsrIG0jQICIDsIUox49ebjnkp+NW5E= X-Received: by 2002:a63:5508:: with SMTP id j8mr13949252pgb.170.1581883414844; Sun, 16 Feb 2020 12:03:34 -0800 (PST) Received: from localhost ([101.127.140.252]) by smtp.gmail.com with ESMTPSA id s130sm14422672pfc.62.2020.02.16.12.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 12:03:34 -0800 (PST) From: Jason Zaman To: selinux-refpolicy@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 02/10] udev: Add watch perms Date: Mon, 17 Feb 2020 04:03:11 +0800 Message-Id: <20200216200319.39337-2-jason@perfinion.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200216200319.39337-1-jason@perfinion.com> References: <20200216200319.39337-1-jason@perfinion.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: selinux-refpolicy-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: selinux-refpolicy@vger.kernel.org Udev watches all the fixed_disks and udevadm watches the runtime dir. udevd[3010]: inotify_add_watch(6, /dev/sde, 10) failed: Permission denied avc: denied { watch } for pid=4669 comm="udevadm" path="/run/udev" dev="tmpfs" ino=19464 scontext=system_u:system_r:udevadm_t:s0 tcontext=system_u:object_r:udev_runtime_t:s0 tclass=dir permissive=0 avc: denied { watch } for pid=3022 comm="udevd" path="/dev/loop3" dev="devtmpfs" ino=10247 scontext=system_u:system_r:udev_t:s0-s0:c0.c1023 tcontext=system_u:object_r:fixed_disk_device_t:s0 tclass=blk_file permissive=0 Signed-off-by: Jason Zaman --- policy/modules/kernel/storage.if | 20 ++++++++++++++++++++ policy/modules/system/udev.te | 3 +++ 2 files changed, 23 insertions(+) diff --git a/policy/modules/kernel/storage.if b/policy/modules/kernel/storage.if index c14bb13b..f9dcbaf5 100644 --- a/policy/modules/kernel/storage.if +++ b/policy/modules/kernel/storage.if @@ -364,6 +364,26 @@ interface(`storage_swapon_fixed_disk',` allow $1 fixed_disk_device_t:blk_file getattr; ') +######################################## +## +## Watch fixed disk device nodes. +## +## +## +## Domain allowed access. +## +## +# +interface(`storage_watch_fixed_disk',` + gen_require(` + type fixed_disk_device_t; + ') + + dev_list_all_dev_nodes($1) + allow $1 fixed_disk_device_t:blk_file watch; + allow $1 fixed_disk_device_t:chr_file watch; +') + ######################################## ## ## Allow the caller to get the attributes diff --git a/policy/modules/system/udev.te b/policy/modules/system/udev.te index 0ccbcb51..e0e27a9d 100644 --- a/policy/modules/system/udev.te +++ b/policy/modules/system/udev.te @@ -154,6 +154,8 @@ selinux_compute_create_context(udev_t) selinux_compute_relabel_context(udev_t) selinux_compute_user_contexts(udev_t) +storage_watch_fixed_disk(udev_t) + auth_read_pam_console_data(udev_t) auth_domtrans_pam_console(udev_t) auth_use_nsswitch(udev_t) @@ -401,6 +403,7 @@ delete_files_pattern(udevadm_t, udev_runtime_t, udev_runtime_t) delete_lnk_files_pattern(udevadm_t, udev_runtime_t, udev_runtime_t) list_dirs_pattern(udevadm_t, udev_runtime_t, udev_runtime_t) read_files_pattern(udevadm_t, udev_runtime_t, udev_runtime_t) +allow udevadm_t udev_runtime_t:dir watch; list_dirs_pattern(udevadm_t, udev_tbl_t, udev_tbl_t) read_files_pattern(udevadm_t, udev_tbl_t, udev_tbl_t) -- 2.24.1