Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
82c864d5
Commit
82c864d5
authored
Mar 06, 2019
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make zygote notifier more reliable
parent
6226f875
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
25 deletions
+31
-25
bootstages.cpp
native/jni/core/bootstages.cpp
+1
-1
magisk.cpp
native/jni/core/magisk.cpp
+1
-0
daemon.h
native/jni/include/daemon.h
+0
-1
hide_utils.cpp
native/jni/magiskhide/hide_utils.cpp
+1
-19
magiskhide.h
native/jni/magiskhide/magiskhide.h
+2
-4
proc_monitor.cpp
native/jni/magiskhide/proc_monitor.cpp
+26
-0
No files found.
native/jni/core/bootstages.cpp
View file @
82c864d5
...
@@ -583,7 +583,7 @@ static void dump_logs() {
...
@@ -583,7 +583,7 @@ static void dump_logs() {
sprintf
(
buf
,
"/system/bin/%s"
,
app
);
sprintf
(
buf
,
"/system/bin/%s"
,
app
);
if
(
lstat
(
buf
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
if
(
lstat
(
buf
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
clone_attr
(
buf
,
MAGISKTMP
"/app_process"
);
clone_attr
(
buf
,
MAGISKTMP
"/app_process"
);
bind_mount
(
MAGISKTMP
"/app_process"
,
buf
);
bind_mount
(
MAGISKTMP
"/app_process"
,
buf
,
false
);
}
}
}
}
unblock_boot_process
();
unblock_boot_process
();
...
...
native/jni/core/magisk.cpp
View file @
82c864d5
...
@@ -129,6 +129,7 @@ int app_process_main(int argc, char *argv[]) {
...
@@ -129,6 +129,7 @@ int app_process_main(int argc, char *argv[]) {
int
fd
=
connect_daemon
();
int
fd
=
connect_daemon
();
write_int
(
fd
,
ZYGOTE_NOTIFY
);
write_int
(
fd
,
ZYGOTE_NOTIFY
);
write_string
(
fd
,
path
);
write_string
(
fd
,
path
);
read_int
(
fd
);
close
(
fd
);
close
(
fd
);
}
else
{
}
else
{
// Redirect to system mirror
// Redirect to system mirror
...
...
native/jni/include/daemon.h
View file @
82c864d5
...
@@ -80,7 +80,6 @@ void install_apk(const char *apk);
...
@@ -80,7 +80,6 @@ void install_apk(const char *apk);
void
magiskhide_handler
(
int
client
);
void
magiskhide_handler
(
int
client
);
void
zygote_notify
(
int
client
,
struct
ucred
*
cred
);
void
zygote_notify
(
int
client
,
struct
ucred
*
cred
);
void
zygote_notify
(
int
pid
);
/*************
/*************
* Superuser *
* Superuser *
...
...
native/jni/magiskhide/hide_utils.cpp
View file @
82c864d5
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
using
namespace
std
;
using
namespace
std
;
static
pthread_t
proc_monitor_thread
;
pthread_t
proc_monitor_thread
;
static
const
char
*
prop_key
[]
=
static
const
char
*
prop_key
[]
=
{
"ro.boot.vbmeta.device_state"
,
"ro.boot.verifiedbootstate"
,
"ro.boot.flash.locked"
,
{
"ro.boot.vbmeta.device_state"
,
"ro.boot.verifiedbootstate"
,
"ro.boot.flash.locked"
,
...
@@ -328,21 +328,3 @@ void auto_start_magiskhide() {
...
@@ -328,21 +328,3 @@ void auto_start_magiskhide() {
}
}
}
}
int
next_zygote
=
-
1
;
void
zygote_notify
(
int
pid
)
{
if
(
hide_enabled
)
{
MutexGuard
lock
(
monitor_lock
);
next_zygote
=
pid
;
pthread_kill
(
proc_monitor_thread
,
SIGZYGOTE
);
}
}
void
zygote_notify
(
int
client
,
struct
ucred
*
cred
)
{
char
*
path
=
read_string
(
client
);
close
(
client
);
zygote_notify
(
cred
->
pid
);
usleep
(
100000
);
xmount
(
MAGISKTMP
"/app_process"
,
path
,
nullptr
,
MS_BIND
,
nullptr
);
free
(
path
);
}
native/jni/magiskhide/magiskhide.h
View file @
82c864d5
#ifndef MAGISK_HIDE_H
#pragma once
#define MAGISK_HIDE_H
#include <pthread.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/types.h>
...
@@ -54,6 +53,7 @@ static inline int parse_int(const char *s) {
...
@@ -54,6 +53,7 @@ static inline int parse_int(const char *s) {
return
val
;
return
val
;
}
}
extern
pthread_t
proc_monitor_thread
;
extern
bool
hide_enabled
;
extern
bool
hide_enabled
;
extern
pthread_mutex_t
monitor_lock
;
extern
pthread_mutex_t
monitor_lock
;
extern
std
::
set
<
std
::
pair
<
std
::
string
,
std
::
string
>>
hide_set
;
extern
std
::
set
<
std
::
pair
<
std
::
string
,
std
::
string
>>
hide_set
;
...
@@ -75,5 +75,3 @@ enum {
...
@@ -75,5 +75,3 @@ enum {
HIDE_ITEM_NOT_EXIST
,
HIDE_ITEM_NOT_EXIST
,
HIDE_NO_NS
HIDE_NO_NS
};
};
#endif
native/jni/magiskhide/proc_monitor.cpp
View file @
82c864d5
...
@@ -241,6 +241,32 @@ static void term_thread(int) {
...
@@ -241,6 +241,32 @@ static void term_thread(int) {
//#define PTRACE_LOG(fmt, args...) LOGD("PID=[%d] " fmt, pid, ##args)
//#define PTRACE_LOG(fmt, args...) LOGD("PID=[%d] " fmt, pid, ##args)
#define PTRACE_LOG(...)
#define PTRACE_LOG(...)
int
next_zygote
=
-
1
;
void
zygote_notify
(
int
client
,
struct
ucred
*
cred
)
{
char
*
path
=
read_string
(
client
);
xptrace
(
PTRACE_ATTACH
,
cred
->
pid
);
// Wait for attach
waitpid
(
cred
->
pid
,
nullptr
,
__WALL
|
__WNOTHREAD
);
xptrace
(
PTRACE_CONT
,
cred
->
pid
);
write_int
(
client
,
0
);
close
(
client
);
// Wait for exec
waitpid
(
cred
->
pid
,
nullptr
,
__WALL
|
__WNOTHREAD
);
xptrace
(
PTRACE_DETACH
,
cred
->
pid
);
if
(
hide_enabled
)
{
MutexGuard
lock
(
monitor_lock
);
next_zygote
=
cred
->
pid
;
pthread_kill
(
proc_monitor_thread
,
SIGZYGOTE
);
}
// Remount zygote notifier ASAP
xmount
(
MAGISKTMP
"/app_process"
,
path
,
nullptr
,
MS_BIND
,
nullptr
);
free
(
path
);
}
static
bool
check_pid
(
int
pid
)
{
static
bool
check_pid
(
int
pid
)
{
char
path
[
128
];
char
path
[
128
];
char
cmdline
[
1024
];
char
cmdline
[
1024
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment