Skip to content

Commit dd466dc

Browse files
authored
Refine prctl access check, allow /product/bin/su
1 parent fa7af67 commit dd466dc

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

kernel/core_hook.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,8 @@ static bool is_system_bin_su() {
253253
if (mm && mm->exe_file) {
254254
pathname = d_path(&mm->exe_file->f_path, path_buf, sizeof(path_buf));
255255
if (!IS_ERR(pathname)) {
256-
if (strcmp(pathname, "/system/bin/su") == 0) {
257-
return true;
258-
}
256+
if (strcmp(pathname, "/system/bin/su") == 0) return true;
257+
if (strcmp(pathname, "/product/bin/su") == 0) return true;
259258
}
260259
}
261260
return false;
@@ -277,9 +276,9 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
277276
}
278277

279278
bool from_root = 0 == current_uid().val;
280-
bool from_manager = is_manager() || (is_allow_su() && is_system_bin_su());
279+
bool from_manager = is_manager();
281280

282-
if (!from_root && !from_manager) {
281+
if (!from_root && !from_manager && !(is_allow_su() && arg2 == CMD_GRANT_ROOT && is_system_bin_su())) {
283282
// only root or manager can access this interface
284283
return 0;
285284
}
@@ -430,7 +429,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,
430429
}
431430

432431
// all other cmds are for 'root manager'
433-
if (!from_manager) {
432+
if (!from_manager && arg2 != CMD_ENABLE_SU) {
434433
return 0;
435434
}
436435

0 commit comments

Comments
 (0)