Skip to content

Commit 245d4bf

Browse files
nampudbackslashxx
andauthored
Simplify is_system_bin_su
From backslashxx@5084a80 Co-authored-by: backslashxx <[email protected]>
1 parent e7c5b24 commit 245d4bf

1 file changed

Lines changed: 8 additions & 13 deletions

File tree

kernel/core_hook.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -245,19 +245,14 @@ static void nuke_ext4_sysfs() {
245245
path_put(&path);
246246
}
247247

248-
static bool is_system_bin_su() {
249-
char path_buf[256];
250-
char *pathname;
251-
252-
struct mm_struct *mm = current->mm;
253-
if (mm && mm->exe_file) {
254-
pathname = d_path(&mm->exe_file->f_path, path_buf, sizeof(path_buf));
255-
if (!IS_ERR(pathname)) {
256-
if (strcmp(pathname, "/system/bin/su") == 0) return true;
257-
if (strcmp(pathname, "/product/bin/su") == 0) return true;
258-
}
259-
}
260-
return false;
248+
static bool is_system_bin_su()
249+
{
250+
// YES in_execve becomes 0 when it succeeds.
251+
if (!current->mm || current->in_execve)
252+
return false;
253+
254+
// quick af check
255+
return (current->mm->exe_file && !strcmp(current->mm->exe_file->f_path.dentry->d_name.name, "su"));
261256
}
262257

263258
int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3,

0 commit comments

Comments
 (0)