Commit Graph

188 Commits

Author SHA1 Message Date
Chris PeBenito ad7217f906
Merge pull request #375 from cgzones/infer
Use correct interface or template declaration
2021-06-03 09:13:05 -04:00
Yi Zhao 7ee15a0681 roles: move dbus_role_template to userdom_common_user_template
After commit cc8374fd24 (various: systemd
user fixes and additional support), the dbus_role_template is required
for all roles. Move it to userdom_common_user_template.

Before the patch if set DISTRO=redhat:
root@qemux86-64:~# ps xZ | grep "systemd --user"
root:sysadm_r:sysadm_t  240 ? Ss 0:00 /lib/systemd/systemd --user

After the patch:
root@qemux86-64:~# ps xZ | grep "systemd --user"
root:sysadm_r:sysadm_systemd_t  218 ? Ss 0:00 /lib/systemd/systemd --user

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
2021-05-19 10:00:33 +08:00
Christian Göttsche 6c5928d65a Use correct interface or template declaration
Following the guideline of interfaces not allowed to declare anything
and not use prefix parameters, declare interfaces doing so as templates.

Also declare templates not using those features and not calling
templates themselves as interfaces.

These changes originate from the discussion in
https://github.com/TresysTechnology/selint/issues/205 and are found by
new proposed SELint checks at
https://github.com/TresysTechnology/selint/pull/206.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2021-05-13 17:22:59 +02:00
Kenton Groombridge 69b2259c7d various: several dontaudits
Signed-off-by: Kenton Groombridge <me@concord.sh>
2021-04-08 10:35:17 -04:00
Kenton Groombridge d91bef2d24 devices, userdomain: dontaudit userdomain setattr on null device nodes
Signed-off-by: Kenton Groombridge <me@concord.sh>
2021-03-27 19:53:53 -04:00
Kenton Groombridge cc8374fd24
various: systemd user fixes and additional support
This finishes up a lot of the work originally started on systemd --user
support including interacting with user units, communicating with the
user's systemd instance, and reading the system journal.

Signed-off-by: Kenton Groombridge <me@concord.sh>
2021-03-18 15:58:17 -04:00
Dave Sugar 09bd4af708 Work with xdg module disabled
These two cases I see when building on a system without graphical interface.
Move userdom_xdg_user_template into optional block
gpg module doesn't require a graphical front end, move xdg_read_data_files into optional block

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2021-01-28 18:13:33 -05:00
Chris PeBenito cb93093f4e Merge pull request #335 from pebenito/drop-dead-modules 2021-01-25 08:22:09 -05:00
Chris PeBenito 81b20d6b08 userdomain: Move lines.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2021-01-19 09:24:14 -05:00
Russell Coker c42c407bdc yet more strict patches fixed
More little strict patches, much of which are needed for KDE.

With the lines that Chris didn't like removed.

Signed-off-by: Russell Coker <russell@coker.com.au>
2021-01-19 09:14:16 -05:00
Chris PeBenito 7b15003eae Remove modules for programs that are deprecated or no longer supported.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2021-01-14 17:14:30 -05:00
Chris PeBenito 7fd6d78c2c userdomain: Fix error in calling userdom_xdg_user_template().
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-12-08 15:09:27 -05:00
0xC0ncord 1d15c9e009
userdomain, xserver: move xdg rules to userdom_xdg_user_template
xdg rules are normally set in xserver. But, if a modular policy is being
used and the xserver module is not present, the required rules for users
to be able to access xdg content are never created and thus these files
and directories cannot be interacted with by users. This change adds a
new template that can be called to grant these privileges to userdomain
types as necessary.

Signed-off-by: Kenton Groombridge <me@concord.sh>
2020-12-08 10:59:17 -05:00
Jason Zaman a98f25ce73 userdomain: Add watch on home dirs
avc:  denied  { watch } for  pid=12351 comm="gmain" path="/usr/share/backgrounds/xfce" dev="zfs" ino=366749 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=system_u:object_r:usr_t:s0 tclass=dir permissive=0
avc:  denied  { watch } for  pid=11646 comm="gmain" path="/etc/fonts" dev="zfs" ino=237700 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=system_u:object_r:fonts_t:s0 tclass=dir permissive=0
avc:  denied  { watch } for  pid=12351 comm="gmain" path="/home/jason/Desktop" dev="zfs" ino=33153 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:user_home_t:s0 tclass=dir permissive=0
avc:  denied  { watch } for  pid=12574 comm="gmain" path="/home/jason/.local/share/icc" dev="zfs" ino=1954514 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_data_t:s0 tclass=dir permissive=0
avc:  denied  { watch } for  pid=11795 comm="gmain" path="/home/jason/.config/xfce4/panel/launcher-19" dev="zfs" ino=35464 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_config_t:s0 tclass=dir permissive=0
avc:  denied  { watch } for  pid=12351 comm="gmain" path="/home/jason/downloads/pics" dev="zfs" ino=38173 scontext=staff_u:staff_r:staff_t:s0-s0:c0.c1023 tcontext=staff_u:object_r:xdg_downloads_t:s0 tclass=dir permissive=0
Signed-off-by: Jason Zaman <perfinion@gentoo.org>
Signed-off-by: Jason Zaman <jason@perfinion.com>
2020-11-22 14:00:34 -05:00
Jonathan Davies 9d3321e4fe userdomain.if: Marked usbguard user modify tunable as optional so usbguard may be excluded.
Thanks to Dominick Grift for helping me pin-point this.

Signed-off-by: Jonathan Davies <jpds@protonmail.com>
2020-08-29 20:43:38 +00:00
bauen1 fa59d0e9bc
selint: fix S-010
Signed-off-by: bauen1 <j2468h@gmail.com>
2020-08-28 17:39:09 +02:00
Christian Göttsche 72b2c66256 whitespace cleanup
Remove trailing white spaces and mixed up indents

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
2020-08-13 14:34:57 +02:00
Chris PeBenito fe737c405d selinuxuntil, userdomain: Restore relabelfrom access for unlabeled files.
Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-07-28 10:33:07 -04:00
Chris PeBenito 0992763548 Update callers for "pid" to "runtime" interface rename.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-06-28 16:03:45 -04:00
Chris PeBenito be04bb3e7e Rename "pid" interfaces to "runtime" interfaces.
Rename interfaces to bring consistency with previous pid->runtime type
renaming.  See PR #106 or 69a403cd original type renaming.

Interfaces that are still in use were renamed with a compatibility
interface.  Unused interfaces were fully deprecated for removal.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2020-06-28 14:33:17 -04:00
Topi Miettinen 1d8333d7a7
Remove unlabeled packet access
When SECMARK or Netlabel packet labeling is used, it's useful to
forbid receiving and sending unlabeled packets. If packet labeling is
not active, there's no effect.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-06-03 23:16:19 +03:00
Chris PeBenito 100a3fb02b Merge pull request #233 from fishilico/ip-netns 2020-05-04 09:05:34 -04:00
Daniel Burgener 04d51e18c8 Switch pipe reading on domtrans to inherited only
Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-20 15:46:38 -04:00
Daniel Burgener 410a682138 Fix mismatches between object class and permission macro.
In many cases, this won't result in a change in the actual policy generated, but if the definitions of macros are changed going forward, the mismatches could cause issues.

Signed-off-by: Daniel Burgener <Daniel.Burgener@microsoft.com>
2020-04-20 15:46:33 -04:00
Nicolas Iooss c99cfb2c16
sysnetwork: allow using "ip netns"
When using network namespaces with `ip netns`, command `ip` creates
files in `/run/netns` that are mountpoints for `nsfs`. For example:

    $ ip netns add VPN

    $ ls -Z /run/netns/VPN
    system_u:object_r:nsfs_t /run/netns/VPN

    $ findmnt /run/netns/VPN
    TARGET         SOURCE                 FSTYPE OPTIONS
    /run/netns/VPN nsfs[net:[4026532371]] nsfs   rw
    /run/netns/VPN nsfs[net:[4026532371]] nsfs   rw

From a shell CLI, it is possible to retrieve the name of the current
network namespace:

    $ ip netns exec VPN bash
    $ ip netns identify $$
    VPN

This requires reading `/proc/$PID/ns/net`, which is labelled as a user
domain. Allow this access using `userdom_read_all_users_state()`.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2020-04-19 11:52:29 +02:00
Chris PeBenito d046419bf4 Merge pull request #178 from gtrentalancia/master 2020-03-19 14:16:28 -04:00
Chris PeBenito 7f3f512ef2 Merge pull request #191 from topimiettinen/add-usbguard 2020-03-19 13:07:05 -04:00
Chris PeBenito b3959fb415 Merge pull request #196 from gtrentalancia/watch-perms 2020-03-19 13:05:42 -04:00
Guido Trentalancia bf806fd589 userdomain: add watch perms
Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
--
 policy/modules/system/miscfiles.if  |   19 +++++++++++++++++++
 policy/modules/system/userdomain.if |    6 ++++++
 2 files changed, 25 insertions(+)
2020-03-19 05:50:42 +01:00
Topi Miettinen 1d2fb171b5
Add usbguard
Usbguard enforces the USB device authorization policy for all USB
devices. Users can be authorized to manage rules and make device
authorization decisions using a command line tool.

Add rules for usbguard. Optionally, allow authorized users to control
the daemon, which requires usbguard-daemon to be able modify its rules
in /etc/usbguard.

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
2020-03-18 20:23:38 +02:00
Guido Trentalancia c5c4e8a900 This patch improves a previous commit by restricting down
the permissions to write the wireless device in order to
prevent a possible Denial of Service (DoS) attack from an
unprivileged process bringing down the wireless interfaces.

Only administrative users can now enable/disable the wireless
interfaces, while normal users can only read their status.

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
---
 policy/modules/kernel/devices.if    |   18 ++++++++++++++++++
 policy/modules/system/userdomain.if |    3 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)
2020-02-08 11:42:27 -08:00
Chris PeBenito fdb28ea98d Merge pull request #167 from gtrentalancia/master 2020-01-25 14:32:20 -05:00
Guido Trentalancia 3415d17e7f Allow userdomain to read and write the wireless devices (for
example for querying their state, enabling and/or disabling
them using userspace tools such as "rfkill" from util-linux).

See also:
https://wireless.wiki.kernel.org/en/users/documentation/rfkill

Signed-off-by: Guido Trentalancia <guido@trentalancia.com>
---
 policy/modules/system/userdomain.if |    1 +
 1 file changed, 1 insertion(+)
2020-01-24 11:29:27 -08:00
Daniel Burgener 36c3a7903c Fix situations where require blocks in interfaces listed types not actually referenced by that interface
Signed-off-by: Daniel Burgener <dburgener@tresys.com>
2020-01-24 08:18:55 -05:00
Daniel Burgener 70a1c1ede2 Add requires to interfaces that reference types or attributes without requiring them
Signed-off-by: Daniel Burgener <dburgener@tresys.com>
2020-01-16 09:59:56 -05:00
Stephen Smalley 161bda392e access_vectors: Remove unused permissions
Remove unused permission definitions from SELinux.
Many of these were only ever used in pre-mainline
versions of SELinux, prior to Linux 2.6.0.  Some of them
were used in the legacy network or compat_net=1 checks
that were disabled by default in Linux 2.6.18 and
fully removed in Linux 2.6.30.

The corresponding classmap declarations were removed from the
mainline kernel in:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=42a9699a9fa179c0054ea3cf5ad3cc67104a6162

Permissions never used in mainline Linux:
file swapon
filesystem transition
tcp_socket { connectto newconn acceptfrom }
node enforce_dest
unix_stream_socket { newconn acceptfrom }

Legacy network checks, removed in 2.6.30:
socket { recv_msg send_msg }
node { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }
netif { tcp_recv tcp_send udp_recv udp_send rawip_recv rawip_send dccp_recv dccp_send }

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
2020-01-14 13:41:50 -05:00
Chris PeBenito 42145d226a systemd: Logind removes /run/user/* user temp files.
See systemd-user-runtime-dir stop.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2020-01-07 12:43:44 -05:00
Chris PeBenito da156aea1e systemd: Add initial policy for systemd --user.
This is just a start; it does not cover all uses.

Signed-off-by: Chris PeBenito <Christopher.PeBenito@microsoft.com>
2019-04-25 11:18:58 -04:00
Jason Zaman fa23645ca1 userdomain: introduce userdom_user_home_dir_filetrans_user_cert
Signed-off-by: Jason Zaman <jason@perfinion.com>
2019-01-23 18:40:57 -05:00
Jason Zaman 8bb4fdfc29 userdom: remove filetrans from userdom_user_content_access_template 2018-06-10 13:23:58 -04:00
Sven Vermeulen b64a53494f tunable-managed user content access template
To simplify policy management on the various application domains with
respect to user content access, a template is introduced which generates
four tunable_policy() blocks.

- The *_read_generic_user_content boolean will enable the application
  domain to read generic user resources (labeled with user_home_t).
- The *_read_all_user_content boolean does the same, but for all user
  resources (those associated with the user_home_content_type attribute).
- The *_manage_generic_user_content boolean enables the application to
  manage generic user resources (labeled with user_home_t)
- The *_manage_all_user_content boolean does the same, but for all user
  reosurces (those associated with the user_home_content_type attribute).

Although it would be even better to generate the booleans themselves as
well (which is what Gentoo does with this template), it would result in
booleans without proper documentation. Calls such as "semanage boolean
-l" would fail to properly show a description on the boolean - something
Gentoo resolves by keeping this documentation separate in a
doc/gentoo_tunables.xml file.

In this patch, we assume that the calling modules will define the
booleans themselves (with appropriate documentation). The template
checks for the existence of the booleans. This approach is more in
line with how domain-specific booleans are managed up to now.

Changes since v2:
 - Fix typo in gen_require (had a closing : instead of ;)

Changes since v1:
 - Use in-line XML comment and tunable definition

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2018-06-10 13:23:01 -04:00
Sven Vermeulen d4dad1950d helper interfaces to read/manage all user content
To facilitate handling user home content (through the
user_home_content_type attribute) the following interfaces are provided:

- userdom_read_all_user_home_content
- userdom_manage_all_user_home_content

Domains that are granted these privileges are able to read (or manage)
all user home content, so not only the generic one (user_home_t) but all
types that have been assigned the user_home_content_type attribute. This
is more than just user_home_t and the XDG types, so the use should not
be granted automatically.

As part of the larger XDG patch set, these interfaces are called through
the *_read_all_user_content and *_manage_all_user_content booleans which
are by default not enabled.

Changes since v2:
- Fix typo in pattern call

Signed-off-by: Sven Vermeulen <sven.vermeulen@siphos.be>
2018-06-10 13:23:01 -04:00
James Carter da0cf8e721 Mark unused parameters as unused
Marked unused parameters as unused in the interfaces listed below.

userdomain.if:userdom_ro_home_role()
userdomain.if:userdom_manage_home_role()
userdomain.if:userdom_manage_tmp_role()
userdomain.if:userdom_manage_tmpfs_role()

Signed-off-by: James Carter <jwcart2@tycho.nsa.gov>
2018-04-12 18:44:50 -04:00
Chris PeBenito 78a49b640d Add new mmap permission set and pattern support macros.
Deprecate mmap_file_perms and mmap_files_pattern since they are not fully
informative about their access.  Replace with a full set of permission
set macros for mmap.

Requested for selinux-testsuite usage.
2017-12-13 18:58:34 -05:00
Jason Zaman d29486d4cf userdomain: Allow public content access
All are allowed read access to readonly files.
unpriv and admin users are allowed rw access to public rw files.
2017-12-13 18:19:29 -05:00
David Sugar 9af24aeb9c Make an attribute for objects in /run/user/%{USERID}/*
Setup attribute user_runtime_content_type in userdomain for files in /run/user/%{USERID}/* interfaces to associate this attribute with types and interfaces to delete types with this attribute.

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2017-12-12 20:19:10 -05:00
David Sugar d7674a5406 Work around systemd-logind patch not in RHEL 7.x yet
This is probably RHEL only - seeing directories in /run/user/$(UID) created as
 tmpfs_t rather than user_runtime_t.  This appears fixed in newer systemd-logind.
It appears to have been fixed in systemd git repo by Nicolas Iooss 02-Feb-2016
hash 4b51966cf6c06250036e428608da92f8640beb96 probably in systemd-v229
I don't see this merged into RHEL 7.x as of now but as some point it hopefully
will be merged in and this can go away.

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2017-12-03 16:38:39 -05:00
Jason Zaman 9adc6c5ddb gssproxy: Allow others to stream connect
kernel AVC:
 * Starting gssproxy ...
Failed to write to /proc/net/rpc/use-gss-proxy: 13 (Permission denied)
 * start-stop-daemon: failed to start `gssproxy'

type=AVC msg=audit(1490858215.578:386110): avc:  denied  { connectto } for  pid=25447 comm="gssproxy" path="/run/gssproxy.sock" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:gssproxy_t:s0 tclass=unix_stream_socket permissive=0
2017-11-04 14:00:56 -04:00
Jason Zaman 6efe498a9b Add key interfaces and perms
Mostly taken from the fedora rawhide policy
2017-11-04 14:00:56 -04:00
Jason Zaman d5f6a58a77 userdomain: allow admin to rw tape storage 2017-11-01 18:59:17 -04:00