【问题标题】:Add new security policy in SElinux on Android 10在 Android 10 上的 SElinux 中添加新的安全策略
【发布时间】:2021-05-28 19:03:32
【问题描述】:

我希望女巫 /dev/i2c-1 设备不受 Android 10 上的 SELinux 安全政策的约束。

我有 Android 10 的源代码。我尝试在 /device/thales/mt8768q/sepolicy/edgelab.te 中创建一个 .te 文件

在 foo.te 中,我在网站上添加了一个类似的示例:https://source.android.com/security/selinux/customize

allow domain i2c-1_device:chr_file rw_file_perms

但是,在编译过程中,这一行会产生错误。

更新:

我在/device/manufacturer/device-name/BoardConfig.mk 上添加新行:

BOARD_SEPOLICY_DIRS += device/thales/mt8768q/sepolicy

错误是:

#line 206
device/mediatek/mt6765/sepolicy/bsp/mnld.te:8:ERROR 'syntax error' at token 'role' on line 97225:
#line 2 "device/thales/mt8768q/sepolicy/edgelab.te"
allow domain i2c-1_device:chr_file { { getattr open read ioctl lock map } { open append write lock map } }role r;
checkpolicy:  error(s) encountered while parsing configuration

可能i2c-1_device 不是有效名称,但我不知道如何在.te 文件中引用/dev/i2c-1

【问题讨论】:

  • 如果您不分享错误,就无法提供帮助

标签: android android-source selinux seandroid


【解决方案1】:

您应该定义您的域和标签。

  1. 定义您的 dev_type (device/"manufacturer"/"device-name"/sepolicy/"your-filename".te):

    类型 i2c-1_device, dev_type;

  2. 使用您的类型标记文件(设备/“制造商”/“设备名称”/sepolicy/file_contexts):

    /dev/i2c-1/* u:object_r:i2c-1_device:s0

  3. 定义您的规则(设备/“制造商”/“设备名称”/“您的文件名”.te):

    允许域 i2c-1_device:chr_file rw_file_perms

您最好定义您的域并限制只有您的域可以访问 i2c-1_device。 example 定义了一个 dhcp 域,这是一个很好的例子。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-02-08
    • 1970-01-01
    • 2019-02-11
    • 1970-01-01
    • 2023-02-04
    • 1970-01-01
    • 2013-04-19
    • 2010-12-03
    相关资源
    最近更新 更多