From: guido@trentalancia.net (Guido Trentalancia) Date: Mon, 08 Aug 2016 18:56:37 +0200 Subject: [refpolicy] [PATCH v3 2/2] Correctly label files under /lib/firmware In-Reply-To: <1470673622.10405.9.camel@trentalancia.net> References: <1470670886.10405.7.camel@trentalancia.net> <1470673622.10405.9.camel@trentalancia.net> Message-ID: <1470675397.2909.1.camel@trentalancia.net> To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com Create a new "firmware_t" file type, an interface to read such type of files, an interface to search directories containing such type of files and finally make sure that files under /lib/firmware (firmware data files usually shipped with the kernel) are properly labeled using the new label. Signed-off-by: Guido Trentalancia --- policy/modules/kernel/files.fc | 2 ++ policy/modules/kernel/files.if | 38 ++++++++++++++++++++++++++++++++++++++ policy/modules/kernel/files.te | 6 ++++++ 3 files changed, 46 insertions(+) --- refpolicy-git-06082016-orig/policy/modules/kernel/files.fc 2016-08-06 21:26:43.283774146 +0200 +++ refpolicy-git-06082016/policy/modules/kernel/files.fc 2016-08-08 18:04:04.403079629 +0200 @@ -107,6 +107,8 @@ HOME_ROOT/lost\+found/.* <> # /lib(64)? # /lib/modules(/.*)? gen_context(system_u:object_r:modules_object_t,s0) +/lib/firmware -d gen_context(system_u:object_r:firmware_t,s0) +/lib/firmware/.* gen_context(system_u:object_r:firmware_t,s0) ifdef(`distro_debian',` # on Debian /lib/init/rw is a tmpfs used like /var/run but --- refpolicy-git-06082016-orig/policy/modules/kernel/files.if 2016-08-06 21:26:43.284774157 +0200 +++ refpolicy-git-06082016/policy/modules/kernel/files.if 2016-08-08 18:42:32.255597221 +0200 @@ -3992,6 +3992,24 @@ interface(`files_search_kernel_modules', ######################################## ## +## Search the contents of /lib/firmware directories. +## +## +## +## Domain allowed access. +## +## +# +interface(`files_search_firmware',` + gen_require(` + type firmware_t; + ') + + allow $1 firmware_t:dir search_dir_perms; +') + +######################################## +## ## List the contents of the kernel module directories. ## ## @@ -4157,6 +4175,26 @@ interface(`files_kernel_modules_filetran ') ######################################## +## +## Read firmware files. +## +## +## +## Domain allowed access. +## +## +# +interface(`files_read_firmware_files',` + gen_require(` + type firmware_t; + ') + + allow $1 firmware_t:dir list_dir_perms; + read_files_pattern($1, firmware_t, firmware_t) + read_lnk_files_pattern($1, firmware_t, firmware_t) +') + +######################################## ## ## List world-readable directories. ## --- refpolicy-git-06082016-orig/policy/modules/kernel/files.te 2016-08-06 21:26:43.284774157 +0200 +++ refpolicy-git-06082016/policy/modules/kernel/files.te 2016-08-08 18:15:48.314379707 +0200 @@ -98,6 +98,12 @@ files_mountpoint(mnt_t) type modules_object_t; files_type(modules_object_t) +# +# firmware_t is the type for firmware files +# +type firmware_t; +files_type(firmware_t) + type no_access_t; files_type(no_access_t)