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
421277d7
Commit
421277d7
authored
Nov 12, 2021
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent race conditions in connect_companion
parent
56988944
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
entry.cpp
native/jni/zygisk/entry.cpp
+4
-0
No files found.
native/jni/zygisk/entry.cpp
View file @
421277d7
...
@@ -190,10 +190,13 @@ static bool get_exe(int pid, char *buf, size_t sz) {
...
@@ -190,10 +190,13 @@ static bool get_exe(int pid, char *buf, size_t sz) {
return
xreadlink
(
buf
,
buf
,
sz
)
>
0
;
return
xreadlink
(
buf
,
buf
,
sz
)
>
0
;
}
}
static
pthread_mutex_t
zygiskd_lock
=
PTHREAD_MUTEX_INITIALIZER
;
static
int
zygiskd_sockets
[]
=
{
-
1
,
-
1
};
static
int
zygiskd_sockets
[]
=
{
-
1
,
-
1
};
#define zygiskd_socket zygiskd_sockets[is_64_bit]
#define zygiskd_socket zygiskd_sockets[is_64_bit]
static
void
connect_companion
(
int
client
,
bool
is_64_bit
)
{
static
void
connect_companion
(
int
client
,
bool
is_64_bit
)
{
mutex_guard
g
(
zygiskd_lock
);
if
(
zygiskd_socket
>=
0
)
{
if
(
zygiskd_socket
>=
0
)
{
// Make sure the socket is still valid
// Make sure the socket is still valid
pollfd
pfd
=
{
zygiskd_socket
,
0
,
0
};
pollfd
pfd
=
{
zygiskd_socket
,
0
,
0
};
...
@@ -222,6 +225,7 @@ static void connect_companion(int client, bool is_64_bit) {
...
@@ -222,6 +225,7 @@ static void connect_companion(int client, bool is_64_bit) {
send_fds
(
zygiskd_socket
,
module_fds
.
data
(),
module_fds
.
size
());
send_fds
(
zygiskd_socket
,
module_fds
.
data
(),
module_fds
.
size
());
// Wait for ack
// Wait for ack
if
(
read_int
(
zygiskd_socket
)
!=
0
)
{
if
(
read_int
(
zygiskd_socket
)
!=
0
)
{
LOGE
(
"zygiskd startup error
\n
"
);
return
;
return
;
}
}
}
}
...
...
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