How to gain access to a kernel node under Android 5.0 seandroid

Source: Internet
Author: User

Android 5.0, because of the seandroid/selinux security mechanism, even if you have root privileges, or a kernel node set to 777 of the permissions, still cannot be accessed at the JNI layer. This article will use a user-defined kernel node/DEV/WF_BTAs an example, hands-on teaches the reader how to gain access to the node in the JNI layer.
The first step: find the process that needs to access the kernel node, the author myself This node is accessed by the System_server process
Step Two: Open the file androidl/android/external/sepolicy/file_contexts.be the same as in this file, define the name you want for this:
/dev/tegra.* u:object_r:video_device:s0/dev/tf_driver u:object_r:tee_device:s0/dev/tty U:object_r:owntty_device: s0/dev/tty[0-9]* u:object_r:tty_device:s0# We Add here/dev/wf_bt              u:object_r:wf_bt_device:s0
Wf_bt_device is custom, and the other left and right sides of the content are consistent with the example above.
The third step: Open the file Androidl/android/external/sepolicy/device.te in the same style as in this file, the second step has just written Wf_bt_device declared as Dev_type:
# device Typestype device, Dev_type, Fs_type;type alarm_device, Dev_type, Mlstrustedobject;type Adb_device, Dev_type; Type Ashmem_device, Dev_type, Mlstrustedobject;type Audio_device, Dev_type;type binder_device, Dev_type, Mlstrustedobject;type Block_device, dev_type;# We add Heretype wf_bt_device, Dev_type;

Fourth Step: androidl/android/external/sepolicy/ Many. te files in the directory end with the process name, such as Surfaceflinger for the Surfaceflinger process, with Vold.te for the vold process, just from the first step, the node is accessed by the System_server process, So, we find system_server.te open, join to allow this process to read and write permission to/DEV/WF_BT,
# Read/write To/proc/net/xt_qtaguid/ctrl and And/dev/xt_qtaguid.allow system_server qtaguid_proc:file rw_file_perms; Allow System_server Qtaguid_device:chr_file rw_file_perms;# Chr_file represents a character device file, if it is a plain file, please use the directory dir# Rw_file_ Perms represents read and Write permissions allow System_server wf_bt_device:chr_file rw_file_perms;
This means that the system_server process is allowed to have read and write access to the Wf_bt_device character device. After you change this, you can make installclean;make-j16 compile the image to verify that the permissions are successful.
FD =open ("/dev/wf_bt", O_rdonly | O_noctty); ABSOLUTE SUCCESS!!!!!
Acknowledgement: Thank Joly_xie

How to gain access to a kernel node under Android 5.0 seandroid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.