Chris PeBenito 17de1b
Chris PeBenito d15dd5
policy_module(devices,1.1.18)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
attribute device_node;
Chris PeBenito 17de1b
attribute memory_raw_read;
Chris PeBenito 17de1b
attribute memory_raw_write;
Chris PeBenito 17de1b
attribute devices_unconfined_type;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# device_t is the type of /dev.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type device_t;
Chris PeBenito 17de1b
fs_associate_tmpfs(device_t)
Chris PeBenito 17de1b
files_type(device_t)
Chris PeBenito 17de1b
files_mountpoint(device_t)
Chris PeBenito 17de1b
files_associate_tmp(device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for /dev/agpgart
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type agp_device_t;
Chris PeBenito 17de1b
dev_node(agp_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for /dev/apm_bios
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type apm_bios_t;
Chris PeBenito 17de1b
dev_node(apm_bios_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type cardmgr_dev_t;
Chris PeBenito 17de1b
dev_node(cardmgr_dev_t)
Chris PeBenito 17de1b
files_tmp_file(cardmgr_dev_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# clock_device_t is the type of
Chris PeBenito 17de1b
# /dev/rtc.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type clock_device_t;
Chris PeBenito 17de1b
dev_node(clock_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# cpu control devices /dev/cpu/0/*
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type cpu_device_t;
Chris PeBenito 17de1b
dev_node(cpu_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# for the IBM zSeries z90crypt hardware ssl accelorator
Chris PeBenito 17de1b
type crypt_device_t;
Chris PeBenito 17de1b
dev_node(crypt_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type dri_device_t;
Chris PeBenito 17de1b
dev_node(dri_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type event_device_t;
Chris PeBenito 17de1b
dev_node(event_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for framebuffer /dev/fb/*
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type framebuf_device_t;
Chris PeBenito 17de1b
dev_node(framebuf_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for /dev/mapper/control
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type lvm_control_t;
Chris PeBenito 17de1b
dev_node(lvm_control_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# memory_device_t is the type of /dev/kmem,
Chris PeBenito 17de1b
# /dev/mem and /dev/port.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type memory_device_t;
Chris PeBenito 17de1b
dev_node(memory_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
neverallow ~{ memory_raw_read devices_unconfined_type } memory_device_t:{ chr_file blk_file } read;
Chris PeBenito 17de1b
neverallow ~{ memory_raw_write devices_unconfined_type } memory_device_t:{ chr_file blk_file } { append write };
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type misc_device_t;
Chris PeBenito 17de1b
dev_node(misc_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# A more general type for mouse devices.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type mouse_device_t;
Chris PeBenito 17de1b
dev_node(mouse_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for /dev/cpu/mtrr and /proc/mtrr
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type mtrr_device_t;
Chris PeBenito 17de1b
dev_node(mtrr_device_t)
Chris PeBenito 17de1b
genfscon proc /mtrr gen_context(system_u:object_r:mtrr_device_t,s0)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# null_device_t is the type of /dev/null.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type null_device_t;
Chris PeBenito 17de1b
dev_node(null_device_t)
Chris PeBenito 17de1b
mls_trusted_object(null_device_t)
Chris PeBenito 17de1b
sid devnull gen_context(system_u:object_r:null_device_t,s0)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for /dev/pmu 
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type power_device_t;
Chris PeBenito 17de1b
dev_node(power_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type printer_device_t;
Chris PeBenito 17de1b
dev_node(printer_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# random_device_t is the type of /dev/random
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type random_device_t;
Chris PeBenito 17de1b
dev_node(random_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type scanner_device_t;
Chris PeBenito 17de1b
dev_node(scanner_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Type for sound devices and mixers
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type sound_device_t;
Chris PeBenito 17de1b
dev_node(sound_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# sysfs_t is the type for the /sys pseudofs
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type sysfs_t;
Chris PeBenito 17de1b
files_mountpoint(sysfs_t)
Chris PeBenito 17de1b
fs_type(sysfs_t)
Chris PeBenito 17de1b
genfscon sysfs / gen_context(system_u:object_r:sysfs_t,s0)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# urandom_device_t is the type of /dev/urandom
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type urandom_device_t;
Chris PeBenito 17de1b
dev_node(urandom_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# usbfs_t is the type for the /proc/bus/usb pseudofs
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type usbfs_t alias usbdevfs_t;
Chris PeBenito 17de1b
files_mountpoint(usbfs_t)
Chris PeBenito 17de1b
fs_noxattr_type(usbfs_t)
Chris PeBenito 17de1b
genfscon usbfs / gen_context(system_u:object_r:usbfs_t,s0)
Chris PeBenito 17de1b
genfscon usbdevfs / gen_context(system_u:object_r:usbfs_t,s0)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# usb_device_t is the type for /dev/bus/usb/[0-9]+/[0-9]+
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type usb_device_t;
Chris PeBenito 17de1b
dev_node(usb_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type v4l_device_t;
Chris PeBenito 17de1b
dev_node(v4l_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# Type for vmware devices.
Chris PeBenito 17de1b
type vmware_device_t;
Chris PeBenito 17de1b
dev_node(vmware_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type watchdog_device_t;
Chris PeBenito 17de1b
dev_node(vmware_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type xen_device_t;
Chris PeBenito 17de1b
dev_node(xen_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type xserver_misc_device_t;
Chris PeBenito 17de1b
dev_node(xserver_misc_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# zero_device_t is the type of /dev/zero.
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
type zero_device_t;
Chris PeBenito 17de1b
dev_node(zero_device_t)
Chris PeBenito 17de1b
mls_trusted_object(zero_device_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Rules for all device nodes
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
fs_associate(device_node)
Chris PeBenito 17de1b
fs_associate_tmpfs(device_node)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
files_associate_tmp(device_node)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Unconfined access to this module
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
allow devices_unconfined_type self:capability sys_rawio;
Chris PeBenito 17de1b
allow devices_unconfined_type device_node:{ blk_file chr_file } *;
Chris PeBenito 8b9ebd
allow devices_unconfined_type mtrr_device_t:file *;