2009-10-14 01:23:18

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 0/6] Updated X object manager policy: Intro

This patch series is an updated policy for the X server object manager.
This is the policy that I was running in Portland for my various demos.
It includes new x_pointer/x_keyboard classes, unconfined-by-default
user types, and other changes. The only thing missing here is updated
mls constraints; I am still working on those.

I need the first patch in the series (x_pointer/x_keyboard classes)
upstream so that I can use these classes in the X server. Please merge
this patch expeditiously if possible.

The remaining 5 patches are NOT independent and breakage will probably
result if only some of them are applied. I only broke them up in an
attempt to make it easier to review the changes.

This whole thing is also available in a git tree at
git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
ease of pulling.


--

Eamon Walsh<[email protected]>
National Security Agency


2009-10-14 01:27:11

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 1/6] Add separate x_pointer and x_keyboard classes inheriting from x_device.

Add separate x_pointer and x_keyboard classes inheriting from x_device.

This is needed to allow more fine-grained control over X devices without
using different types. Using different types is problematic because
devices act as subjects in the X Flask implementation, and subjects
cannot be labeled through a type transition (since the output role is
hardcoded to object_r).

Signed-off-by: Eamon Walsh<[email protected]>
---
policy/flask/access_vectors | 55 +++++++++++++++++++++++++---------------
policy/flask/security_classes | 4 +++
2 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/policy/flask/access_vectors b/policy/flask/access_vectors
index 3998b77..6620e4c 100644
--- a/policy/flask/access_vectors
+++ b/policy/flask/access_vectors
@@ -94,6 +94,33 @@ common database
}

#
+# Define a common prefix for pointer and keyboard access vectors.
+#
+
+common x_device
+{
+ getattr
+ setattr
+ use
+ read
+ write
+ getfocus
+ setfocus
+ bell
+ force_cursor
+ freeze
+ grab
+ manage
+ list_property
+ get_property
+ set_property
+ add
+ remove
+ create
+ destroy
+}
+
+#
# Define the access vectors.
#
# class class_name [ inherits common_name ] { permission_name ... }
@@ -525,27 +552,7 @@ class x_client
}

class x_device
-{
- getattr
- setattr
- use
- read
- write
- getfocus
- setfocus
- bell
- force_cursor
- freeze
- grab
- manage
- list_property
- get_property
- set_property
- add
- remove
- create
- destroy
-}
+inherits x_device

class x_server
{
@@ -802,3 +809,9 @@ class kernel_service

class tun_socket
inherits socket
+
+class x_pointer
+inherits x_device
+
+class x_keyboard
+inherits x_device
diff --git a/policy/flask/security_classes b/policy/flask/security_classes
index 2bd1bf6..fa65db2 100644
--- a/policy/flask/security_classes
+++ b/policy/flask/security_classes
@@ -121,4 +121,8 @@ class kernel_service

class tun_socket

+# Still More SE-X Windows stuff
+class x_pointer # userspace
+class x_keyboard # userspace
+
# FLASK
--
1.6.5.rc2

2009-10-14 01:28:36

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 2/6] Add a "prefix" parameter to xserver_role and xserver_restricted_role.

Add a "prefix" parameter to xserver_role and xserver_restricted_role.

This is required to call xserver_object_types_template and
xserver_common_x_domain_template from within these interfaces.

Additionally, add a call to xserver_unconfined from within
xserver_restricted_role. This causes the default user types to
be unconfined as far as the X object manager is concerned. Only
non-default types such as mozilla_t are now confined.

Signed-off-by: Eamon Walsh<[email protected]>
---
policy/modules/apps/wm.if | 2 +-
policy/modules/roles/staff.te | 2 +-
policy/modules/roles/sysadm.te | 2 +-
policy/modules/roles/unprivuser.te | 2 +-
policy/modules/services/xserver.if | 201 ++++++++++++++--------------------
policy/modules/system/userdomain.if | 2 +-
6 files changed, 88 insertions(+), 123 deletions(-)

diff --git a/policy/modules/apps/wm.if b/policy/modules/apps/wm.if
index 313f247..11d78d0 100644
--- a/policy/modules/apps/wm.if
+++ b/policy/modules/apps/wm.if
@@ -75,7 +75,7 @@ template(`wm_role_template',`
')

optional_policy(`
- xserver_role($2, $1_wm_t)
+ xserver_role($1_wm, $2, $1_wm_t)
')
')

diff --git a/policy/modules/roles/staff.te b/policy/modules/roles/staff.te
index 7433ca0..07af057 100644
--- a/policy/modules/roles/staff.te
+++ b/policy/modules/roles/staff.te
@@ -166,5 +166,5 @@ optional_policy(`
')

optional_policy(`
- xserver_role(staff_r, staff_t)
+ xserver_role(staff, staff_r, staff_t)
')
diff --git a/policy/modules/roles/sysadm.te b/policy/modules/roles/sysadm.te
index 2ed3c67..374add6 100644
--- a/policy/modules/roles/sysadm.te
+++ b/policy/modules/roles/sysadm.te
@@ -444,7 +444,7 @@ optional_policy(`
')

optional_policy(`
- xserver_role(sysadm_r, sysadm_t)
+ xserver_role(sysadm, sysadm_r, sysadm_t)
')

optional_policy(`
diff --git a/policy/modules/roles/unprivuser.te b/policy/modules/roles/unprivuser.te
index 2183644..4c974d1 100644
--- a/policy/modules/roles/unprivuser.te
+++ b/policy/modules/roles/unprivuser.te
@@ -151,5 +151,5 @@ optional_policy(`
')

optional_policy(`
- xserver_role(user_r, user_t)
+ xserver_role(user, user_r, user_t)
')
diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if
index 6a0f5c1..99bddec 100644
--- a/policy/modules/services/xserver.if
+++ b/policy/modules/services/xserver.if
@@ -5,6 +5,12 @@
## Rules required for using the X Windows server
## and environment, for restricted users.
##</summary>
+##<param name="prefix">
+## <summary>
+## The prefix of the X client domain (e.g., user
+## is the prefix for user_t).
+## </summary>
+##</param>
##<param name="role">
## <summary>
## Role allowed access.
@@ -22,144 +28,97 @@ interface(`xserver_restricted_role',`
type user_fonts_t, user_fonts_cache_t, user_fonts_config_t;
type iceauth_t, iceauth_exec_t, iceauth_home_t;
type xauth_t, xauth_exec_t, xauth_home_t;
-
- type info_xproperty_t, rootwindow_t;
-
- class x_drawable all_x_drawable_perms;
- class x_screen all_x_screen_perms;
- class x_gc all_x_gc_perms;
- class x_font all_x_font_perms;
- class x_colormap all_x_colormap_perms;
- class x_property all_x_property_perms;
- class x_selection all_x_selection_perms;
- class x_cursor all_x_cursor_perms;
- class x_client all_x_client_perms;
- class x_device all_x_device_perms;
- class x_server all_x_server_perms;
- class x_extension all_x_extension_perms;
- class x_resource all_x_resource_perms;
- class x_event all_x_event_perms;
- class x_synthetic_event all_x_synthetic_event_perms;
')

- role $1 types { xserver_t xauth_t iceauth_t };
+ role $2 types { xserver_t xauth_t iceauth_t };

# Xserver read/write client shm
- allow xserver_t $2:fd use;
- allow xserver_t $2:shm rw_shm_perms;
+ allow xserver_t $3:fd use;
+ allow xserver_t $3:shm rw_shm_perms;

- domtrans_pattern($2, xserver_exec_t, xserver_t)
- allow xserver_t $2:process signal;
+ domtrans_pattern($3, xserver_exec_t, xserver_t)
+ allow xserver_t $3:process signal;

- allow xserver_t $2:shm rw_shm_perms;
+ allow xserver_t $3:shm rw_shm_perms;

- allow $2 user_fonts_t:dir list_dir_perms;
- allow $2 user_fonts_t:file read_file_perms;
+ allow $3 user_fonts_t:dir list_dir_perms;
+ allow $3 user_fonts_t:file read_file_perms;

- allow $2 user_fonts_config_t:dir list_dir_perms;
- allow $2 user_fonts_config_t:file read_file_perms;
+ allow $3 user_fonts_config_t:dir list_dir_perms;
+ allow $3 user_fonts_config_t:file read_file_perms;

- manage_dirs_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
- manage_files_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
+ manage_dirs_pattern($3, user_fonts_cache_t, user_fonts_cache_t)
+ manage_files_pattern($3, user_fonts_cache_t, user_fonts_cache_t)

- stream_connect_pattern($2, xserver_tmp_t, xserver_tmp_t, xserver_t)
- files_search_tmp($2)
+ stream_connect_pattern($3, xserver_tmp_t, xserver_tmp_t, xserver_t)
+ files_search_tmp($3)

# Communicate via System V shared memory.
- allow $2 xserver_t:shm r_shm_perms;
- allow $2 xserver_tmpfs_t:file read_file_perms;
+ allow $3 xserver_t:shm r_shm_perms;
+ allow $3 xserver_tmpfs_t:file read_file_perms;

# allow ps to show iceauth
- ps_process_pattern($2, iceauth_t)
+ ps_process_pattern($3, iceauth_t)

- domtrans_pattern($2, iceauth_exec_t, iceauth_t)
+ domtrans_pattern($3, iceauth_exec_t, iceauth_t)

- allow $2 iceauth_home_t:file read_file_perms;
+ allow $3 iceauth_home_t:file read_file_perms;

- domtrans_pattern($2, xauth_exec_t, xauth_t)
+ domtrans_pattern($3, xauth_exec_t, xauth_t)

- allow $2 xauth_t:process signal;
+ allow $3 xauth_t:process signal;

# allow ps to show xauth
- ps_process_pattern($2, xauth_t)
- allow $2 xserver_t:process signal;
+ ps_process_pattern($3, xauth_t)
+ allow $3 xserver_t:process signal;

- allow $2 xauth_home_t:file read_file_perms;
+ allow $3 xauth_home_t:file read_file_perms;

# for when /tmp/.X11-unix is created by the system
- allow $2 xdm_t:fd use;
- allow $2 xdm_t:fifo_file { getattr read write ioctl };
- allow $2 xdm_tmp_t:dir search;
- allow $2 xdm_tmp_t:sock_file { read write };
- dontaudit $2 xdm_t:tcp_socket { read write };
+ allow $3 xdm_t:fd use;
+ allow $3 xdm_t:fifo_file { getattr read write ioctl };
+ allow $3 xdm_tmp_t:dir search;
+ allow $3 xdm_tmp_t:sock_file { read write };
+ dontaudit $3 xdm_t:tcp_socket { read write };

# Client read xserver shm
- allow $2 xserver_t:fd use;
- allow $2 xserver_tmpfs_t:file read_file_perms;
+ allow $3 xserver_t:fd use;
+ allow $3 xserver_tmpfs_t:file read_file_perms;

# Read /tmp/.X0-lock
- allow $2 xserver_tmp_t:file { getattr read };
+ allow $3 xserver_tmp_t:file { getattr read };

- dev_rw_xserver_misc($2)
- dev_rw_power_management($2)
- dev_read_input($2)
- dev_read_misc($2)
- dev_write_misc($2)
+ dev_rw_xserver_misc($3)
+ dev_rw_power_management($3)
+ dev_read_input($3)
+ dev_read_misc($3)
+ dev_write_misc($3)
# open office is looking for the following
- dev_getattr_agp_dev($2)
- dev_dontaudit_rw_dri($2)
+ dev_getattr_agp_dev($3)
+ dev_dontaudit_rw_dri($3)
# GNOME checks for usb and other devices:
- dev_rw_usbfs($2)
+ dev_rw_usbfs($3)

- miscfiles_read_fonts($2)
+ miscfiles_read_fonts($3)

- xserver_common_x_domain_template(user, $2)
- xserver_xsession_entry_type($2)
- xserver_dontaudit_write_log($2)
- xserver_stream_connect_xdm($2)
+ xserver_object_types_template($1)
+ xserver_common_x_domain_template($1, $3)
+ xserver_unconfined($3)
+ xserver_xsession_entry_type($3)
+ xserver_dontaudit_write_log($3)
+ xserver_stream_connect_xdm($3)
# certain apps want to read xdm.pid file
- xserver_read_xdm_pid($2)
+ xserver_read_xdm_pid($3)
# gnome-session creates socket under /tmp/.ICE-unix/
- xserver_create_xdm_tmp_sockets($2)
+ xserver_create_xdm_tmp_sockets($3)
# Needed for escd, remove if we get escd policy
- xserver_manage_xdm_tmp_files($2)
+ xserver_manage_xdm_tmp_files($3)

# Client write xserver shm
tunable_policy(`allow_write_xshm',`
- allow $2 xserver_t:shm rw_shm_perms;
- allow $2 xserver_tmpfs_t:file rw_file_perms;
+ allow $3 xserver_t:shm rw_shm_perms;
+ allow $3 xserver_tmpfs_t:file rw_file_perms;
')
-
- ##############################
- #
- # User X object manager local policy
- #
-
- # manage: xhost X11:ChangeHosts
- # freeze: metacity X11:GrabKey
- # force_cursor: metacity X11:GrabPointer
- allow $2 xserver_t:x_device { manage freeze force_cursor };
-
- # gnome-settings-daemon XKEYBOARD:SetControls
- allow $2 xserver_t:x_server manage;
-
- # gnome-settings-daemon RANDR:SelectInput
- allow $2 xserver_t:x_resource write;
-
- # metacity X11:InstallColormap X11:UninstallColormap
- allow $2 rootwindow_t:x_colormap { install uninstall };
-
- # read: gnome-settings-daemon RANDR:GetScreenSizeRange
- # write: gnome-settings-daemon RANDR:SelectInput
- # setattr: gnome-settings-daemon X11:GrabKey
- # manage: metacity X11:ChangeWindowAttributes
- allow $2 rootwindow_t:x_drawable { read write manage setattr };
-
- # setattr: metacity X11:InstallColormap
- allow $2 xserver_t:x_screen { saver_getattr saver_setattr setattr };
-
- # xrdb X11:ChangeProperty prop=RESOURCE_MANAGER
- allow $2 info_xproperty_t:x_property { create append write };
')

########################################
@@ -167,6 +126,12 @@ interface(`xserver_restricted_role',`
## Rules required for using the X Windows server
## and environment.
##</summary>
+##<param name="prefix">
+## <summary>
+## The prefix of the X client domain (e.g., user
+## is the prefix for user_t).
+## </summary>
+##</param>
##<param name="role">
## <summary>
## Role allowed access.
@@ -184,32 +149,32 @@ interface(`xserver_role',`
type user_fonts_t, user_fonts_cache_t, user_fonts_config_t;
')

- xserver_restricted_role($1, $2)
+ xserver_restricted_role($1, $2, $3)

# Communicate via System V shared memory.
- allow $2 xserver_t:shm rw_shm_perms;
- allow $2 xserver_tmpfs_t:file rw_file_perms;
+ allow $3 xserver_t:shm rw_shm_perms;
+ allow $3 xserver_tmpfs_t:file rw_file_perms;

- allow $2 iceauth_home_t:file manage_file_perms;
- allow $2 iceauth_home_t:file { relabelfrom relabelto };
+ allow $3 iceauth_home_t:file manage_file_perms;
+ allow $3 iceauth_home_t:file { relabelfrom relabelto };

- allow $2 xauth_home_t:file manage_file_perms;
- allow $2 xauth_home_t:file { relabelfrom relabelto };
+ allow $3 xauth_home_t:file manage_file_perms;
+ allow $3 xauth_home_t:file { relabelfrom relabelto };

- manage_dirs_pattern($2, user_fonts_t, user_fonts_t)
- manage_files_pattern($2, user_fonts_t, user_fonts_t)
- relabel_dirs_pattern($2, user_fonts_t, user_fonts_t)
- relabel_files_pattern($2, user_fonts_t, user_fonts_t)
+ manage_dirs_pattern($3, user_fonts_t, user_fonts_t)
+ manage_files_pattern($3, user_fonts_t, user_fonts_t)
+ relabel_dirs_pattern($3, user_fonts_t, user_fonts_t)
+ relabel_files_pattern($3, user_fonts_t, user_fonts_t)

- manage_dirs_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
- manage_files_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
- relabel_dirs_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
- relabel_files_pattern($2, user_fonts_cache_t, user_fonts_cache_t)
+ manage_dirs_pattern($3, user_fonts_cache_t, user_fonts_cache_t)
+ manage_files_pattern($3, user_fonts_cache_t, user_fonts_cache_t)
+ relabel_dirs_pattern($3, user_fonts_cache_t, user_fonts_cache_t)
+ relabel_files_pattern($3, user_fonts_cache_t, user_fonts_cache_t)

- manage_dirs_pattern($2, user_fonts_config_t, user_fonts_config_t)
- manage_files_pattern($2, user_fonts_config_t, user_fonts_config_t)
- relabel_dirs_pattern($2, user_fonts_config_t, user_fonts_config_t)
- relabel_files_pattern($2, user_fonts_config_t, user_fonts_config_t)
+ manage_dirs_pattern($3, user_fonts_config_t, user_fonts_config_t)
+ manage_files_pattern($3, user_fonts_config_t, user_fonts_config_t)
+ relabel_dirs_pattern($3, user_fonts_config_t, user_fonts_config_t)
+ relabel_files_pattern($3, user_fonts_config_t, user_fonts_config_t)

')

diff --git a/policy/modules/system/userdomain.if b/policy/modules/system/userdomain.if
index f209ccf..b9bea7b 100644
--- a/policy/modules/system/userdomain.if
+++ b/policy/modules/system/userdomain.if
@@ -885,7 +885,7 @@ template(`userdom_restricted_xwindows_user_template',`
logging_send_audit_msgs($1_t)
selinux_get_enforce_mode($1_t)

- xserver_restricted_role($1_r, $1_t)
+ xserver_restricted_role($1, $1_r, $1_t)

optional_policy(`
alsa_read_rw_config($1_t)
--
1.6.5.rc2

2009-10-14 01:29:21

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 3/6] Make consolekit_t and system_dbusd_t unconfined in X.

Make consolekit_t and system_dbusd_t unconfined in X.

Both of these types have been observed trying to touch the user's X
display, one example being through /usr/libexec/ck-get-x11-server-pid
and /usr/libexec/ck-get-x11-display-device.

Signed-off-by: Eamon Walsh<[email protected]>
---
policy/modules/services/consolekit.te | 1 +
policy/modules/services/dbus.te | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/policy/modules/services/consolekit.te b/policy/modules/services/consolekit.te
index 1ead55d..4f9b992 100644
--- a/policy/modules/services/consolekit.te
+++ b/policy/modules/services/consolekit.te
@@ -108,6 +108,7 @@ optional_policy(`
optional_policy(`
xserver_read_xdm_pid(consolekit_t)
xserver_read_user_xauth(consolekit_t)
+ xserver_unconfined(consolekit_t)
corenet_tcp_connect_xserver_port(consolekit_t)
')

diff --git a/policy/modules/services/dbus.te b/policy/modules/services/dbus.te
index aa857cb..f60e1f1 100644
--- a/policy/modules/services/dbus.te
+++ b/policy/modules/services/dbus.te
@@ -135,6 +135,8 @@ seutil_sigchld_newrole(system_dbusd_t)
userdom_dontaudit_use_unpriv_user_fds(system_dbusd_t)
userdom_dontaudit_search_user_home_dirs(system_dbusd_t)

+xserver_unconfined(system_dbusd_t)
+
optional_policy(`
bind_domtrans(system_dbusd_t)
')
--
1.6.5.rc2

2009-10-14 01:30:18

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 4/6] X Object Manager policy revisions to xserver.te.

X Object Manager policy revisions to xserver.te.

This commit consists of three main parts:

1. Code movement. There were X object manager-related statements
scattered somewhat throughout the file; these have been consolidated,
which resulted in some other statements moving (e.g. iceauth_t).

2. Type changes. Many of the specific event, extension, and property
types have been dropped for the time being. The rootwindow_t and
remote_xclient_t types have been renamed, and a root_xcolormap_t
type has been (re-)added. This is for naming consistency.
An "xserver_unprotected" alias has been added for use in labeling
clients whose resources should be globally accessible (e.g. xdm_t).

3. Policy changes. These are mostly related to devices, which now have
separate x_keyboard and x_pointer classes. The "Hacks" section
has been cleaned up, and various other classes have had the default
permissions tweaked.

Signed-off-by: Eamon Walsh<[email protected]>
---
policy/modules/services/xserver.te | 283 ++++++++++++++++++++----------------
1 files changed, 157 insertions(+), 126 deletions(-)

diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.te
index fc421d5..2f4144d 100644
--- a/policy/modules/services/xserver.te
+++ b/policy/modules/services/xserver.te
@@ -12,6 +12,8 @@ gen_require(`
class x_cursor all_x_cursor_perms;
class x_client all_x_client_perms;
class x_device all_x_device_perms;
+ class x_pointer all_x_pointer_perms;
+ class x_keyboard all_x_keyboard_perms;
class x_server all_x_server_perms;
class x_extension all_x_extension_perms;
class x_resource all_x_resource_perms;
@@ -46,70 +48,53 @@ gen_tunable(xdm_sysadm_login, false)
##</desc>
gen_tunable(xserver_object_manager, false)

-attribute input_xevent_type;
-attribute xserver_unconfined_type;
attribute x_domain;
-attribute x_userdomain;
-attribute xproperty_type;
-attribute xselection_type;
-attribute xextension_type;
-attribute xevent_type;

-type accelgraphics_xext_t, xextension_type;
+# X Events
+attribute xevent_type;
+attribute input_xevent_type;
+type xevent_t, xevent_type;
type client_xevent_t, xevent_type;
+type input_xevent_t, xevent_type, input_xevent_type;
+
+# X Extensions
+attribute xextension_type;
+type xextension_t, xextension_type;
+type security_xextension_t, xextension_type;
+
+# X Properties
+attribute xproperty_type;
+type xproperty_t, xproperty_type;
+type seclabel_xproperty_t, xproperty_type;
type clipboard_xproperty_t, xproperty_type;
+
+# X Selections
+attribute xselection_type;
+type xselection_t, xselection_type;
type clipboard_xselection_t, xselection_type;
-type debug_xext_t, xextension_type;
-type directhw_xext_t alias disallowed_xext_t, xextension_type;
-type focus_xevent_t, xevent_type;
+#type settings_xselection_t, xselection_type;
+#type dbus_xselection_t, xselection_type;

-type iceauth_t;
-type iceauth_exec_t;
-typealias iceauth_t alias { user_iceauth_t staff_iceauth_t sysadm_iceauth_t };
-typealias iceauth_t alias { auditadm_iceauth_t secadm_iceauth_t };
-application_domain(iceauth_t, iceauth_exec_t)
-ubac_constrained(iceauth_t)
+# X Drawables
+attribute xdrawable_type;
+attribute xcolormap_type;
+type root_xdrawable_t, xdrawable_type;
+type root_xcolormap_t, xcolormap_type;

-type iceauth_home_t;
-typealias iceauth_home_t alias { user_iceauth_home_t staff_iceauth_home_t sysadm_iceauth_home_t };
-typealias iceauth_home_t alias { auditadm_iceauth_home_t secadm_iceauth_home_t };
-files_poly_member(iceauth_home_t)
-userdom_user_home_content(iceauth_home_t)
+attribute xserver_unconfined_type;
+attribute xserver_unprotected_type;
+
+xserver_object_types_template(root)
+#xserver_object_types_template(user)

-type info_xproperty_t, xproperty_type;
-type input_xevent_t, xevent_type;
-type manage_xevent_t, xevent_type;
-type output_xext_t, xextension_type;
-type property_xevent_t, xevent_type;
-type remote_xclient_t;
-
-type rootwindow_t;
-typealias rootwindow_t alias { user_rootwindow_t staff_rootwindow_t sysadm_rootwindow_t };
-typealias rootwindow_t alias { auditadm_rootwindow_t secadm_rootwindow_t };
-ubac_constrained(rootwindow_t)
-
-type screensaver_xext_t, xextension_type;
-type security_xext_t, xextension_type;
-type shmem_xext_t, xextension_type;
-type std_xext_t, xextension_type;
-type video_xext_t, xextension_type;
-type unknown_xevent_t, xevent_type;
-
-xserver_object_types_template(user)
-typealias user_xproperty_t alias { staff_xproperty_t sysadm_xproperty_t };
-typealias user_xproperty_t alias { auditadm_xproperty_t secadm_xproperty_t };
-typealias user_input_xevent_t alias { staff_input_xevent_t sysadm_input_xevent_t };
-typealias user_input_xevent_t alias { auditadm_input_xevent_t secadm_input_xevent_t };
-typealias user_property_xevent_t alias { staff_property_xevent_t sysadm_property_xevent_t };
-typealias user_property_xevent_t alias { auditadm_property_xevent_t secadm_property_xevent_t };
-typealias user_focus_xevent_t alias { staff_focus_xevent_t sysadm_focus_xevent_t };
-typealias user_focus_xevent_t alias { auditadm_focus_xevent_t secadm_focus_xevent_t };
-typealias user_manage_xevent_t alias { staff_manage_xevent_t sysadm_manage_xevent_t };
-typealias user_manage_xevent_t alias { auditadm_manage_xevent_t secadm_manage_xevent_t };
-typealias user_default_xevent_t alias { staff_default_xevent_t sysadm_default_xevent_t };
-typealias user_default_xevent_t alias { auditadm_default_xevent_t secadm_default_xevent_t };
-typealias user_client_xevent_t alias { staff_client_xevent_t sysadm_client_xevent_t };
-typealias user_client_xevent_t alias { auditadm_client_xevent_t secadm_client_xevent_t };
+#typealias user_xproperty_t alias { staff_xproperty_t sysadm_xproperty_t };
+#typealias user_xproperty_t alias { auditadm_xproperty_t secadm_xproperty_t };
+#typealias user_input_xevent_t alias { staff_input_xevent_t sysadm_input_xevent_t };
+#typealias user_input_xevent_t alias { auditadm_input_xevent_t secadm_input_xevent_t };
+
+type remote_t;
+xserver_object_types_template(remote)
+xserver_common_x_domain_template(remote,remote_t)

type user_fonts_t;
typealias user_fonts_t alias { staff_fonts_t sysadm_fonts_t };
@@ -126,10 +111,18 @@ typealias user_fonts_config_t alias { staff_fonts_config_t sysadm_fonts_config_t
typealias user_fonts_config_t alias { auditadm_fonts_config_t secadm_fonts_config_t };
userdom_user_home_content(user_fonts_config_t)

-type xevent_t alias default_xevent_t, xevent_type;
-type xext_t alias unknown_xext_t, xextension_type;
-type xproperty_t alias default_xproperty_t, xproperty_type;
-type xselection_t alias default_xselection_t, xselection_type;
+type iceauth_t;
+type iceauth_exec_t;
+typealias iceauth_t alias { user_iceauth_t staff_iceauth_t sysadm_iceauth_t };
+typealias iceauth_t alias { auditadm_iceauth_t secadm_iceauth_t };
+application_domain(iceauth_t, iceauth_exec_t)
+ubac_constrained(iceauth_t)
+
+type iceauth_home_t;
+typealias iceauth_home_t alias { user_iceauth_home_t staff_iceauth_home_t sysadm_iceauth_home_t };
+typealias iceauth_home_t alias { auditadm_iceauth_home_t secadm_iceauth_home_t };
+files_poly_member(iceauth_home_t)
+userdom_user_home_content(iceauth_home_t)

type xauth_t;
type xauth_exec_t;
@@ -161,6 +154,10 @@ type xdm_exec_t;
auth_login_pgm_domain(xdm_t)
init_domain(xdm_t, xdm_exec_t)
init_daemon_domain(xdm_t, xdm_exec_t)
+xserver_object_types_template(xdm)
+xserver_common_x_domain_template(xdm, xdm_t)
+xserver_unconfined(xdm_t)
+xserver_unprotected(xdm_t)

type xdm_lock_t;
files_lock_file(xdm_lock_t)
@@ -190,8 +187,6 @@ type xserver_t;
type xserver_exec_t;
typealias xserver_t alias { user_xserver_t staff_xserver_t sysadm_xserver_t };
typealias xserver_t alias { auditadm_xserver_t secadm_xserver_t xdm_xserver_t };
-xserver_object_types_template(xdm)
-xserver_common_x_domain_template(xdm, xdm_t)
init_system_domain(xserver_t, xserver_exec_t)
ubac_constrained(xserver_t)

@@ -579,6 +574,14 @@ optional_policy(`
# X server local policy
#

+# X Object Manager rules
+type_transition xserver_t xserver_t:x_drawable root_xdrawable_t;
+type_transition xserver_t xserver_t:x_colormap root_xcolormap_t;
+type_transition root_xdrawable_t input_xevent_t:x_event root_input_xevent_t;
+
+allow xserver_t { root_xdrawable_t x_domain }:x_drawable send;
+allow xserver_t input_xevent_t:x_event send;
+
# setuid/setgid for the wrapper program to change UID
# sys_rawio is for iopl access - should not be needed for frame-buffer
# sys_admin, locking shared mem? chowning IPC message queues or semaphores?
@@ -603,20 +606,6 @@ allow xserver_t self:unix_stream_socket { create_stream_socket_perms connectto }
allow xserver_t self:tcp_socket create_stream_socket_perms;
allow xserver_t self:udp_socket create_socket_perms;

-# Device rules
-allow x_domain xserver_t:x_device { read getattr use setattr setfocus grab bell };
-
-allow xserver_t { input_xevent_t input_xevent_type }:x_event send;
-
-domtrans_pattern(xserver_t, xauth_exec_t, xauth_t)
-
-allow xserver_t xauth_home_t:file read_file_perms;
-
-# Labeling rules for root windows and colormaps
-type_transition xserver_t xserver_t:{ x_drawable x_colormap } rootwindow_t;
-
-allow xserver_t { rootwindow_t x_domain }:x_drawable send;
-
manage_dirs_pattern(xserver_t, xserver_tmp_t, xserver_tmp_t)
manage_files_pattern(xserver_t, xserver_tmp_t, xserver_tmp_t)
manage_sock_files_pattern(xserver_t, xserver_tmp_t, xserver_tmp_t)
@@ -635,6 +624,9 @@ manage_files_pattern(xserver_t, xkb_var_lib_t, xkb_var_lib_t)
manage_lnk_files_pattern(xserver_t, xkb_var_lib_t, xkb_var_lib_t)
files_search_var_lib(xserver_t)

+domtrans_pattern(xserver_t, xauth_exec_t, xauth_t)
+allow xserver_t xauth_home_t:file read_file_perms;
+
# Create files in /var/log with the xserver_log_t type.
manage_files_pattern(xserver_t, xserver_log_t, xserver_log_t)
logging_log_filetrans(xserver_t, xserver_log_t, file)
@@ -752,15 +744,17 @@ tunable_policy(`!xserver_object_manager',`
# but typeattribute doesnt work in conditionals

allow xserver_t xserver_t:x_server *;
- allow xserver_t { x_domain rootwindow_t }:x_drawable *;
+ allow xserver_t { x_domain root_xdrawable_t }:x_drawable *;
allow xserver_t xserver_t:x_screen *;
allow xserver_t x_domain:x_gc *;
- allow xserver_t { x_domain rootwindow_t }:x_colormap *;
+ allow xserver_t { x_domain root_xcolormap_t }:x_colormap *;
allow xserver_t xproperty_type:x_property *;
allow xserver_t xselection_type:x_selection *;
allow xserver_t x_domain:x_cursor *;
- allow xserver_t { x_domain remote_xclient_t }:x_client *;
+ allow xserver_t x_domain:x_client *;
allow xserver_t { x_domain xserver_t }:x_device *;
+ allow xserver_t { x_domain xserver_t }:x_pointer *;
+ allow xserver_t { x_domain xserver_t }:x_keyboard *;
allow xserver_t xextension_type:x_extension *;
allow xserver_t { x_domain xserver_t }:x_resource *;
allow xserver_t xevent_type:{ x_event x_synthetic_event } *;
@@ -863,112 +857,149 @@ optional_policy(`
#

# Hacks
-# everyone can get the input focus of everyone else
-# this is a fundamental brokenness in the X protocol
-allow x_domain { x_domain xserver_t }:x_device getfocus;
-# everyone can grab the server
-# everyone does it, it is basically a free DOS attack
-allow x_domain xserver_t:x_server grab;
-# everyone can get the font path, etc.
-# this could leak out sensitive information
-allow x_domain xserver_t:x_server getattr;
# everyone can do override-redirect windows.
# this could be used to spoof labels
allow x_domain self:x_drawable override;
-# everyone can receive management events on the root window
-# allows to know when new windows appear, among other things
-allow x_domain manage_xevent_t:x_event receive;
+# firefox gets nosy with other people's windows
+allow x_domain x_domain:x_drawable { list_child receive };

# X Server
-# can read server-owned resources
-allow x_domain xserver_t:x_resource read;
+# can get X server attributes
+allow x_domain xserver_t:x_server getattr;
+# can grab the server
+allow x_domain xserver_t:x_server grab;
+# can read and write server-owned generic resources
+allow x_domain xserver_t:x_resource { read write };
# can mess with own clients
-allow x_domain self:x_client { manage destroy };
+allow x_domain self:x_client { getattr manage destroy };

# X Protocol Extensions
-allow x_domain std_xext_t:x_extension { query use };
-allow x_domain shmem_xext_t:x_extension { query use };
-dontaudit x_domain xextension_type:x_extension { query use };
+allow x_domain xextension_t:x_extension { query use };
+allow x_domain security_xextension_t:x_extension { query use };

# X Properties
-# can read and write cut buffers
-allow x_domain clipboard_xproperty_t:x_property { create read write append };
-# can read info properties
-allow x_domain info_xproperty_t:x_property read;
# can change properties of root window
-allow x_domain rootwindow_t:x_drawable { list_property get_property set_property };
-# can change properties of own windows
+allow x_domain root_xdrawable_t:x_drawable { list_property get_property set_property };
+# can change properties of my own windows
allow x_domain self:x_drawable { list_property get_property set_property };
+# can read and write cut buffers
+allow x_domain clipboard_xproperty_t:x_property { create read write append };
+# can read security labels
+allow x_domain seclabel_xproperty_t:x_property { getattr read };
+# can change all other properties
+allow x_domain xproperty_t:x_property { getattr create read write append destroy };

# X Windows
# operations allowed on root windows
-allow x_domain rootwindow_t:x_drawable { getattr list_child add_child remove_child send receive };
+allow x_domain root_xdrawable_t:x_drawable { getattr setattr list_child add_child remove_child send receive hide show };
# operations allowed on my windows
allow x_domain self:x_drawable { create destroy getattr setattr read write show hide list_child add_child remove_child manage send receive };
+allow x_domain self:x_drawable { blend };
+# operations allowed on all windows
+allow x_domain x_domain:x_drawable { getattr get_property set_property remove_child };

# X Colormaps
# can use the default colormap
-allow x_domain rootwindow_t:x_colormap { read use add_color };
+allow x_domain root_xcolormap_t:x_colormap { read use add_color remove_color install uninstall };
+# can create and use colormaps
+allow x_domain self:x_colormap *;
+
+# X Devices
+# operations allowed on my own devices
+allow x_domain self:{ x_device x_pointer x_keyboard } *;
+# operations allowed on generic devices
+allow x_domain xserver_t:x_device { use getattr setattr getfocus setfocus bell grab freeze force_cursor };
+# operations allowed on core keyboard
+allow x_domain xserver_t:x_keyboard { use getattr setattr getfocus setfocus bell grab };
+# operations allowed on core pointer
+allow x_domain xserver_t:x_pointer { read use getattr setattr getfocus setfocus bell grab freeze force_cursor };
+
+# all devices can generate input events
+allow x_domain root_xdrawable_t:x_drawable send;
+allow x_domain x_domain:x_drawable send;
+allow x_domain input_xevent_t:x_event send;
+
+# dontaudit keyloggers repeatedly polling
+#dontaudit x_domain xserver_t:x_keyboard read;

# X Input
-# can receive certain root window events
-allow x_domain focus_xevent_t:x_event receive;
-allow x_domain property_xevent_t:x_event receive;
-allow x_domain client_xevent_t:x_synthetic_event receive;
-allow x_domain manage_xevent_t:x_synthetic_event receive;
+# can receive default events
+allow x_domain xevent_t:{ x_event x_synthetic_event } receive;
+# can receive ICCCM events
+allow x_domain client_xevent_t:{ x_event x_synthetic_event } receive;
# can send ICCCM events to the root window
-allow x_domain manage_xevent_t:x_synthetic_event send;
allow x_domain client_xevent_t:x_synthetic_event send;
+# can receive root window input events
+allow x_domain root_input_xevent_t:x_event receive;
+
# X Selections
# can use the clipboard
allow x_domain clipboard_xselection_t:x_selection { getattr setattr read };
-# can query all other selections
-allow x_domain xselection_t:x_selection { getattr read };
+# can use default selections
+allow x_domain xselection_t:x_selection { getattr setattr read };

# Other X Objects
# can create and use cursors
allow x_domain self:x_cursor *;
# can create and use graphics contexts
allow x_domain self:x_gc *;
-# can create and use colormaps
-allow x_domain self:x_colormap *;
# can read and write own objects
allow x_domain self:x_resource { read write };
+# can mess with the screensaver
+allow x_domain xserver_t:x_screen { getattr saver_getattr };
+
+########################################
+#
+# Rules for unprotected access to a domain
+#
+
+allow x_domain xserver_unprotected_type:x_drawable *;
+allow x_domain xserver_unprotected_type:x_gc *;
+allow x_domain xserver_unprotected_type:x_colormap *;
+allow x_domain xserver_unprotected_type:x_property *;
+allow x_domain xserver_unprotected_type:x_cursor *;
+allow x_domain xserver_unprotected_type:x_client *;
+allow x_domain xserver_unprotected_type:x_device *;
+allow x_domain xserver_unprotected_type:x_resource *;
+
+########################################
+#
+# Rules for unconfined access to this module
+#

tunable_policy(`! xserver_object_manager',`
# should be xserver_unconfined(x_domain),
# but typeattribute doesnt work in conditionals

allow x_domain xserver_t:x_server *;
- allow x_domain { x_domain rootwindow_t }:x_drawable *;
+ allow x_domain xdrawable_type:x_drawable *;
allow x_domain xserver_t:x_screen *;
allow x_domain x_domain:x_gc *;
- allow x_domain { x_domain rootwindow_t }:x_colormap *;
+ allow x_domain xcolormap_type:x_colormap *;
allow x_domain xproperty_type:x_property *;
allow x_domain xselection_type:x_selection *;
allow x_domain x_domain:x_cursor *;
- allow x_domain { x_domain remote_xclient_t }:x_client *;
+ allow x_domain x_domain:x_client *;
allow x_domain { x_domain xserver_t }:x_device *;
+ allow x_domain { x_domain xserver_t }:x_pointer *;
+ allow x_domain { x_domain xserver_t }:x_keyboard *;
allow x_domain xextension_type:x_extension *;
allow x_domain { x_domain xserver_t }:x_resource *;
allow x_domain xevent_type:{ x_event x_synthetic_event } *;
')

-########################################
-#
-# Rules for unconfined access to this module
-#
-
allow xserver_unconfined_type xserver_t:x_server *;
-allow xserver_unconfined_type { x_domain rootwindow_t }:x_drawable *;
+allow xserver_unconfined_type xdrawable_type:x_drawable *;
allow xserver_unconfined_type xserver_t:x_screen *;
allow xserver_unconfined_type x_domain:x_gc *;
-allow xserver_unconfined_type { x_domain rootwindow_t }:x_colormap *;
+allow xserver_unconfined_type xcolormap_type:x_colormap *;
allow xserver_unconfined_type xproperty_type:x_property *;
allow xserver_unconfined_type xselection_type:x_selection *;
allow xserver_unconfined_type x_domain:x_cursor *;
-allow xserver_unconfined_type { x_domain remote_xclient_t }:x_client *;
+allow xserver_unconfined_type x_domain:x_client *;
allow xserver_unconfined_type { x_domain xserver_t }:x_device *;
+allow xserver_unconfined_type { x_domain xserver_t }:x_pointer *;
+allow xserver_unconfined_type { x_domain xserver_t }:x_keyboard *;
allow xserver_unconfined_type xextension_type:x_extension *;
allow xserver_unconfined_type { x_domain xserver_t }:x_resource *;
allow xserver_unconfined_type xevent_type:{ x_event x_synthetic_event } *;
--
1.6.5.rc2

2009-10-14 01:31:00

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 5/6] X Object Manager policy revisions to xserver.if.

X Object Manager policy revisions to xserver.if.

This commit consists of two parts:

1. Revisions to xserver_object_types_template and
xserver_common_x_domain_template. This reflects the dropping
of many of the specific event, extension, and property types.

2. New interfaces:
xserver_manage_core_devices: Gives control over core mouse/keyboard.
xserver_unprotected: Allows all clients to access a domain's X objects.
Modified interfaces:
xserver_unconfined: Added x_domain typeattribute statement.

Signed-off-by: Eamon Walsh<[email protected]>
---
policy/modules/services/xserver.if | 105 +++++++++++++++++++++--------------
1 files changed, 63 insertions(+), 42 deletions(-)

diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if
index 99bddec..8d1e240 100644
--- a/policy/modules/services/xserver.if
+++ b/policy/modules/services/xserver.if
@@ -324,18 +324,13 @@ interface(`xserver_user_client',`
#
template(`xserver_common_x_domain_template',`
gen_require(`
- type $1_xproperty_t, $1_input_xevent_t, $1_property_xevent_t;
- type $1_focus_xevent_t, $1_manage_xevent_t, $1_default_xevent_t;
- type $1_client_xevent_t;
-
- type rootwindow_t, xproperty_t;
- type input_xevent_t, focus_xevent_t, property_xevent_t, manage_xevent_t;
+ type root_xdrawable_t;
+ type xproperty_t, $1_xproperty_t;
type xevent_t, client_xevent_t;
+ type input_xevent_t, $1_input_xevent_t;

attribute x_domain;
- attribute xproperty_type;
- attribute xevent_type;
- attribute input_xevent_type;
+ attribute xdrawable_type, xcolormap_type;

class x_drawable all_x_drawable_perms;
class x_property all_x_property_perms;
@@ -350,32 +345,28 @@ template(`xserver_common_x_domain_template',`

# Type attributes
typeattribute $2 x_domain;
+ typeattribute $2 xdrawable_type, xcolormap_type;

# X Properties
- # can read and write client properties
- allow $2 $1_xproperty_t:x_property { create destroy read write append };
- type_transition $2 xproperty_t:x_property $1_xproperty_t;
+ # disable property transitions for the time being.
+# type_transition $2 xproperty_t:x_property $1_xproperty_t;

# X Windows
# new windows have the domain type
- type_transition $2 rootwindow_t:x_drawable $2;
+ type_transition $2 root_xdrawable_t:x_drawable $2;

# X Input
+ # distinguish input events
+ type_transition $2 input_xevent_t:x_event $1_input_xevent_t;
+ # can send own events
+ allow $2 $1_input_xevent_t:{ x_event x_synthetic_event } send;
# can receive own events
allow $2 $1_input_xevent_t:{ x_event x_synthetic_event } receive;
- allow $2 $1_property_xevent_t:{ x_event x_synthetic_event } receive;
- allow $2 $1_focus_xevent_t:{ x_event x_synthetic_event } receive;
- allow $2 $1_manage_xevent_t:{ x_event x_synthetic_event } receive;
- allow $2 $1_default_xevent_t:{ x_event x_synthetic_event } receive;
- allow $2 $1_client_xevent_t:{ x_event x_synthetic_event } receive;
- type_transition $2 input_xevent_t:x_event $1_input_xevent_t;
- type_transition $2 property_xevent_t:x_event $1_property_xevent_t;
- type_transition $2 focus_xevent_t:x_event $1_focus_xevent_t;
- type_transition $2 manage_xevent_t:x_event $1_manage_xevent_t;
- type_transition $2 client_xevent_t:x_event $1_client_xevent_t;
- type_transition $2 xevent_t:x_event $1_default_xevent_t;
- # can send ICCCM events to myself
- allow $2 $1_manage_xevent_t:x_synthetic_event send;
+ # can receive default events
+ allow $2 client_xevent_t:{ x_event x_synthetic_event } receive;
+ allow $2 xevent_t:{ x_event x_synthetic_event } receive;
+ # don't audit send failures
+ dontaudit $2 input_xevent_type:x_event send;
')

#######################################
@@ -401,27 +392,12 @@ template(`xserver_object_types_template',`
#

# Types for properties
- type $1_xproperty_t alias $1_default_xproperty_t, xproperty_type;
+ type $1_xproperty_t, xproperty_type;
ubac_constrained($1_xproperty_t)

# Types for events
type $1_input_xevent_t, input_xevent_type, xevent_type;
ubac_constrained($1_input_xevent_t)
-
- type $1_property_xevent_t, xevent_type;
- ubac_constrained($1_property_xevent_t)
-
- type $1_focus_xevent_t, xevent_type;
- ubac_constrained($1_focus_xevent_t)
-
- type $1_manage_xevent_t, xevent_type;
- ubac_constrained($1_manage_xevent_t)
-
- type $1_default_xevent_t, xevent_type;
- ubac_constrained($1_default_xevent_t)
-
- type $1_client_xevent_t, xevent_type;
- ubac_constrained($1_client_xevent_t)
')

#######################################
@@ -1214,6 +1190,49 @@ interface(`xserver_read_tmp_files',`
########################################
##<summary>
## Interface to provide X object permissions on a given X server to
+## an X client domain. Gives the domain permission to read the
+## virtual core keyboard and virtual core pointer devices.
+##</summary>
+##<param name="domain">
+## <summary>
+## Domain allowed access.
+## </summary>
+##</param>
+#
+interface(`xserver_manage_core_devices',`
+ gen_require(`
+ type xserver_t;
+ class x_device all_x_device_perms;
+ class x_pointer all_x_pointer_perms;
+ class x_keyboard all_x_keyboard_perms;
+ ')
+
+ allow $1 xserver_t:{ x_device x_pointer x_keyboard } *;
+')
+
+########################################
+##<summary>
+## Interface to remove protections on an X client domain.
+## Gives other X client domains full permissions over the target
+## domain's X objects.
+##</summary>
+##<param name="domain">
+## <summary>
+## Domain to be unprotected.
+## </summary>
+##</param>
+#
+interface(`xserver_unprotected',`
+ gen_require(`
+ attribute xserver_unprotected_type;
+ ')
+
+ typeattribute $1 xserver_unprotected_type;
+')
+
+########################################
+##<summary>
+## Interface to provide X object permissions on a given X server to
## an X client domain. Gives the domain complete control over the
## display.
##</summary>
@@ -1225,8 +1244,10 @@ interface(`xserver_read_tmp_files',`
#
interface(`xserver_unconfined',`
gen_require(`
+ attribute x_domain;
attribute xserver_unconfined_type;
')

+ typeattribute $1 x_domain;
typeattribute $1 xserver_unconfined_type;
')
--
1.6.5.rc2

2009-10-14 01:31:36

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 6/6] X Object manager policy revisions to x_contexts.

X Object manager policy revisions to x_contexts.

Many of the specific event, extension, and property types have been
removed for the time being. Polyinstantiation allows selections and
properties to be separated in a different way, and new X server support
for labeling individual extension requests (as opposed to entire extensions)
should make the extension querying problem easier to solve in the future.

Signed-off-by: Eamon Walsh<[email protected]>
---
config/appconfig-mcs/x_contexts | 109 +++------------------------------
config/appconfig-mls/x_contexts | 109 +++------------------------------
config/appconfig-standard/x_contexts | 109 +++------------------------------
3 files changed, 30 insertions(+), 297 deletions(-)

diff --git a/config/appconfig-mcs/x_contexts b/config/appconfig-mcs/x_contexts
index 08da649..0b32044 100644
--- a/config/appconfig-mcs/x_contexts
+++ b/config/appconfig-mcs/x_contexts
@@ -13,7 +13,7 @@
# The default client rule defines a context to be used for all clients
# connecting to the server from a remote host.
#
-client * system_u:object_r:remote_xclient_t:s0
+client * system_u:object_r:remote_t:s0


#
@@ -27,25 +27,10 @@ client * system_u:object_r:remote_xclient_t:s0
# rule indicated by an asterisk should follow all other property rules.
#
# Properties that normal clients may only read
-property XFree86_VT system_u:object_r:info_xproperty_t:s0
-property XFree86_DDC_EDID1_RAWDATA system_u:object_r:info_xproperty_t:s0
-property RESOURCE_MANAGER system_u:object_r:info_xproperty_t:s0
-property SCREEN_RESOURCES system_u:object_r:info_xproperty_t:s0
-property _MIT_PRIORITY_COLORS system_u:object_r:info_xproperty_t:s0
-property AT_SPI_IOR system_u:object_r:info_xproperty_t:s0
-property _SELINUX_CLIENT_CONTEXT system_u:object_r:info_xproperty_t:s0
-property _NET_WORKAREA system_u:object_r:info_xproperty_t:s0
-property _XKB_RULES_NAMES system_u:object_r:info_xproperty_t:s0
+property _SELINUX_* system_u:object_r:seclabel_xproperty_t:s0

# Clipboard and selection properties
-property CUT_BUFFER0 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER1 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER2 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER3 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER4 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER5 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER6 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER7 system_u:object_r:clipboard_xproperty_t:s0
+property CUT_BUFFER? system_u:object_r:clipboard_xproperty_t:s0

# Default fallback type
property * system_u:object_r:xproperty_t:s0
@@ -61,57 +46,11 @@ property * system_u:object_r:xproperty_t:s0
# Extension rules map an extension name to a context. A default extension
# rule indicated by an asterisk should follow all other extension rules.
#
-# Standard extensions
-extension BIG-REQUESTS system_u:object_r:std_xext_t:s0
-extension SHAPE system_u:object_r:std_xext_t:s0
-extension SYNC system_u:object_r:std_xext_t:s0
-extension XC-MISC system_u:object_r:std_xext_t:s0
-extension XFIXES system_u:object_r:std_xext_t:s0
-extension XInputExtension system_u:object_r:std_xext_t:s0
-extension XKEYBOARD system_u:object_r:std_xext_t:s0
-extension DAMAGE system_u:object_r:std_xext_t:s0
-extension RENDER system_u:object_r:std_xext_t:s0
-extension XINERAMA system_u:object_r:std_xext_t:s0
-
-# Direct hardware access extensions
-extension XFree86-DGA system_u:object_r:directhw_xext_t:s0
-extension XFree86-VidModeExtension system_u:object_r:directhw_xext_t:s0
-
-# Screen management and multihead extensions
-extension RANDR system_u:object_r:output_xext_t:s0
-extension Composite system_u:object_r:output_xext_t:s0
-
-# Screensaver, power management extensions
-extension DPMS system_u:object_r:screensaver_xext_t:s0
-extension MIT-SCREEN-SAVER system_u:object_r:screensaver_xext_t:s0
-
-# Shared memory extensions
-extension MIT-SHM system_u:object_r:shmem_xext_t:s0
-extension XFree86-Bigfont system_u:object_r:shmem_xext_t:s0
-
-# Accelerated graphics, OpenGL, direct rendering extensions
-extension GLX system_u:object_r:accelgraphics_xext_t:s0
-extension NV-CONTROL system_u:object_r:accelgraphics_xext_t:s0
-extension NV-GLX system_u:object_r:accelgraphics_xext_t:s0
-extension NVIDIA-GLX system_u:object_r:accelgraphics_xext_t:s0
-
-# Debugging, testing, and recording extensions
-extension RECORD system_u:object_r:debug_xext_t:s0
-extension X-Resource system_u:object_r:debug_xext_t:s0
-extension XTEST system_u:object_r:debug_xext_t:s0
-
-# Security-related extensions
-extension SECURITY system_u:object_r:security_xext_t:s0
-extension SELinux system_u:object_r:security_xext_t:s0
-extension XAccessControlExtension system_u:object_r:security_xext_t:s0
-extension XC-APPGROUP system_u:object_r:security_xext_t:s0
-
-# Video extensions
-extension XVideo system_u:object_r:video_xext_t:s0
-extension XVideo-MotionCompensation system_u:object_r:video_xext_t:s0
+# Restricted extensions
+extension SELinux system_u:object_r:security_xextension_t:s0

-# Default fallback type
-extension * system_u:object_r:xext_t:s0
+# Standard extensions
+extension * system_u:object_r:xextension_t:s0


#
@@ -124,8 +63,6 @@ extension * system_u:object_r:xext_t:s0
# rule indicated by an asterisk should follow all other selection rules.
#
# Standard selections
-selection XA_PRIMARY system_u:object_r:clipboard_xselection_t:s0
-selection XA_SECONDARY system_u:object_r:clipboard_xselection_t:s0
selection PRIMARY system_u:object_r:clipboard_xselection_t:s0
selection CLIPBOARD system_u:object_r:clipboard_xselection_t:s0

@@ -149,7 +86,6 @@ event X11:KeyRelease system_u:object_r:input_xevent_t:s0
event X11:ButtonPress system_u:object_r:input_xevent_t:s0
event X11:ButtonRelease system_u:object_r:input_xevent_t:s0
event X11:MotionNotify system_u:object_r:input_xevent_t:s0
-event X11:SelectionNotify system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceKeyPress system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceKeyRelease system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceButtonPress system_u:object_r:input_xevent_t:s0
@@ -159,36 +95,11 @@ event XInputExtension:DeviceValuator system_u:object_r:input_xevent_t:s0
event XInputExtension:ProximityIn system_u:object_r:input_xevent_t:s0
event XInputExtension:ProximityOut system_u:object_r:input_xevent_t:s0

-# Focus events
-event X11:FocusIn system_u:object_r:focus_xevent_t:s0
-event X11:FocusOut system_u:object_r:focus_xevent_t:s0
-event X11:EnterNotify system_u:object_r:focus_xevent_t:s0
-event X11:LeaveNotify system_u:object_r:focus_xevent_t:s0
-
-# Property events
-event X11:PropertyNotify system_u:object_r:property_xevent_t:s0
-
# Client message events
event X11:ClientMessage system_u:object_r:client_xevent_t:s0
-
-# Manager events
-event X11:ConfigureRequest system_u:object_r:manage_xevent_t:s0
-event X11:ResizeRequest system_u:object_r:manage_xevent_t:s0
-event X11:MapRequest system_u:object_r:manage_xevent_t:s0
-event X11:CirculateRequest system_u:object_r:manage_xevent_t:s0
-event X11:CreateNotify system_u:object_r:manage_xevent_t:s0
-event X11:DestroyNotify system_u:object_r:manage_xevent_t:s0
-event X11:MapNotify system_u:object_r:manage_xevent_t:s0
-event X11:UnmapNotify system_u:object_r:manage_xevent_t:s0
-event X11:ReparentNotify system_u:object_r:manage_xevent_t:s0
-event X11:ConfigureNotify system_u:object_r:manage_xevent_t:s0
-event X11:GravityNotify system_u:object_r:manage_xevent_t:s0
-event X11:CirculateNotify system_u:object_r:manage_xevent_t:s0
-event X11:Expose system_u:object_r:manage_xevent_t:s0
-event X11:VisibilityNotify system_u:object_r:manage_xevent_t:s0
-
-# Unknown events (that are not registered in the X server's name database)
-event<unknown> system_u:object_r:unknown_xevent_t:s0
+event X11:SelectionNotify system_u:object_r:client_xevent_t:s0
+event X11:UnmapNotify system_u:object_r:client_xevent_t:s0
+event X11:ConfigureNotify system_u:object_r:client_xevent_t:s0

# Default fallback type
event * system_u:object_r:xevent_t:s0
diff --git a/config/appconfig-mls/x_contexts b/config/appconfig-mls/x_contexts
index 08da649..0b32044 100644
--- a/config/appconfig-mls/x_contexts
+++ b/config/appconfig-mls/x_contexts
@@ -13,7 +13,7 @@
# The default client rule defines a context to be used for all clients
# connecting to the server from a remote host.
#
-client * system_u:object_r:remote_xclient_t:s0
+client * system_u:object_r:remote_t:s0


#
@@ -27,25 +27,10 @@ client * system_u:object_r:remote_xclient_t:s0
# rule indicated by an asterisk should follow all other property rules.
#
# Properties that normal clients may only read
-property XFree86_VT system_u:object_r:info_xproperty_t:s0
-property XFree86_DDC_EDID1_RAWDATA system_u:object_r:info_xproperty_t:s0
-property RESOURCE_MANAGER system_u:object_r:info_xproperty_t:s0
-property SCREEN_RESOURCES system_u:object_r:info_xproperty_t:s0
-property _MIT_PRIORITY_COLORS system_u:object_r:info_xproperty_t:s0
-property AT_SPI_IOR system_u:object_r:info_xproperty_t:s0
-property _SELINUX_CLIENT_CONTEXT system_u:object_r:info_xproperty_t:s0
-property _NET_WORKAREA system_u:object_r:info_xproperty_t:s0
-property _XKB_RULES_NAMES system_u:object_r:info_xproperty_t:s0
+property _SELINUX_* system_u:object_r:seclabel_xproperty_t:s0

# Clipboard and selection properties
-property CUT_BUFFER0 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER1 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER2 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER3 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER4 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER5 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER6 system_u:object_r:clipboard_xproperty_t:s0
-property CUT_BUFFER7 system_u:object_r:clipboard_xproperty_t:s0
+property CUT_BUFFER? system_u:object_r:clipboard_xproperty_t:s0

# Default fallback type
property * system_u:object_r:xproperty_t:s0
@@ -61,57 +46,11 @@ property * system_u:object_r:xproperty_t:s0
# Extension rules map an extension name to a context. A default extension
# rule indicated by an asterisk should follow all other extension rules.
#
-# Standard extensions
-extension BIG-REQUESTS system_u:object_r:std_xext_t:s0
-extension SHAPE system_u:object_r:std_xext_t:s0
-extension SYNC system_u:object_r:std_xext_t:s0
-extension XC-MISC system_u:object_r:std_xext_t:s0
-extension XFIXES system_u:object_r:std_xext_t:s0
-extension XInputExtension system_u:object_r:std_xext_t:s0
-extension XKEYBOARD system_u:object_r:std_xext_t:s0
-extension DAMAGE system_u:object_r:std_xext_t:s0
-extension RENDER system_u:object_r:std_xext_t:s0
-extension XINERAMA system_u:object_r:std_xext_t:s0
-
-# Direct hardware access extensions
-extension XFree86-DGA system_u:object_r:directhw_xext_t:s0
-extension XFree86-VidModeExtension system_u:object_r:directhw_xext_t:s0
-
-# Screen management and multihead extensions
-extension RANDR system_u:object_r:output_xext_t:s0
-extension Composite system_u:object_r:output_xext_t:s0
-
-# Screensaver, power management extensions
-extension DPMS system_u:object_r:screensaver_xext_t:s0
-extension MIT-SCREEN-SAVER system_u:object_r:screensaver_xext_t:s0
-
-# Shared memory extensions
-extension MIT-SHM system_u:object_r:shmem_xext_t:s0
-extension XFree86-Bigfont system_u:object_r:shmem_xext_t:s0
-
-# Accelerated graphics, OpenGL, direct rendering extensions
-extension GLX system_u:object_r:accelgraphics_xext_t:s0
-extension NV-CONTROL system_u:object_r:accelgraphics_xext_t:s0
-extension NV-GLX system_u:object_r:accelgraphics_xext_t:s0
-extension NVIDIA-GLX system_u:object_r:accelgraphics_xext_t:s0
-
-# Debugging, testing, and recording extensions
-extension RECORD system_u:object_r:debug_xext_t:s0
-extension X-Resource system_u:object_r:debug_xext_t:s0
-extension XTEST system_u:object_r:debug_xext_t:s0
-
-# Security-related extensions
-extension SECURITY system_u:object_r:security_xext_t:s0
-extension SELinux system_u:object_r:security_xext_t:s0
-extension XAccessControlExtension system_u:object_r:security_xext_t:s0
-extension XC-APPGROUP system_u:object_r:security_xext_t:s0
-
-# Video extensions
-extension XVideo system_u:object_r:video_xext_t:s0
-extension XVideo-MotionCompensation system_u:object_r:video_xext_t:s0
+# Restricted extensions
+extension SELinux system_u:object_r:security_xextension_t:s0

-# Default fallback type
-extension * system_u:object_r:xext_t:s0
+# Standard extensions
+extension * system_u:object_r:xextension_t:s0


#
@@ -124,8 +63,6 @@ extension * system_u:object_r:xext_t:s0
# rule indicated by an asterisk should follow all other selection rules.
#
# Standard selections
-selection XA_PRIMARY system_u:object_r:clipboard_xselection_t:s0
-selection XA_SECONDARY system_u:object_r:clipboard_xselection_t:s0
selection PRIMARY system_u:object_r:clipboard_xselection_t:s0
selection CLIPBOARD system_u:object_r:clipboard_xselection_t:s0

@@ -149,7 +86,6 @@ event X11:KeyRelease system_u:object_r:input_xevent_t:s0
event X11:ButtonPress system_u:object_r:input_xevent_t:s0
event X11:ButtonRelease system_u:object_r:input_xevent_t:s0
event X11:MotionNotify system_u:object_r:input_xevent_t:s0
-event X11:SelectionNotify system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceKeyPress system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceKeyRelease system_u:object_r:input_xevent_t:s0
event XInputExtension:DeviceButtonPress system_u:object_r:input_xevent_t:s0
@@ -159,36 +95,11 @@ event XInputExtension:DeviceValuator system_u:object_r:input_xevent_t:s0
event XInputExtension:ProximityIn system_u:object_r:input_xevent_t:s0
event XInputExtension:ProximityOut system_u:object_r:input_xevent_t:s0

-# Focus events
-event X11:FocusIn system_u:object_r:focus_xevent_t:s0
-event X11:FocusOut system_u:object_r:focus_xevent_t:s0
-event X11:EnterNotify system_u:object_r:focus_xevent_t:s0
-event X11:LeaveNotify system_u:object_r:focus_xevent_t:s0
-
-# Property events
-event X11:PropertyNotify system_u:object_r:property_xevent_t:s0
-
# Client message events
event X11:ClientMessage system_u:object_r:client_xevent_t:s0
-
-# Manager events
-event X11:ConfigureRequest system_u:object_r:manage_xevent_t:s0
-event X11:ResizeRequest system_u:object_r:manage_xevent_t:s0
-event X11:MapRequest system_u:object_r:manage_xevent_t:s0
-event X11:CirculateRequest system_u:object_r:manage_xevent_t:s0
-event X11:CreateNotify system_u:object_r:manage_xevent_t:s0
-event X11:DestroyNotify system_u:object_r:manage_xevent_t:s0
-event X11:MapNotify system_u:object_r:manage_xevent_t:s0
-event X11:UnmapNotify system_u:object_r:manage_xevent_t:s0
-event X11:ReparentNotify system_u:object_r:manage_xevent_t:s0
-event X11:ConfigureNotify system_u:object_r:manage_xevent_t:s0
-event X11:GravityNotify system_u:object_r:manage_xevent_t:s0
-event X11:CirculateNotify system_u:object_r:manage_xevent_t:s0
-event X11:Expose system_u:object_r:manage_xevent_t:s0
-event X11:VisibilityNotify system_u:object_r:manage_xevent_t:s0
-
-# Unknown events (that are not registered in the X server's name database)
-event<unknown> system_u:object_r:unknown_xevent_t:s0
+event X11:SelectionNotify system_u:object_r:client_xevent_t:s0
+event X11:UnmapNotify system_u:object_r:client_xevent_t:s0
+event X11:ConfigureNotify system_u:object_r:client_xevent_t:s0

# Default fallback type
event * system_u:object_r:xevent_t:s0
diff --git a/config/appconfig-standard/x_contexts b/config/appconfig-standard/x_contexts
index f9cefb9..5b752f8 100644
--- a/config/appconfig-standard/x_contexts
+++ b/config/appconfig-standard/x_contexts
@@ -13,7 +13,7 @@
# The default client rule defines a context to be used for all clients
# connecting to the server from a remote host.
#
-client * system_u:object_r:remote_xclient_t
+client * system_u:object_r:remote_t


#
@@ -27,25 +27,10 @@ client * system_u:object_r:remote_xclient_t
# rule indicated by an asterisk should follow all other property rules.
#
# Properties that normal clients may only read
-property XFree86_VT system_u:object_r:info_xproperty_t
-property XFree86_DDC_EDID1_RAWDATA system_u:object_r:info_xproperty_t
-property RESOURCE_MANAGER system_u:object_r:info_xproperty_t
-property SCREEN_RESOURCES system_u:object_r:info_xproperty_t
-property _MIT_PRIORITY_COLORS system_u:object_r:info_xproperty_t
-property AT_SPI_IOR system_u:object_r:info_xproperty_t
-property _SELINUX_CLIENT_CONTEXT system_u:object_r:info_xproperty_t
-property _NET_WORKAREA system_u:object_r:info_xproperty_t
-property _XKB_RULES_NAMES system_u:object_r:info_xproperty_t
+property _SELINUX_* system_u:object_r:seclabel_xproperty_t

# Clipboard and selection properties
-property CUT_BUFFER0 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER1 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER2 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER3 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER4 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER5 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER6 system_u:object_r:clipboard_xproperty_t
-property CUT_BUFFER7 system_u:object_r:clipboard_xproperty_t
+property CUT_BUFFER? system_u:object_r:clipboard_xproperty_t

# Default fallback type
property * system_u:object_r:xproperty_t
@@ -61,57 +46,11 @@ property * system_u:object_r:xproperty_t
# Extension rules map an extension name to a context. A default extension
# rule indicated by an asterisk should follow all other extension rules.
#
-# Standard extensions
-extension BIG-REQUESTS system_u:object_r:std_xext_t
-extension SHAPE system_u:object_r:std_xext_t
-extension SYNC system_u:object_r:std_xext_t
-extension XC-MISC system_u:object_r:std_xext_t
-extension XFIXES system_u:object_r:std_xext_t
-extension XInputExtension system_u:object_r:std_xext_t
-extension XKEYBOARD system_u:object_r:std_xext_t
-extension DAMAGE system_u:object_r:std_xext_t
-extension RENDER system_u:object_r:std_xext_t
-extension XINERAMA system_u:object_r:std_xext_t
-
-# Direct hardware access extensions
-extension XFree86-DGA system_u:object_r:directhw_xext_t
-extension XFree86-VidModeExtension system_u:object_r:directhw_xext_t
-
-# Screen management and multihead extensions
-extension RANDR system_u:object_r:output_xext_t
-extension Composite system_u:object_r:output_xext_t
-
-# Screensaver, power management extensions
-extension DPMS system_u:object_r:screensaver_xext_t
-extension MIT-SCREEN-SAVER system_u:object_r:screensaver_xext_t
-
-# Shared memory extensions
-extension MIT-SHM system_u:object_r:shmem_xext_t
-extension XFree86-Bigfont system_u:object_r:shmem_xext_t
-
-# Accelerated graphics, OpenGL, direct rendering extensions
-extension GLX system_u:object_r:accelgraphics_xext_t
-extension NV-CONTROL system_u:object_r:accelgraphics_xext_t
-extension NV-GLX system_u:object_r:accelgraphics_xext_t
-extension NVIDIA-GLX system_u:object_r:accelgraphics_xext_t
-
-# Debugging, testing, and recording extensions
-extension RECORD system_u:object_r:debug_xext_t
-extension X-Resource system_u:object_r:debug_xext_t
-extension XTEST system_u:object_r:debug_xext_t
-
-# Security-related extensions
-extension SECURITY system_u:object_r:security_xext_t
-extension SELinux system_u:object_r:security_xext_t
-extension XAccessControlExtension system_u:object_r:security_xext_t
-extension XC-APPGROUP system_u:object_r:security_xext_t
-
-# Video extensions
-extension XVideo system_u:object_r:video_xext_t
-extension XVideo-MotionCompensation system_u:object_r:video_xext_t
+# Restricted extensions
+extension SELinux system_u:object_r:security_xextension_t

-# Default fallback type
-extension * system_u:object_r:xext_t
+# Standard extensions
+extension * system_u:object_r:xextension_t


#
@@ -124,8 +63,6 @@ extension * system_u:object_r:xext_t
# rule indicated by an asterisk should follow all other selection rules.
#
# Standard selections
-selection XA_PRIMARY system_u:object_r:clipboard_xselection_t
-selection XA_SECONDARY system_u:object_r:clipboard_xselection_t
selection PRIMARY system_u:object_r:clipboard_xselection_t
selection CLIPBOARD system_u:object_r:clipboard_xselection_t

@@ -149,7 +86,6 @@ event X11:KeyRelease system_u:object_r:input_xevent_t
event X11:ButtonPress system_u:object_r:input_xevent_t
event X11:ButtonRelease system_u:object_r:input_xevent_t
event X11:MotionNotify system_u:object_r:input_xevent_t
-event X11:SelectionNotify system_u:object_r:input_xevent_t
event XInputExtension:DeviceKeyPress system_u:object_r:input_xevent_t
event XInputExtension:DeviceKeyRelease system_u:object_r:input_xevent_t
event XInputExtension:DeviceButtonPress system_u:object_r:input_xevent_t
@@ -159,36 +95,11 @@ event XInputExtension:DeviceValuator system_u:object_r:input_xevent_t
event XInputExtension:ProximityIn system_u:object_r:input_xevent_t
event XInputExtension:ProximityOut system_u:object_r:input_xevent_t

-# Focus events
-event X11:FocusIn system_u:object_r:focus_xevent_t
-event X11:FocusOut system_u:object_r:focus_xevent_t
-event X11:EnterNotify system_u:object_r:focus_xevent_t
-event X11:LeaveNotify system_u:object_r:focus_xevent_t
-
-# Property events
-event X11:PropertyNotify system_u:object_r:property_xevent_t
-
# Client message events
event X11:ClientMessage system_u:object_r:client_xevent_t
-
-# Manager events
-event X11:ConfigureRequest system_u:object_r:manage_xevent_t
-event X11:ResizeRequest system_u:object_r:manage_xevent_t
-event X11:MapRequest system_u:object_r:manage_xevent_t
-event X11:CirculateRequest system_u:object_r:manage_xevent_t
-event X11:CreateNotify system_u:object_r:manage_xevent_t
-event X11:DestroyNotify system_u:object_r:manage_xevent_t
-event X11:MapNotify system_u:object_r:manage_xevent_t
-event X11:UnmapNotify system_u:object_r:manage_xevent_t
-event X11:ReparentNotify system_u:object_r:manage_xevent_t
-event X11:ConfigureNotify system_u:object_r:manage_xevent_t
-event X11:GravityNotify system_u:object_r:manage_xevent_t
-event X11:CirculateNotify system_u:object_r:manage_xevent_t
-event X11:Expose system_u:object_r:manage_xevent_t
-event X11:VisibilityNotify system_u:object_r:manage_xevent_t
-
-# Unknown events (that are not registered in the X server's name database)
-event<unknown> system_u:object_r:unknown_xevent_t
+event X11:SelectionNotify system_u:object_r:client_xevent_t
+event X11:UnmapNotify system_u:object_r:client_xevent_t
+event X11:ConfigureNotify system_u:object_r:client_xevent_t

# Default fallback type
event * system_u:object_r:xevent_t
--
1.6.5.rc2

2009-10-14 12:53:02

by cpebenito

[permalink] [raw]
Subject: [refpolicy] [PATCH 1/6] Add separate x_pointer and x_keyboard classes inheriting from x_device.

On Tue, 2009-10-13 at 21:27 -0400, Eamon Walsh wrote:
> Add separate x_pointer and x_keyboard classes inheriting from
> x_device.
>
> This is needed to allow more fine-grained control over X devices
> without
> using different types. Using different types is problematic because
> devices act as subjects in the X Flask implementation, and subjects
> cannot be labeled through a type transition (since the output role is
> hardcoded to object_r).

Merged.

> Signed-off-by: Eamon Walsh<[email protected]>
> ---
> policy/flask/access_vectors | 55
> +++++++++++++++++++++++++---------------
> policy/flask/security_classes | 4 +++
> 2 files changed, 38 insertions(+), 21 deletions(-)
>
> diff --git a/policy/flask/access_vectors b/policy/flask/access_vectors
> index 3998b77..6620e4c 100644
> --- a/policy/flask/access_vectors
> +++ b/policy/flask/access_vectors
> @@ -94,6 +94,33 @@ common database
> }
>
> #
> +# Define a common prefix for pointer and keyboard access vectors.
> +#
> +
> +common x_device
> +{
> + getattr
> + setattr
> + use
> + read
> + write
> + getfocus
> + setfocus
> + bell
> + force_cursor
> + freeze
> + grab
> + manage
> + list_property
> + get_property
> + set_property
> + add
> + remove
> + create
> + destroy
> +}
> +
> +#
> # Define the access vectors.
> #
> # class class_name [ inherits common_name ] { permission_name ... }
> @@ -525,27 +552,7 @@ class x_client
> }
>
> class x_device
> -{
> - getattr
> - setattr
> - use
> - read
> - write
> - getfocus
> - setfocus
> - bell
> - force_cursor
> - freeze
> - grab
> - manage
> - list_property
> - get_property
> - set_property
> - add
> - remove
> - create
> - destroy
> -}
> +inherits x_device
>
> class x_server
> {
> @@ -802,3 +809,9 @@ class kernel_service
>
> class tun_socket
> inherits socket
> +
> +class x_pointer
> +inherits x_device
> +
> +class x_keyboard
> +inherits x_device
> diff --git a/policy/flask/security_classes
> b/policy/flask/security_classes
> index 2bd1bf6..fa65db2 100644
> --- a/policy/flask/security_classes
> +++ b/policy/flask/security_classes
> @@ -121,4 +121,8 @@ class kernel_service
>
> class tun_socket
>
> +# Still More SE-X Windows stuff
> +class x_pointer # userspace
> +class x_keyboard # userspace
> +
> # FLASK
> --
> 1.6.5.rc2
>
>
>
>
--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150

2009-10-22 13:32:38

by cpebenito

[permalink] [raw]
Subject: [refpolicy] [PATCH 2/6] Add a "prefix" parameter to xserver_role and xserver_restricted_role.

On Tue, 2009-10-13 at 21:28 -0400, Eamon Walsh wrote:
> Add a "prefix" parameter to xserver_role and xserver_restricted_role.

These need to turn into new xserver_role_template and
xserver_restricted_role_template templates, and the current versions
need to stay, but as deprecated, for compatibility.

> This is required to call xserver_object_types_template and
> xserver_common_x_domain_template from within these interfaces.
>
> Additionally, add a call to xserver_unconfined from within
> xserver_restricted_role. This causes the default user types to
> be unconfined as far as the X object manager is concerned. Only
> non-default types such as mozilla_t are now confined.

> Signed-off-by: Eamon Walsh<[email protected]>
> ---
> policy/modules/apps/wm.if | 2 +-
> policy/modules/roles/staff.te | 2 +-
> policy/modules/roles/sysadm.te | 2 +-
> policy/modules/roles/unprivuser.te | 2 +-
> policy/modules/services/xserver.if | 201
> ++++++++++++++--------------------
> policy/modules/system/userdomain.if | 2 +-
> 6 files changed, 88 insertions(+), 123 deletions(-)
>
> diff --git a/policy/modules/apps/wm.if b/policy/modules/apps/wm.if
> index 313f247..11d78d0 100644
> --- a/policy/modules/apps/wm.if
> +++ b/policy/modules/apps/wm.if
> @@ -75,7 +75,7 @@ template(`wm_role_template',`
> ')
>
> optional_policy(`
> - xserver_role($2, $1_wm_t)
> + xserver_role($1_wm, $2, $1_wm_t)
> ')
> ')
>
> diff --git a/policy/modules/roles/staff.te
> b/policy/modules/roles/staff.te
> index 7433ca0..07af057 100644
> --- a/policy/modules/roles/staff.te
> +++ b/policy/modules/roles/staff.te
> @@ -166,5 +166,5 @@ optional_policy(`
> ')
>
> optional_policy(`
> - xserver_role(staff_r, staff_t)
> + xserver_role(staff, staff_r, staff_t)
> ')
> diff --git a/policy/modules/roles/sysadm.te
> b/policy/modules/roles/sysadm.te
> index 2ed3c67..374add6 100644
> --- a/policy/modules/roles/sysadm.te
> +++ b/policy/modules/roles/sysadm.te
> @@ -444,7 +444,7 @@ optional_policy(`
> ')
>
> optional_policy(`
> - xserver_role(sysadm_r, sysadm_t)
> + xserver_role(sysadm, sysadm_r, sysadm_t)
> ')
>
> optional_policy(`
> diff --git a/policy/modules/roles/unprivuser.te
> b/policy/modules/roles/unprivuser.te
> index 2183644..4c974d1 100644
> --- a/policy/modules/roles/unprivuser.te
> +++ b/policy/modules/roles/unprivuser.te
> @@ -151,5 +151,5 @@ optional_policy(`
> ')
>
> optional_policy(`
> - xserver_role(user_r, user_t)
> + xserver_role(user, user_r, user_t)
> ')
> diff --git a/policy/modules/services/xserver.if
> b/policy/modules/services/xserver.if
> index 6a0f5c1..99bddec 100644
> --- a/policy/modules/services/xserver.if
> +++ b/policy/modules/services/xserver.if
> @@ -5,6 +5,12 @@
> ## Rules required for using the X Windows server
> ## and environment, for restricted users.
> ##</summary>
> +##<param name="prefix">
> +## <summary>
> +## The prefix of the X client domain (e.g., user
> +## is the prefix for user_t).
> +## </summary>
> +##</param>
> ##<param name="role">
> ## <summary>
> ## Role allowed access.
> @@ -22,144 +28,97 @@ interface(`xserver_restricted_role',`
> type user_fonts_t, user_fonts_cache_t,
> user_fonts_config_t;
> type iceauth_t, iceauth_exec_t, iceauth_home_t;
> type xauth_t, xauth_exec_t, xauth_home_t;
> -
> - type info_xproperty_t, rootwindow_t;
> -
> - class x_drawable all_x_drawable_perms;
> - class x_screen all_x_screen_perms;
> - class x_gc all_x_gc_perms;
> - class x_font all_x_font_perms;
> - class x_colormap all_x_colormap_perms;
> - class x_property all_x_property_perms;
> - class x_selection all_x_selection_perms;
> - class x_cursor all_x_cursor_perms;
> - class x_client all_x_client_perms;
> - class x_device all_x_device_perms;
> - class x_server all_x_server_perms;
> - class x_extension all_x_extension_perms;
> - class x_resource all_x_resource_perms;
> - class x_event all_x_event_perms;
> - class x_synthetic_event all_x_synthetic_event_perms;
> ')
>
> - role $1 types { xserver_t xauth_t iceauth_t };
> + role $2 types { xserver_t xauth_t iceauth_t };
>
> # Xserver read/write client shm
> - allow xserver_t $2:fd use;
> - allow xserver_t $2:shm rw_shm_perms;
> + allow xserver_t $3:fd use;
> + allow xserver_t $3:shm rw_shm_perms;
>
> - domtrans_pattern($2, xserver_exec_t, xserver_t)
> - allow xserver_t $2:process signal;
> + domtrans_pattern($3, xserver_exec_t, xserver_t)
> + allow xserver_t $3:process signal;
>
> - allow xserver_t $2:shm rw_shm_perms;
> + allow xserver_t $3:shm rw_shm_perms;
>
> - allow $2 user_fonts_t:dir list_dir_perms;
> - allow $2 user_fonts_t:file read_file_perms;
> + allow $3 user_fonts_t:dir list_dir_perms;
> + allow $3 user_fonts_t:file read_file_perms;
>
> - allow $2 user_fonts_config_t:dir list_dir_perms;
> - allow $2 user_fonts_config_t:file read_file_perms;
> + allow $3 user_fonts_config_t:dir list_dir_perms;
> + allow $3 user_fonts_config_t:file read_file_perms;
>
> - manage_dirs_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> - manage_files_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> + manage_dirs_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
> + manage_files_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
>
> - stream_connect_pattern($2, xserver_tmp_t, xserver_tmp_t,
> xserver_t)
> - files_search_tmp($2)
> + stream_connect_pattern($3, xserver_tmp_t, xserver_tmp_t,
> xserver_t)
> + files_search_tmp($3)
>
> # Communicate via System V shared memory.
> - allow $2 xserver_t:shm r_shm_perms;
> - allow $2 xserver_tmpfs_t:file read_file_perms;
> + allow $3 xserver_t:shm r_shm_perms;
> + allow $3 xserver_tmpfs_t:file read_file_perms;
>
> # allow ps to show iceauth
> - ps_process_pattern($2, iceauth_t)
> + ps_process_pattern($3, iceauth_t)
>
> - domtrans_pattern($2, iceauth_exec_t, iceauth_t)
> + domtrans_pattern($3, iceauth_exec_t, iceauth_t)
>
> - allow $2 iceauth_home_t:file read_file_perms;
> + allow $3 iceauth_home_t:file read_file_perms;
>
> - domtrans_pattern($2, xauth_exec_t, xauth_t)
> + domtrans_pattern($3, xauth_exec_t, xauth_t)
>
> - allow $2 xauth_t:process signal;
> + allow $3 xauth_t:process signal;
>
> # allow ps to show xauth
> - ps_process_pattern($2, xauth_t)
> - allow $2 xserver_t:process signal;
> + ps_process_pattern($3, xauth_t)
> + allow $3 xserver_t:process signal;
>
> - allow $2 xauth_home_t:file read_file_perms;
> + allow $3 xauth_home_t:file read_file_perms;
>
> # for when /tmp/.X11-unix is created by the system
> - allow $2 xdm_t:fd use;
> - allow $2 xdm_t:fifo_file { getattr read write ioctl };
> - allow $2 xdm_tmp_t:dir search;
> - allow $2 xdm_tmp_t:sock_file { read write };
> - dontaudit $2 xdm_t:tcp_socket { read write };
> + allow $3 xdm_t:fd use;
> + allow $3 xdm_t:fifo_file { getattr read write ioctl };
> + allow $3 xdm_tmp_t:dir search;
> + allow $3 xdm_tmp_t:sock_file { read write };
> + dontaudit $3 xdm_t:tcp_socket { read write };
>
> # Client read xserver shm
> - allow $2 xserver_t:fd use;
> - allow $2 xserver_tmpfs_t:file read_file_perms;
> + allow $3 xserver_t:fd use;
> + allow $3 xserver_tmpfs_t:file read_file_perms;
>
> # Read /tmp/.X0-lock
> - allow $2 xserver_tmp_t:file { getattr read };
> + allow $3 xserver_tmp_t:file { getattr read };
>
> - dev_rw_xserver_misc($2)
> - dev_rw_power_management($2)
> - dev_read_input($2)
> - dev_read_misc($2)
> - dev_write_misc($2)
> + dev_rw_xserver_misc($3)
> + dev_rw_power_management($3)
> + dev_read_input($3)
> + dev_read_misc($3)
> + dev_write_misc($3)
> # open office is looking for the following
> - dev_getattr_agp_dev($2)
> - dev_dontaudit_rw_dri($2)
> + dev_getattr_agp_dev($3)
> + dev_dontaudit_rw_dri($3)
> # GNOME checks for usb and other devices:
> - dev_rw_usbfs($2)
> + dev_rw_usbfs($3)
>
> - miscfiles_read_fonts($2)
> + miscfiles_read_fonts($3)
>
> - xserver_common_x_domain_template(user, $2)
> - xserver_xsession_entry_type($2)
> - xserver_dontaudit_write_log($2)
> - xserver_stream_connect_xdm($2)
> + xserver_object_types_template($1)
> + xserver_common_x_domain_template($1, $3)
> + xserver_unconfined($3)
> + xserver_xsession_entry_type($3)
> + xserver_dontaudit_write_log($3)
> + xserver_stream_connect_xdm($3)
> # certain apps want to read xdm.pid file
> - xserver_read_xdm_pid($2)
> + xserver_read_xdm_pid($3)
> # gnome-session creates socket under /tmp/.ICE-unix/
> - xserver_create_xdm_tmp_sockets($2)
> + xserver_create_xdm_tmp_sockets($3)
> # Needed for escd, remove if we get escd policy
> - xserver_manage_xdm_tmp_files($2)
> + xserver_manage_xdm_tmp_files($3)
>
> # Client write xserver shm
> tunable_policy(`allow_write_xshm',`
> - allow $2 xserver_t:shm rw_shm_perms;
> - allow $2 xserver_tmpfs_t:file rw_file_perms;
> + allow $3 xserver_t:shm rw_shm_perms;
> + allow $3 xserver_tmpfs_t:file rw_file_perms;
> ')
> -
> - ##############################
> - #
> - # User X object manager local policy
> - #
> -
> - # manage: xhost X11:ChangeHosts
> - # freeze: metacity X11:GrabKey
> - # force_cursor: metacity X11:GrabPointer
> - allow $2 xserver_t:x_device { manage freeze force_cursor };
> -
> - # gnome-settings-daemon XKEYBOARD:SetControls
> - allow $2 xserver_t:x_server manage;
> -
> - # gnome-settings-daemon RANDR:SelectInput
> - allow $2 xserver_t:x_resource write;
> -
> - # metacity X11:InstallColormap X11:UninstallColormap
> - allow $2 rootwindow_t:x_colormap { install uninstall };
> -
> - # read: gnome-settings-daemon RANDR:GetScreenSizeRange
> - # write: gnome-settings-daemon RANDR:SelectInput
> - # setattr: gnome-settings-daemon X11:GrabKey
> - # manage: metacity X11:ChangeWindowAttributes
> - allow $2 rootwindow_t:x_drawable { read write manage
> setattr };
> -
> - # setattr: metacity X11:InstallColormap
> - allow $2 xserver_t:x_screen { saver_getattr saver_setattr
> setattr };
> -
> - # xrdb X11:ChangeProperty prop=RESOURCE_MANAGER
> - allow $2 info_xproperty_t:x_property { create append write };
> ')
>
> ########################################
> @@ -167,6 +126,12 @@ interface(`xserver_restricted_role',`
> ## Rules required for using the X Windows server
> ## and environment.
> ##</summary>
> +##<param name="prefix">
> +## <summary>
> +## The prefix of the X client domain (e.g., user
> +## is the prefix for user_t).
> +## </summary>
> +##</param>
> ##<param name="role">
> ## <summary>
> ## Role allowed access.
> @@ -184,32 +149,32 @@ interface(`xserver_role',`
> type user_fonts_t, user_fonts_cache_t,
> user_fonts_config_t;
> ')
>
> - xserver_restricted_role($1, $2)
> + xserver_restricted_role($1, $2, $3)
>
> # Communicate via System V shared memory.
> - allow $2 xserver_t:shm rw_shm_perms;
> - allow $2 xserver_tmpfs_t:file rw_file_perms;
> + allow $3 xserver_t:shm rw_shm_perms;
> + allow $3 xserver_tmpfs_t:file rw_file_perms;
>
> - allow $2 iceauth_home_t:file manage_file_perms;
> - allow $2 iceauth_home_t:file { relabelfrom relabelto };
> + allow $3 iceauth_home_t:file manage_file_perms;
> + allow $3 iceauth_home_t:file { relabelfrom relabelto };
>
> - allow $2 xauth_home_t:file manage_file_perms;
> - allow $2 xauth_home_t:file { relabelfrom relabelto };
> + allow $3 xauth_home_t:file manage_file_perms;
> + allow $3 xauth_home_t:file { relabelfrom relabelto };
>
> - manage_dirs_pattern($2, user_fonts_t, user_fonts_t)
> - manage_files_pattern($2, user_fonts_t, user_fonts_t)
> - relabel_dirs_pattern($2, user_fonts_t, user_fonts_t)
> - relabel_files_pattern($2, user_fonts_t, user_fonts_t)
> + manage_dirs_pattern($3, user_fonts_t, user_fonts_t)
> + manage_files_pattern($3, user_fonts_t, user_fonts_t)
> + relabel_dirs_pattern($3, user_fonts_t, user_fonts_t)
> + relabel_files_pattern($3, user_fonts_t, user_fonts_t)
>
> - manage_dirs_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> - manage_files_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> - relabel_dirs_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> - relabel_files_pattern($2, user_fonts_cache_t,
> user_fonts_cache_t)
> + manage_dirs_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
> + manage_files_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
> + relabel_dirs_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
> + relabel_files_pattern($3, user_fonts_cache_t,
> user_fonts_cache_t)
>
> - manage_dirs_pattern($2, user_fonts_config_t,
> user_fonts_config_t)
> - manage_files_pattern($2, user_fonts_config_t,
> user_fonts_config_t)
> - relabel_dirs_pattern($2, user_fonts_config_t,
> user_fonts_config_t)
> - relabel_files_pattern($2, user_fonts_config_t,
> user_fonts_config_t)
> + manage_dirs_pattern($3, user_fonts_config_t,
> user_fonts_config_t)
> + manage_files_pattern($3, user_fonts_config_t,
> user_fonts_config_t)
> + relabel_dirs_pattern($3, user_fonts_config_t,
> user_fonts_config_t)
> + relabel_files_pattern($3, user_fonts_config_t,
> user_fonts_config_t)
>
> ')
>
> diff --git a/policy/modules/system/userdomain.if
> b/policy/modules/system/userdomain.if
> index f209ccf..b9bea7b 100644
> --- a/policy/modules/system/userdomain.if
> +++ b/policy/modules/system/userdomain.if
> @@ -885,7 +885,7 @@
> template(`userdom_restricted_xwindows_user_template',`
> logging_send_audit_msgs($1_t)
> selinux_get_enforce_mode($1_t)
>
> - xserver_restricted_role($1_r, $1_t)
> + xserver_restricted_role($1, $1_r, $1_t)
>
> optional_policy(`
> alsa_read_rw_config($1_t)
> --
> 1.6.5.rc2
>
>
>
>
--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150

2009-10-22 13:33:45

by cpebenito

[permalink] [raw]
Subject: [refpolicy] [PATCH 0/6] Updated X object manager policy: Intro

On Tue, 2009-10-13 at 21:23 -0400, Eamon Walsh wrote:
> This patch series is an updated policy for the X server object manager.
> This is the policy that I was running in Portland for my various demos.
> It includes new x_pointer/x_keyboard classes, unconfined-by-default
> user types, and other changes. The only thing missing here is updated
> mls constraints; I am still working on those.
>
> I need the first patch in the series (x_pointer/x_keyboard classes)
> upstream so that I can use these classes in the X server. Please merge
> this patch expeditiously if possible.
>
> The remaining 5 patches are NOT independent and breakage will probably
> result if only some of them are applied. I only broke them up in an
> attempt to make it easier to review the changes.

I tried to build this so I could use sediff to better understand the
change, but I get many m4 errors.

> This whole thing is also available in a git tree at
> git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
> ease of pulling.
>
>
--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150