Android5.1.1 source code, android source code

Source: Internet
Author: User

Android5.1.1 source code, android source code
Preface

All Android Application processes are obtained from zygote fork, and the new fork application processes still maintain the root permission, which is obviously not allowed, therefore, the permissions of the fork sub-process must be downgraded. This article describes where the Android source code executes the permission downgrade operation.

 

If you do not know what zygote is, or are curious about how zygote starts, you can read the article of Lao Luo:
Source code analysis of the Startup Process of the Android system process Zygote

 

Execution path

The following runSelectLoop method is a member method of ZygoteInit. It is in the file "frameworks/base/core/java/com/android/internal/OS/ZygoteInit. java, the following is its source code:

Zygote waits for the client to notify you to start a new application in this method. For more information, see the articles listed in the preface. Now we are concerned about done = peers. get (index ). runOnce (); Statement, which calls the runOnce method to start a new application process. The runOnce method is a member method of the ZygoteConnection class.

The ZygoteConnection. runOnce method is in the file "frameworks/base/core/java/com/android/internal/OS/ZygoteConnection. java". The following is its source code:

 

ParsedArgs stores information about the application to be started. Its type is Arguments, and Arguments is the internal class of ZygoteConnection.

Zygote is called in runOnce method. forkAndSpecialize method, which is in the file "frameworks/base/core/java/com/android/internal/OS/Zygote. java, the following is its source code:

 

The nativeForkAndSpecialize method is called in this method.

NativeForkAndSpecialize is a native method. In native code, its function name is callback. This function is in the file "frameworks/base/core/jni/com_android_internal_ OS _Zygote.cpp". The following is its source code:

 

The ForkAndSpecializeCommon function is called in this function.

 

Subprocess permission downgrade Function

The ForkAndSpecializeCommon function calls the fork function in the file "frameworks/base/core/jni/com_android_internal_ OS _Zygote.cpp", and the subprocess that generates the fork function degrades its permissions, the following is its source code:

The sub-processes in this function call SetGids, SetRLimits, setresgid, and setresuid respectively, and set the group ID and user ID to downgrade their permissions.

 

 

Author: xunyu @ Alibaba mobile security. For more security technology blogs, clickAlibaba Cloud universal security blog

 

Related Article

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.