From: guido@trentalancia.net (Guido Trentalancia) Date: Sat, 13 Aug 2016 15:14:47 +0200 Subject: [refpolicy] [PATCH v3 2/2] Correctly label files under /lib/firmware In-Reply-To: <1b379d3f-6a85-3a6f-5392-0f4a72962d83@ieee.org> References: <1470670886.10405.7.camel@trentalancia.net> <1470673622.10405.9.camel@trentalancia.net> <1470675397.2909.1.camel@trentalancia.net> <1b379d3f-6a85-3a6f-5392-0f4a72962d83@ieee.org> Message-ID: <1471094087.21480.6.camel@trentalancia.net> To: refpolicy@oss.tresys.com List-Id: refpolicy.oss.tresys.com Hello Chris. On Sat, 13/08/2016 at 08.55 -0400, Chris PeBenito wrote: > On 08/08/16 12:56, Guido Trentalancia wrote: > > 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. > > I'm not clear why a new type is needed.??The code should generally > be? > read-only, not executable, and is otherwise non-sensitive.??It seems? > like usr_t would be more appropriate to label the firmware files, > than? > the current lib_t. I have created a new version of the patch, where a specific firmware type is created so that permissions can be granted to read the corresponding file context only, instead of generic lib_t read permissions. > > 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 20 > > 16-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:mo > > dules_object_t,s0) > > +/lib/firmware -d gen_context(system_u:object > > _r:firmware_t,s0) > > +/lib/firmware/.* gen_context(system_u:object_r:firm > > ware_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 20 > > 16-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 20 > > 16-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) Regards, Guido