2019-09-30 19:00:55 +02:00
|
|
|
# System and vendor domains for BoringSSL self test binaries.
|
|
|
|
#
|
|
|
|
# For FIPS compliance, all processes linked against libcrypto perform a startup
|
|
|
|
# self test which computes a hash of the BoringSSL Crypto Module (BCM) and, at least once
|
|
|
|
# per device boot, also run a series of Known Answer Tests (KAT) to verify functionality.
|
|
|
|
#
|
|
|
|
# The KATs are expensive, and to ensure they are run as few times as possible, they
|
|
|
|
# are skipped if a marker file exists in /dev/boringssl/selftest whose name is
|
|
|
|
# the hash of the BCM that was computed earlier. The files are zero length and their contents
|
|
|
|
# should never be read or written. To avoid giving arbitrary processes access to /dev/boringssl
|
|
|
|
# to create these marker files, there are dedicated self test binaries which this policy
|
|
|
|
# gives access to and which are run during early-init.
|
|
|
|
#
|
|
|
|
# Due to build skew, the version of libcrypto in /vendor may have a different hash than
|
|
|
|
# the system one. To cater for this there are vendor variants of the self test binaries
|
|
|
|
# which also have permission to write to the same files in /dev/boringssl. In the case where
|
|
|
|
# vendor and system libcrypto have the same hash, there will be a race to create the file,
|
|
|
|
# but this is harmless.
|
|
|
|
#
|
|
|
|
# If the self tests fail, then the device should reboot into firmware and for this reason
|
|
|
|
# the system boringssl_self_test domain needs to be in coredomain. As vendor domains
|
|
|
|
# are not allowed in coredomain, this means that the vendor self tests cannot trigger a
|
|
|
|
# reboot. However every binary linked against the vendor libcrypto will abort on startup,
|
|
|
|
# so in practice the device will crash anyway in this unlikely scenario.
|
|
|
|
|
|
|
|
# System boringssl_self_test domain
|
2019-09-08 01:52:15 +02:00
|
|
|
type boringssl_self_test, domain, coredomain;
|
2019-08-28 23:08:50 +02:00
|
|
|
type boringssl_self_test_exec, system_file_type, exec_type, file_type;
|
|
|
|
|
2019-09-30 19:00:55 +02:00
|
|
|
# Vendor boringssl_self_test domain
|
|
|
|
type vendor_boringssl_self_test, domain;
|
|
|
|
type vendor_boringssl_self_test_exec, vendor_file_type, exec_type, file_type;
|
|
|
|
|
|
|
|
# Switch to boringssl_self_test security domain when running boringssl_self_test_exec
|
2019-08-28 23:08:50 +02:00
|
|
|
init_daemon_domain(boringssl_self_test)
|
|
|
|
|
2019-09-30 19:00:55 +02:00
|
|
|
# Switch to vendor_boringssl_self_test security domain when running vendor_boringssl_self_test_exec
|
|
|
|
init_daemon_domain(vendor_boringssl_self_test)
|
|
|
|
|
|
|
|
# Marker files, common to both domains, indicating KAT have been performed on a particular libcrypto
|
|
|
|
#
|
|
|
|
# The files are zero length so there is no issue if both vendor and system code
|
|
|
|
# try to create the same file simultaneously. One will succeed and the other will fail
|
|
|
|
# silently, i.e. still indicate success. Similar harmless naming collisions will happen in the
|
|
|
|
# system domain e.g. when system and APEX copies of libcrypto are identical.
|
|
|
|
type boringssl_self_test_marker, file_type;
|
|
|
|
|
|
|
|
# Allow self test binaries to create/check for the existence of boringssl_self_test_marker files
|
|
|
|
allow { boringssl_self_test vendor_boringssl_self_test }
|
|
|
|
boringssl_self_test_marker:file create_file_perms;
|
|
|
|
allow { boringssl_self_test vendor_boringssl_self_test }
|
|
|
|
boringssl_self_test_marker:dir ra_dir_perms;
|
2019-08-28 23:08:50 +02:00
|
|
|
|
2019-09-30 19:00:55 +02:00
|
|
|
# Allow self test binaries to write their stdout/stderr messages to kmsg_debug
|
|
|
|
allow { boringssl_self_test vendor_boringssl_self_test }
|
|
|
|
kmsg_debug_device:chr_file { w_file_perms getattr ioctl };
|
2019-09-24 01:22:58 +02:00
|
|
|
|
2019-09-30 19:00:55 +02:00
|
|
|
# No other process should be able to create marker files because their existence causes the
|
|
|
|
# boringssl KAT to be skipped.
|
2019-08-28 23:08:50 +02:00
|
|
|
neverallow {
|
|
|
|
domain
|
2019-09-30 19:00:55 +02:00
|
|
|
-vendor_boringssl_self_test
|
2019-08-28 23:08:50 +02:00
|
|
|
-boringssl_self_test
|
|
|
|
-init
|
|
|
|
-vendor_init
|
|
|
|
} boringssl_self_test_marker:file no_rw_file_perms;
|
2019-09-11 20:11:46 +02:00
|
|
|
|
|
|
|
neverallow {
|
|
|
|
domain
|
2019-09-30 19:00:55 +02:00
|
|
|
-vendor_boringssl_self_test
|
2019-09-11 20:11:46 +02:00
|
|
|
-boringssl_self_test
|
|
|
|
-init
|
|
|
|
-vendor_init
|
|
|
|
} boringssl_self_test_marker:dir write;
|