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
762b678d
Commit
762b678d
authored
Nov 24, 2018
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent any SELinux issues of root shell streams
parent
38fcc57b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
12 deletions
+16
-12
rules.cpp
native/jni/magiskpolicy/rules.cpp
+7
-6
su_daemon.cpp
native/jni/su/su_daemon.cpp
+9
-6
No files found.
native/jni/magiskpolicy/rules.cpp
View file @
762b678d
...
...
@@ -10,10 +10,6 @@ static void allowSuClient(const char *target) {
sepol_allow
(
SEPOL_PROC_DOMAIN
,
target
,
"fd"
,
"use"
);
sepol_allow
(
SEPOL_PROC_DOMAIN
,
target
,
"fifo_file"
,
ALL
);
// Allow access to magisk files
sepol_allow
(
target
,
SEPOL_FILE_DOMAIN
,
"file"
,
ALL
);
sepol_allow
(
target
,
SEPOL_FILE_DOMAIN
,
"dir"
,
ALL
);
// Allow binder service
sepol_allow
(
target
,
SEPOL_PROC_DOMAIN
,
"binder"
,
"call"
);
sepol_allow
(
target
,
SEPOL_PROC_DOMAIN
,
"binder"
,
"transfer"
);
...
...
@@ -150,10 +146,15 @@ void sepol_magisk_rules() {
sepol_allow
(
SEPOL_PROC_DOMAIN
,
ALL
,
"chr_file"
,
ALL
);
sepol_allow
(
SEPOL_PROC_DOMAIN
,
ALL
,
"fifo_file"
,
ALL
);
// Super files
sepol_allow
(
ALL
,
SEPOL_FILE_DOMAIN
,
"file"
,
ALL
);
sepol_allow
(
ALL
,
SEPOL_FILE_DOMAIN
,
"dir"
,
ALL
);
sepol_allow
(
ALL
,
SEPOL_FILE_DOMAIN
,
"fifo_file"
,
ALL
);
sepol_allow
(
ALL
,
SEPOL_FILE_DOMAIN
,
"chr_file"
,
ALL
);
sepol_allow
(
SEPOL_FILE_DOMAIN
,
ALL
,
"filesystem"
,
"associate"
);
// For changing attributes
sepol_allow
(
"rootfs"
,
"tmpfs"
,
"filesystem"
,
"associate"
);
sepol_allow
(
SEPOL_FILE_DOMAIN
,
"labeledfs"
,
"filesystem"
,
"associate"
);
sepol_allow
(
SEPOL_FILE_DOMAIN
,
"tmpfs"
,
"filesystem"
,
"associate"
);
// Xposed
sepol_allow
(
"untrusted_app"
,
"untrusted_app"
,
"capability"
,
"setgid"
);
...
...
native/jni/su/su_daemon.cpp
View file @
762b678d
...
...
@@ -267,7 +267,6 @@ void su_daemon_handler(int client, struct ucred *credential) {
int
infd
=
recv_fd
(
client
);
int
outfd
=
recv_fd
(
client
);
int
errfd
=
recv_fd
(
client
);
int
ptsfd
=
-
1
;
if
(
pts_slave
[
0
])
{
LOGD
(
"su: pts_slave=[%s]
\n
"
,
pts_slave
);
...
...
@@ -279,13 +278,10 @@ void su_daemon_handler(int client, struct ucred *credential) {
if
(
st
.
st_uid
!=
info
->
uid
&&
info
->
uid
!=
0
)
LOGE
(
"su: Wrong permission of pts_slave"
);
// Set our pts_slave to devpts, same restriction as adb shell
lsetfilecon
(
pts_slave
,
"u:object_r:devpts:s0"
);
// Opening the TTY has to occur after the
// fork() and setsid() so that it becomes
// our controlling TTY and not the daemon's
ptsfd
=
xopen
(
pts_slave
,
O_RDWR
);
int
ptsfd
=
xopen
(
pts_slave
,
O_RDWR
);
if
(
infd
<
0
)
infd
=
ptsfd
;
...
...
@@ -302,7 +298,14 @@ void su_daemon_handler(int client, struct ucred *credential) {
xdup2
(
outfd
,
STDOUT_FILENO
);
xdup2
(
errfd
,
STDERR_FILENO
);
close
(
ptsfd
);
// Unleash all streams from SELinux hell
setfilecon
(
"/proc/self/fd/0"
,
"u:object_r:"
SEPOL_FILE_DOMAIN
":s0"
);
setfilecon
(
"/proc/self/fd/1"
,
"u:object_r:"
SEPOL_FILE_DOMAIN
":s0"
);
setfilecon
(
"/proc/self/fd/2"
,
"u:object_r:"
SEPOL_FILE_DOMAIN
":s0"
);
close
(
infd
);
close
(
outfd
);
close
(
errfd
);
close
(
client
);
// Handle namespaces
...
...
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