Document directory
- 1. Added system calls.
- 2. Add at_secure to linker
Android security defense (2): seandroid bionic
Recently, seandroid will conduct comparative analysis on various modules, learn to transplant SELinux to Android, and learn program control policies.
As the first analysis module, bionic briefly describes seandroid for later understanding.
The differences between seandroid and Android are summarized as follows: seandroid = SELinux + Android controls applications through Mac to improve the security of native Android systems.
How to control programs in seandroid
In a word, the program sends a request to seandroid (SELinux). seandroid performs policy analysis based on the policy database, compares the security context, and controls the resource access of the application.
Seandroid bionic
Seandroid has the same architecture and mechanism as SELinux. Considering the characteristics of mobile devices, only a subset of SELinux is transplanted to seandroid.
1. Added system calls.
Compared with Android, seandroid bionic adds 12 system calls:
int fsetxattr(int, const char *, const void *, size_t, int)ssize_t fgetxattr(int, const char *, void *, size_t)ssize_t flistxattr(int, char *, size_t)int fremovexattr(int, const char *)int setxattr(const char *, const char *, const void *, size_t, int)int lsetxattr(const char *, const char *, const void *, size_t, int)ssize_t getxattr(const char *, const char *, void *, size_t)ssize_t lgetxattr(const char *, const char *, void *, size_t)ssize_t listxattr(const char *, char *, size_t)ssize_t llistxattr(const char *, char *, size_t)int removexattr(const char *, const char *)int lremovexattr(const char *, const char *)
2. Add at_secure to linker
SELinux sets the at_secure auxv flag for the loaded application, specifically in Bionic/linker. C:
/* Initialize environment functions, and get to the ELF aux vectors table */vecs = linker_env_init(vecs);/* Check auxv for AT_SECURE first to see if program is setuid, setgid,has file caps, or caused a SELinux/AppArmor domain transition. */for (v = vecs; v[0]; v += 2) { if (v[0] == AT_SECURE) { /* kernel told us whether to enable secure mode */ program_is_setuid = v[1]; goto sanitize; }}/* Kernel did not provide AT_SECURE - fall back on legacy test. */program_is_setuid = (getuid() != geteuid()) || (getgid() != getegid());
To sum up, bionic is not very different, mainly because of the addition of at_secure, SELinux water is very deep, and we recommend you read the article:
Chapter 17th, program management and SELinux