From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CC7C7158095 for ; Sat, 3 Sep 2022 19:10:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D651CE07D1; Sat, 3 Sep 2022 19:10:19 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BE689E07D1 for ; Sat, 3 Sep 2022 19:10:19 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 01CEE340F89 for ; Sat, 3 Sep 2022 19:10:19 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 481035CB for ; Sat, 3 Sep 2022 19:10:16 +0000 (UTC) From: "Jason Zaman" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jason Zaman" Message-ID: <1662230515.9f6c6ae09df158fda4a027209642d9393c471b03.perfinion@gentoo> Subject: [gentoo-commits] proj/hardened-refpolicy:master commit in: policy/modules/system/, policy/modules/kernel/ X-VCS-Repository: proj/hardened-refpolicy X-VCS-Files: policy/modules/kernel/terminal.if policy/modules/system/init.te X-VCS-Directories: policy/modules/system/ policy/modules/kernel/ X-VCS-Committer: perfinion X-VCS-Committer-Name: Jason Zaman X-VCS-Revision: 9f6c6ae09df158fda4a027209642d9393c471b03 X-VCS-Branch: master Date: Sat, 3 Sep 2022 19:10:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: ece4b9ec-d751-4f15-8b45-cda45bbfd674 X-Archives-Hash: b8203f254e5fb164c80c10ac53ddfbb9 commit: 9f6c6ae09df158fda4a027209642d9393c471b03 Author: Kenton Groombridge concord sh> AuthorDate: Sat May 7 01:16:29 2022 +0000 Commit: Jason Zaman gentoo org> CommitDate: Sat Sep 3 18:41:55 2022 +0000 URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=9f6c6ae0 term, init: allow systemd to watch and watch reads on unallocated ttys As of systemd 250, systemd needs to be able to add a watch on and watch reads on unallocated ttys in order to start getty. systemd[55548]: getty tty1.service: Failed to set up standard input: Permission denied systemd[55548]: getty tty1.service: Failed at step STDIN spawning /sbin/agetty: Permission denied time->Fri May 6 21:17:58 2022 type=PROCTITLE msg=audit(1651886278.452:1770): proctitle="(agetty)" type=PATH msg=audit(1651886278.452:1770): item=0 name="/dev/tty1" inode=18 dev=00:05 mode=020620 ouid=0 ogid=5 rdev=04:01 obj=system_u:object_r:tty_device_t:s0 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0 type=CWD msg=audit(1651886278.452:1770): cwd="/" type=SYSCALL msg=audit(1651886278.452:1770): arch=c000003e syscall=254 success=no exit=-13 a0=3 a1=60ba5c21e020 a2=18 a3=23 items=1 ppid=1 pid=55551 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="(agetty)" exe="/lib/systemd/systemd" subj=system_u:system_r:init_t:s0 key=(null) type=AVC msg=audit(1651886278.452:1770): avc: denied { watch watch_reads } for pid=55551 comm="(agetty)" path="/dev/tty1" dev="devtmpfs" ino=18 scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file permissive=0 Signed-off-by: Kenton Groombridge concord.sh> Signed-off-by: Jason Zaman gentoo.org> policy/modules/kernel/terminal.if | 38 ++++++++++++++++++++++++++++++++++++++ policy/modules/system/init.te | 2 ++ 2 files changed, 40 insertions(+) diff --git a/policy/modules/kernel/terminal.if b/policy/modules/kernel/terminal.if index 55c18dff..e5645c7c 100644 --- a/policy/modules/kernel/terminal.if +++ b/policy/modules/kernel/terminal.if @@ -1284,6 +1284,44 @@ interface(`term_dontaudit_use_unallocated_ttys',` dontaudit $1 tty_device_t:chr_file rw_chr_file_perms; ') +######################################## +## +## Watch unallocated ttys. +## +## +## +## Domain allowed access. +## +## +# +interface(`term_watch_unallocated_ttys',` + gen_require(` + type tty_device_t; + ') + + dev_list_all_dev_nodes($1) + allow $1 tty_device_t:chr_file watch; +') + +######################################## +## +## Watch reads on unallocated ttys. +## +## +## +## Domain allowed access. +## +## +# +interface(`term_watch_reads_unallocated_ttys',` + gen_require(` + type tty_device_t; + ') + + dev_list_all_dev_nodes($1) + allow $1 tty_device_t:chr_file watch_reads; +') + ######################################## ## ## Get the attributes of all tty device nodes. diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te index db06551c..a93eefed 100644 --- a/policy/modules/system/init.te +++ b/policy/modules/system/init.te @@ -523,6 +523,8 @@ ifdef(`init_systemd',` term_create_devpts_dirs(init_t) term_create_ptmx(init_t) term_create_controlling_term(init_t) + term_watch_unallocated_ttys(init_t) + term_watch_reads_unallocated_ttys(init_t) # udevd is a "systemd kobject uevent socket activated daemon" udev_create_kobject_uevent_sockets(init_t)