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
3f840f53
Commit
3f840f53
authored
Apr 01, 2022
by
石松洲
Committed by
John Wu
Apr 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check device tree fstab entries are compatible
Fix topjohnwu#5664
parent
d8718d8a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
15 deletions
+17
-15
init.hpp
native/jni/init/init.hpp
+1
-1
rootdir.cpp
native/jni/init/rootdir.cpp
+2
-6
selinux.cpp
native/jni/init/selinux.cpp
+14
-8
No files found.
native/jni/init/init.hpp
View file @
3f840f53
...
...
@@ -64,7 +64,7 @@ protected:
#endif
void
patch_sepolicy
(
const
char
*
file
);
void
hijack_sepolicy
();
bool
hijack_sepolicy
();
void
setup_tmp
(
const
char
*
path
);
void
patch_rw_root
();
public
:
...
...
native/jni/init/rootdir.cpp
View file @
3f840f53
...
...
@@ -235,10 +235,8 @@ void SARBase::patch_ro_root() {
}
}
if
(
access
(
SPLIT_PLAT_CIL
,
F_OK
)
!=
0
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
{
if
(
(
access
(
SPLIT_PLAT_CIL
,
F_OK
)
!=
0
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
||
!
hijack_sepolicy
()
)
{
patch_sepolicy
(
ROOTOVL
"/sepolicy"
);
}
else
{
hijack_sepolicy
();
}
// Mount rootdir
...
...
@@ -309,10 +307,8 @@ void MagiskInit::patch_rw_root() {
}
}
if
(
!
treble
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
{
if
(
(
!
treble
&&
access
(
"/sepolicy"
,
F_OK
)
==
0
)
||
!
hijack_sepolicy
()
)
{
patch_sepolicy
(
"/sepolicy"
);
}
else
{
hijack_sepolicy
();
}
chdir
(
"/"
);
...
...
native/jni/init/selinux.cpp
View file @
3f840f53
...
...
@@ -42,7 +42,7 @@ void MagiskInit::patch_sepolicy(const char *file) {
#define MOCK_BLOCKING SELINUXMOCK "/blocking"
#define REAL_SELINUXFS SELINUXMOCK "/fs"
void
MagiskInit
::
hijack_sepolicy
()
{
bool
MagiskInit
::
hijack_sepolicy
()
{
const
char
*
blocking_target
;
string
actual_content
;
...
...
@@ -60,7 +60,7 @@ void MagiskInit::hijack_sepolicy() {
}
else
{
// Error, should never happen
LOGE
(
"! Cannot find plat_file_contexts
\n
"
);
return
;
return
false
;
}
actual_content
=
full_read
(
blocking_target
);
...
...
@@ -91,11 +91,6 @@ void MagiskInit::hijack_sepolicy() {
// and let the original init mount selinuxfs for us
// This only happens on Android 8.0 - 9.0
// Preserve sysfs and procfs for hijacking
mount_list
.
erase
(
std
::
remove_if
(
mount_list
.
begin
(),
mount_list
.
end
(),
[](
const
string
&
s
)
{
return
s
==
"/proc"
||
s
==
"/sys"
;
}),
mount_list
.
end
());
// Remount procfs with proper options
xmount
(
nullptr
,
"/proc"
,
nullptr
,
MS_REMOUNT
,
"hidepid=2,gid=3009"
);
...
...
@@ -103,7 +98,18 @@ void MagiskInit::hijack_sepolicy() {
snprintf
(
buf
,
sizeof
(
buf
),
"%s/fstab/compatible"
,
config
->
dt_dir
);
dt_compat
=
full_read
(
buf
);
if
(
dt_compat
.
empty
())
{
// Device does not do early mount and apparently use monolithic policy
return
false
;
}
LOGD
(
"Hijack [%s]
\n
"
,
buf
);
// Preserve sysfs and procfs for hijacking
mount_list
.
erase
(
std
::
remove_if
(
mount_list
.
begin
(),
mount_list
.
end
(),
[](
const
string
&
s
)
{
return
s
==
"/proc"
||
s
==
"/sys"
;
}),
mount_list
.
end
());
mkfifo
(
MOCK_COMPAT
,
0444
);
xmount
(
MOCK_COMPAT
,
buf
,
nullptr
,
MS_BIND
,
nullptr
);
}
else
{
...
...
@@ -128,7 +134,7 @@ void MagiskInit::hijack_sepolicy() {
// Create a new process waiting for init operations
if
(
xfork
())
{
// In parent, return and continue boot process
return
;
return
true
;
}
if
(
!
dt_compat
.
empty
())
{
...
...
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