Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF126C76199 for ; Sun, 16 Feb 2020 08:54:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B664D206E2 for ; Sun, 16 Feb 2020 08:54:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=perfinion-com.20150623.gappssmtp.com header.i=@perfinion-com.20150623.gappssmtp.com header.b="RdOWxeq6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726036AbgBPIyd (ORCPT ); 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-Google-Smtp-Source: APXvYqzfRxNhcuyaZnTeT/PngtzpcIz1hjqhWyI57yFu6YMvhQvyiHso5NaZytcTUPKXNyNkaXecKg== 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