Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3588676ybv; Sun, 16 Feb 2020 00:54:37 -0800 (PST) X-Google-Smtp-Source: APXvYqwHM6KEl3ddYpIEzdZ5EWZW/PCQ0kxBoDjKv1VyM4HuXw8+1cV2sk6wYCkFX0p7r6qR7SC3 X-Received: by 2002:a9d:664a:: with SMTP id q10mr7888270otm.298.1581843277519; Sun, 16 Feb 2020 00:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581843277; cv=none; d=google.com; s=arc-20160816; b=YFdMG8K9DUIPjqN8zfoCukFgQCltcb3VSpTeCVeM+ncO75YCQX420go/uE/0Gl8sa/ kxpF0XLO8k9y/t9j1/ODowLBBvOVZHqDA/v3GHPLHM0R0bSB/UxnWFQ0G1xOxOk/ZVK6 Ea9g3dy4mh12m7YILxEfDN5wCNiaqK/NhL38FXsFu9KkNZqSrlPyIbjUwMN3tIFuL7QS qS4JU/jBdWBbp9xG3E4A1xBFzCdpqAhV+TDA8wF0IjBdQlJBIUVu5xzJQcRrKRUVCeg4 WTAzmlEgJtzfdO6ZbXL1CnpU7a38R2G/ZOC+2nOhksRWWOzOOezrrbaUXEOnfvmiN3Ir MvmQ== 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=mJspbHg33Q/vZb9fjxLhVdRqY/YiVwODLginZC2lL5E=; b=pP5+jjg29GsI9Ij6QRvG2MvPZQNGT4tZwaxPeudKIM5eU/ibK77HVJm0f0OWwhBy3b JI140WmYaDYOklYB4fdO7+v0J/LHhOQQ//swlIEr3X4QYg/u9uyssgD4KW8BTjvSYEyd q8/FZOdrjhpoksjtW/l7/qTWoSf+eAY1v8hcgejZihskDKCd2cuV5K+5B0ysslTnFH1a AmnhLHw+zx3QfQlsV5V9HmuXrxRT+lv9RzFIKVJpyKVQVlrgrqM+/cTMfPvOQDB89FLj 4TME3NjQPdNUWD8SSFX4+UCrWz+FGcWJHi0Dw0Y2p9BM0Tv1FuUktA9TdcFnmG7Og++W +dqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@perfinion-com.20150623.gappssmtp.com header.s=20150623 header.b=RdOWxeq6; 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 y73si4846029oia.246.2020.02.16.00.54.35; Sun, 16 Feb 2020 00:54:37 -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=RdOWxeq6; 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 S1726036AbgBPIyd (ORCPT + 13 others); Sun, 16 Feb 2020 03:54:33 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41764 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbgBPIyd (ORCPT ); Sun, 16 Feb 2020 03:54:33 -0500 Received: by mail-pl1-f193.google.com with SMTP id t14so5519065plr.8 for ; Sun, 16 Feb 2020 00:54:31 -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=mJspbHg33Q/vZb9fjxLhVdRqY/YiVwODLginZC2lL5E=; b=RdOWxeq6hSIaafUtFtU65XVyx6/bEKImIe+k50rT3cn/iOtX81K5PJNJwQId6g8vs7 yeim2fPjV0vO0cIU0UK9op+cRSX/tj2rKiQWnOi++XeyEsv+H/nuFhC/+KUkIXP7ZG+q rABgxpRd5Q+iUcNZ5a/GRIA10bzBl58vVQn9gc6QKp8RTlychEKeYlz038csL/qh/z3W sfra9EwMtNUWv4je54ZokPP5mNVWUch/2QCVMXJ1cGfZ3DJy7Xao/Ov5xa1hZAM5A2nH Abu+vhKJQ7MlNOBS7mj2z8POQmLjqjtQQb54BfQGWTrOHyc1PCDS/0LQg7UJZrBGy2je m24A== 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=mJspbHg33Q/vZb9fjxLhVdRqY/YiVwODLginZC2lL5E=; b=XtMfxVCrLLgKya8dvqy+wOGx7hRRay7QrWwq6GUAmmfev16SMBAMKvo+OJTZSHOTIY lcJ3GKCYePvysRcyKpfuK946AupPwMH6ZWOBTF/HNlTCJ34i/yiYoVtiI8fYetfyy3+5 Hyy8KxY1GugxSSVoMtn3xUZO3Uo/2l2Apn++UC6GZObF8jp0jevQcN5ceOsoibY7oQ22 SJDzCTAVhk7Qll+K3bumuMXw8xKUdyY1t2bnEO/Fg+C/14VmOgWDotc+uiKj5Yw/kRB2 HdtTVqz8yDnHw3VG9StUgtjdttuWarfvDbog2blW+FncjpPDWZICwfkD5kcnvsXEkUTA YwLw== X-Gm-Message-State: APjAAAVR8NUBjozsgf8cwelkGovD2GNk4/jLRCSaXRYoChGkYCktValR 3bZPTH6MPI0fy1XtTWCmZfJ0O0ERxNu/eQ== X-Received: by 2002:a17:90a:8b82:: with SMTP id z2mr13980914pjn.59.1581843270756; Sun, 16 Feb 2020 00:54:30 -0800 (PST) Received: from localhost ([101.127.140.252]) by smtp.gmail.com with ESMTPSA id a10sm13397105pgm.81.2020.02.16.00.54.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 16 Feb 2020 00:54:30 -0800 (PST) From: Jason Zaman To: selinux-refpolicy@vger.kernel.org Cc: Jason Zaman Subject: [PATCH 02/10] udev: Add watch perms Date: Sun, 16 Feb 2020 16:54:14 +0800 Message-Id: <20200216085422.36530-2-jason@perfinion.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200216085422.36530-1-jason@perfinion.com> References: <20200216085422.36530-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 From: Jason Zaman 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 --- 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