mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-04 23:45:23 +00:00
ec3705f2ed
Introduce new domain `magisk_client` and new file type `magisk_exec`. Connection to magiskd's always-on socket is restricted to magisk_client only. Whitelisted process domains can transit to magisk_client through executing files labelled magisk_exec. The main magisk binary shall be the only file labelled as magisk_exec throughout the whole system. All processes thus are no longer allowed to connect to magiskd directly without going through the proper magisk binary. Connection failures are silenced from audit logs with dontaudit rules, so crazy processes which traverse through all unix domain sockets to try connection can no longer check logcat to know the actual reason behind EACCES, leaking the denied process policy (which is u:r:magisk:s0). This also allows us to remove many rules that open up holes in untrusted_app domains that were used to make remote shell work properly. Since all processes establishing the remote shell are now restricted to the magisk_client domain, all these rules are moved to magisk_client. This makes Magisk require fewer compromises in Android's security model. Note: as of this commit, requesting new root access via Magisk Manager will stop working as Magisk Manager can no longer communicate with magiskd directly. This will be addressed in a future commit that involves changes in both native and application side.
28 lines
1.3 KiB
C++
28 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <sepol/policydb/policydb.h>
|
|
#include <magiskpolicy.hpp>
|
|
|
|
// Internal APIs, do not use directly
|
|
struct sepol_impl : public sepolicy {
|
|
void check_avtab_node(avtab_ptr_t node);
|
|
avtab_ptr_t get_avtab_node(avtab_key_t *key, avtab_extended_perms_t *xperms);
|
|
bool add_rule(const char *s, const char *t, const char *c, const char *p, int effect, bool invert);
|
|
void add_rule(type_datum_t *src, type_datum_t *tgt, class_datum_t *cls, perm_datum_t *perm, int effect, bool invert);
|
|
void add_xperm_rule(type_datum_t *src, type_datum_t *tgt,
|
|
class_datum_t *cls, uint16_t low, uint16_t high, int effect, bool invert);
|
|
bool add_xperm_rule(const char *s, const char *t, const char *c, const char *range, int effect, bool invert);
|
|
bool add_type_rule(const char *s, const char *t, const char *c, const char *d, int effect);
|
|
bool add_filename_trans(const char *s, const char *t, const char *c, const char *d, const char *o);
|
|
bool add_genfscon(const char *fs_name, const char *path, const char *context);
|
|
bool add_type(const char *type_name, uint32_t flavor);
|
|
bool set_type_state(const char *type_name, bool permissive);
|
|
void add_typeattribute(type_datum_t *type, type_datum_t *attr);
|
|
bool add_typeattribute(const char *type, const char *attr);
|
|
void strip_dontaudit();
|
|
};
|
|
|
|
#define impl static_cast<sepol_impl *>(this)
|
|
|
|
void statement_help();
|