【问题标题】:How to disable SELinux or allow a new domain in SELinux policy in AOSP 9 build?如何在 AOSP 9 构建的 SELinux 策略中禁用 SELinux 或允许新域?
【发布时间】:2019-05-09 14:28:43
【问题描述】:

我正在尝试使用新的守护程序构建 AOSP 9,但 SELinux 不允许我这样做。 我的 sierra_config_ip.te 有这个文件的开头:

type sierra_config_ip, domain;
permissive sierra_config_ip;
type sierra_config_ip_exec, exec_type, file_type;

init_daemon_domain(sierra_config_ip)

我的文件上下文是:

/(vendor|system/vendor)/bin/init.config.ip      u:object_r:sierra_config_ip_exec:s0

我的 init.rc 是:

service sierra_config_ip /vendor/bin/init.config.ip
    class main
    user root
    group radio cache inet misc dhcp
    capabilities BLOCK_SUSPEND NET_ADMIN NET_RAW
    disabled
    oneshot

但我总是收到以下错误:

[  0% 3/56037] build out/target/product/evk_8mm/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows
FAILED: out/target/product/evk_8mm/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows 
/bin/bash -c "(rm -f out/target/product/evk_8mm/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows ) && (ASAN_OPTIONS=detect_leaks=0 out/host/linux-x86/bin/checkpolicy -M -c      30 -o out/target/product/evk_8mm/obj/ETC/sepolicy_neverallows_intermediates/sepolicy_neverallows out/target/product/evk_8mm/obj/ETC/sepolicy_neverallows_intermediates/policy.conf )"
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_dhcpcd sierra_dhcpcd_exec:file { execute entrypoint };
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_config_ip sierra_config_ip_exec:file { execute entrypoint };
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_config_ip toolbox_exec:file { execute execute_no_trans };
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_config_ip dhcp_exec:file { execute execute_no_trans };
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_config_ip shell_exec:file { execute execute_no_trans };
libsepol.report_failure: neverallow on line 1005 of system/sepolicy/public/domain.te (or line 11245 of policy.conf) violated by allow sierra_dhcpcd toolbox_exec:file { execute execute_no_trans };
libsepol.report_failure: neverallow on line 873 of system/sepolicy/public/domain.te (or line 10996 of policy.conf) violated by allow sierra_config_ip net_data_file:dir { search };
libsepol.report_failure: neverallow on line 873 of system/sepolicy/public/domain.te (or line 10996 of policy.conf) violated by allow sierra_dhcpcd net_data_file:dir { search };
libsepol.report_failure: neverallow on line 846 of system/sepolicy/public/domain.te (or line 10945 of policy.conf) violated by allow sierra_config_ip net_data_file:file { open };
libsepol.report_failure: neverallow on line 846 of system/sepolicy/public/domain.te (or line 10945 of policy.conf) violated by allow sierra_config_ip dhcp_data_file:file { create setattr lock map unlink rename open };
libsepol.check_assertions: 10 neverallow failures occurred
Error while expanding policy

我不知道为什么不起作用,我按照此处其他主题中描述的步骤进行操作,例如this one。有人可以帮我解决这个问题吗?

除此之外,我尝试禁用 SELinux 以最终能够构建 Android。为此,我把它放了

enforcing=0 androidboot.selinux=disabled

在BoardConfig.mk中的BOARD_KERNEL_CMDLINE中,但是策略是之前构建的,错误再次出现!

我还尝试将 -sierra_config_ip 放入 domain.te:

full_treble_only(`
    # Do not allow vendor components to execute files from system
    # except for the ones whitelist here.
    neverallow {
        domain
        -coredomain
        -appdomain
        -vendor_executes_system_violators
        -vendor_init
        -evs_domain
        -sierra_config_ip
    } {
        exec_type
        -vendor_file_type
        -crash_dump_exec
        -netutils_wrapper_exec
    }:file { entrypoint execute execute_no_trans };
')

但我收到以下错误:

system/sepolicy/public/domain.te:1005:ERROR 'unknown type sierra_config_ip' at token ';' on line 11251:
#line 1005
    }:file { entrypoint execute execute_no_trans };

【问题讨论】:

标签: selinux android-9.0-pie


【解决方案1】:

需要在device/fsl/XXX/XXX/BoardConfig.mk中添加如下“BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive”

更完整的例子:

# Kernel
BOARD_KERNEL_BASE := 0x80000000
BOARD_KERNEL_CMDLINE := console=null androidboot.hardware=qcom msm_rtb.filter=0x237 ehci-hcd.park=3
BOARD_KERNEL_CMDLINE += lpm_levels.sleep_disabled=1 androidboot.bootdevice=7824900.sdhci loop.max_part=7
BOARD_KERNEL_CMDLINE += firmware_class.path=/vendor/firmware_mnt/image 
BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive
BOARD_KERNEL_IMAGE_NAME := Image.gz-dtb
BOARD_KERNEL_OFFSET = 0x00008000
BOARD_KERNEL_PAGESIZE := 2048
BOARD_KERNEL_TAGS_OFFSET := 0x00000100
BOARD_RAMDISK_OFFSET := 0x01000000
TARGET_KERNEL_ARCH := arm64
TARGET_KERNEL_SOURCE := kernel/lenovo/msm8953

完整来源: https://github.com/darran-kelinske-fivestars/android_device_lenovo_tb-common/blob/ade087a14b713c163f0a92e156e9e8f82a447d22/BoardConfigCommon.mk#L150

【讨论】:

    猜你喜欢
    • 2013-04-19
    • 2022-01-12
    • 2023-04-09
    • 2015-07-14
    • 2014-12-03
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2017-04-26
    相关资源
    最近更新 更多