2009-10-28 02:05:54

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 0/3] Updated X object manager policy -v2: 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.

The 3 patches here 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 is also available in a git tree at
git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
ease of pulling.

Changes from -v1:

Dropped the x_keyboard/x_pointer object class patch (already pushed).

Dropped the patch making system_dbusd_t and consolekit_t unconfined.
This is so the focus is only on the changes to the xserver module.

No changes to the existing xserver_role and xserver_restricted_role
interfaces. The existing UBAC-based controls have been restored.

Removed an apostrophe in a comment that was causing m4 errors.


--

Eamon Walsh
National Security Agency


2009-10-28 02:18:14

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 1/3] 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 | 273 ++++++++++++++++++++----------------
1 files changed, 152 insertions(+), 121 deletions(-)

diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.te
index fc421d5..d6c4b95 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;
-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 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 Selections
+attribute xselection_type;
+type xselection_t, xselection_type;
+type clipboard_xselection_t, xselection_type;
+#type settings_xselection_t, xselection_type;
+#type dbus_xselection_t, xselection_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)
+# X Drawables
+attribute xdrawable_type;
+attribute xcolormap_type;
+type root_xdrawable_t, xdrawable_type;
+type root_xcolormap_t, xcolormap_type;

-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;
+attribute xserver_unconfined_type;
+attribute xserver_unprotected_type;

+xserver_object_types_template(root)
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 };
+
+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



--

Eamon Walsh
National Security Agency

2009-10-28 02:19:25

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 2/4] 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 | 154 +++++++++++++++---------------------
1 files changed, 64 insertions(+), 90 deletions(-)

diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if
index 6a0f5c1..cffc058 100644
--- a/policy/modules/services/xserver.if
+++ b/policy/modules/services/xserver.if
@@ -22,24 +22,6 @@ 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 };
@@ -114,6 +96,7 @@ interface(`xserver_restricted_role',`
miscfiles_read_fonts($2)

xserver_common_x_domain_template(user, $2)
+ xserver_unconfined($2)
xserver_xsession_entry_type($2)
xserver_dontaudit_write_log($2)
xserver_stream_connect_xdm($2)
@@ -129,37 +112,6 @@ interface(`xserver_restricted_role',`
allow $2 xserver_t:shm rw_shm_perms;
allow $2 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 };
')

########################################
@@ -359,17 +311,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 xdrawable_type, xcolormap_type;
attribute input_xevent_type;

class x_drawable all_x_drawable_perms;
@@ -385,32 +333,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;
+ # dont audit send failures
+ dontaudit $2 input_xevent_type:x_event send;
')

#######################################
@@ -436,27 +380,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)
')

#######################################
@@ -1249,6 +1178,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>
@@ -1260,8 +1232,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



--

Eamon Walsh
National Security Agency

2009-10-28 02:20:38

by Eamon Walsh

[permalink] [raw]
Subject: [refpolicy] [PATCH 3/3] 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



--

Eamon Walsh
National Security Agency

2009-10-28 13:57:25

by cpebenito

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

On Tue, 2009-10-27 at 22:05 -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.
>
> The 3 patches here 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 is also available in a git tree at
> git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
> ease of pulling.

This looks ok. I have this in a branch in my local repo for now, as I
have a couple minor questions/issues:

1) +xserver_object_types_template(root)

Is this for the root window?

2) The aliases that were removed need to be restored, and updated for
the removals this patchset.

3) I'd like to try to find a better name for "xserver_unprotected", if
possible.

Additional patches can be made on top of these.

> Changes from -v1:
>
> Dropped the x_keyboard/x_pointer object class patch (already pushed).
>
> Dropped the patch making system_dbusd_t and consolekit_t unconfined.
> This is so the focus is only on the changes to the xserver module.
>
> No changes to the existing xserver_role and xserver_restricted_role
> interfaces. The existing UBAC-based controls have been restored.
>
> Removed an apostrophe in a comment that was causing m4 errors.
>
>
--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150

2009-10-29 22:57:38

by Eamon Walsh

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

On 10/28/2009 09:57 AM, Christopher J. PeBenito wrote:
> On Tue, 2009-10-27 at 22:05 -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.
>>
>> The 3 patches here 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 is also available in a git tree at
>> git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
>> ease of pulling.
>>
> This looks ok. I have this in a branch in my local repo for now, as I
> have a couple minor questions/issues:
>
> 1) +xserver_object_types_template(root)
>
> Is this for the root window?
>

It defines the root_input_xevent_t type that is used for input events
sent to the root window (if no other window has focus). This is new;
before this patchset they were just labeled generic "input_xevent_t."

If other derived event types are reintroduced they will go in that
template as well so calling it will define root_* variants that can be used.


> 2) The aliases that were removed need to be restored, and updated for
> the removals this patchset.
>

Are you referring to the type aliases here? What needs to be updated?


> 3) I'd like to try to find a better name for "xserver_unprotected", if
> possible.
>

Let's just drop this interface (attached patch). I'm not seeing the
AVC's that motivated this anymore, probably because the default user
types are X unconfined. If they show up again I can resubmit this.



> Additional patches can be made on top of these.
>


--

Eamon Walsh
National Security Agency

-------------- next part --------------
A non-text attachment was scrubbed...
Name: remove_unprotected.patch
Type: text/x-patch
Size: 2782 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20091029/311777f1/attachment.bin

2009-10-30 13:17:08

by cpebenito

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

On Thu, 2009-10-29 at 18:57 -0400, Eamon Walsh wrote:
> On 10/28/2009 09:57 AM, Christopher J. PeBenito wrote:
> > On Tue, 2009-10-27 at 22:05 -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.
> >>
> >> The 3 patches here 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 is also available in a git tree at
> >> git://anongit.freedesktop.org/~ewalsh/refpolicy (branch "master"), for
> >> ease of pulling.
> >>
> > This looks ok. I have this in a branch in my local repo for now, as I
> > have a couple minor questions/issues:
> >
> > 1) +xserver_object_types_template(root)
> >
> > Is this for the root window?
>
> It defines the root_input_xevent_t type that is used for input events
> sent to the root window (if no other window has focus). This is new;
> before this patchset they were just labeled generic "input_xevent_t."
>
> If other derived event types are reintroduced they will go in that
> template as well so calling it will define root_* variants that can be used.
>
>
> > 2) The aliases that were removed need to be restored, and updated for
> > the removals this patchset.
> >
>
> Are you referring to the type aliases here? What needs to be updated?

The ones like these that were removed:

-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 };

They shouldn't be removed, but they should be revised to make them
aliases of the new types. So the above looks like it turns into:

typealias xevent_t alias { staff_property_xevent_t sysadm_property_xevent_t user_property_xevent_t };
typealias xevent_t alias { auditadm_property_xevent_t secadm_property_xevent_t };

or should it be aliased to client_xevent_t (I'm not sure)?

> > 3) I'd like to try to find a better name for "xserver_unprotected", if
> > possible.
> >
>
> Let's just drop this interface (attached patch). I'm not seeing the
> AVC's that motivated this anymore, probably because the default user
> types are X unconfined. If they show up again I can resubmit this.

Merged.

> commit 509cc124f67abc46e9088c05dbe75e0f4d4c94a9
> Author: Eamon Walsh <[email protected]>
> Date: Thu Oct 29 18:47:32 2009 -0400
>
> Drop the xserver_unprotected interface.
>
> The motivation for this was xdm_t objects not getting cleaned up,
> so the user session tried to interact with them. But since the
> default user type is unconfined this problem has gone away for now.
>
> Signed-off-by: Eamon Walsh <[email protected]>
>
> diff --git a/policy/modules/services/xserver.if b/policy/modules/services/xserver.if
> index cffc058..e34a892 100644
> --- a/policy/modules/services/xserver.if
> +++ b/policy/modules/services/xserver.if
> @@ -1200,26 +1200,6 @@ interface(`xserver_manage_core_devices',`
>
> ########################################
> ## <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.
> diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.te
> index d6c4b95..f7e7637 100644
> --- a/policy/modules/services/xserver.te
> +++ b/policy/modules/services/xserver.te
> @@ -82,7 +82,6 @@ type root_xdrawable_t, xdrawable_type;
> type root_xcolormap_t, xcolormap_type;
>
> attribute xserver_unconfined_type;
> -attribute xserver_unprotected_type;
>
> xserver_object_types_template(root)
> xserver_object_types_template(user)
> @@ -157,7 +156,6 @@ 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)
> @@ -950,20 +948,6 @@ 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
> #
>
>
--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150

2009-10-30 22:24:12

by Eamon Walsh

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

On 10/30/2009 09:17 AM, Christopher J. PeBenito wrote:
>
> The ones like these that were removed:
>
> -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 };
>
> They shouldn't be removed, but they should be revised to make them
> aliases of the new types. So the above looks like it turns into:
>
> typealias xevent_t alias { staff_property_xevent_t sysadm_property_xevent_t user_property_xevent_t };
> typealias xevent_t alias { auditadm_property_xevent_t secadm_property_xevent_t };
>
> or should it be aliased to client_xevent_t (I'm not sure)?
>
>

I'm assuming this is for compatibility across a policy reload? Because
these types definitely don't exist on disk anywhere.

Attached patch should fix this.


--

Eamon Walsh
National Security Agency

-------------- next part --------------
A non-text attachment was scrubbed...
Name: add_back_typealias.patch
Type: text/x-patch
Size: 1694 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20091030/ac348025/attachment.bin

2009-11-02 13:45:18

by cpebenito

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

On Fri, 2009-10-30 at 18:24 -0400, Eamon Walsh wrote:
> On 10/30/2009 09:17 AM, Christopher J. PeBenito wrote:
> >
> > The ones like these that were removed:
> >
> > -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 };
> >
> > They shouldn't be removed, but they should be revised to make them
> > aliases of the new types. So the above looks like it turns into:
> >
> > typealias xevent_t alias { staff_property_xevent_t sysadm_property_xevent_t user_property_xevent_t };
> > typealias xevent_t alias { auditadm_property_xevent_t secadm_property_xevent_t };
> >
> > or should it be aliased to client_xevent_t (I'm not sure)?
> >
> >
>
> I'm assuming this is for compatibility across a policy reload? Because
> these types definitely don't exist on disk anywhere.
>
> Attached patch should fix this.

It's not adding an alias for the user_*_xevent_t types; I'll fix that in
the merge.

> --
>
> Eamon Walsh
> National Security Agency
>
>
>
>
>
>
>
>
> differences between files attachment (add_back_typealias.patch)
>
> commit f4c928970788550ad0e366bd5a23005d8aa42764
> Author: Eamon Walsh <[email protected]>
> Date: Fri Oct 30 18:14:05 2009 -0400
>
> Add back removed typealiases.
>
> I'm assuming this is for compatibility across a policy reload.
>
> Signed-off-by: Eamon Walsh <[email protected]>
>
> diff --git a/policy/modules/services/xserver.te b/policy/modules/services/xserver.te
> index f7e7637..2784f0d 100644
> --- a/policy/modules/services/xserver.te
> +++ b/policy/modules/services/xserver.te
> @@ -90,6 +90,16 @@ 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 xevent_t alias { staff_property_xevent_t sysadm_property_xevent_t };
> +typealias xevent_t alias { auditadm_property_xevent_t secadm_property_xevent_t };
> +typealias xevent_t alias { staff_focus_xevent_t sysadm_focus_xevent_t };
> +typealias xevent_t alias { auditadm_focus_xevent_t secadm_focus_xevent_t };
> +typealias xevent_t alias { staff_manage_xevent_t sysadm_manage_xevent_t };
> +typealias xevent_t alias { auditadm_manage_xevent_t secadm_manage_xevent_t };
> +typealias xevent_t alias { staff_default_xevent_t sysadm_default_xevent_t };
> +typealias xevent_t alias { auditadm_default_xevent_t secadm_default_xevent_t };
> +typealias client_xevent_t alias { staff_client_xevent_t sysadm_client_xevent_t };
> +typealias client_xevent_t alias { auditadm_client_xevent_t secadm_client_xevent_t };
>
> type remote_t;
> xserver_object_types_template(remote)
>
>

--
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150