Skip to content

Commit

Permalink
exec: add a hack to disable lmkd reloading props
Browse files Browse the repository at this point in the history
/vendor/etc/perf/perfconfigstore.xml enables ro.lmk.enable_userspace_lmk,
and when the lmkd properties are re-read, lmkd tries to honor it and ignores
the presence of in-kernel lmk and exits repeatedly, which causes init to
trigger a reboot.

Signed-off-by: Juhyung Park <[email protected]>
Change-Id: I222d4a7825ca5dfda24f540d22355263d3f61754
(cherry picked from commit 25d2c1cb0ff04cb41233b245d0de9cf1f201d2b3)
Signed-off-by: TogoFire <[email protected]>
  • Loading branch information
arter97 authored and TogoFire committed Jan 31, 2025
1 parent 0e5fa95 commit 70077ad
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions fs/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,27 @@ static int exec_binprm(struct linux_binprm *bprm)
return ret;
}

static noinline bool is_lmkd_reinit(struct user_arg_ptr *argv)
{
const char __user *str;
char buf[10];
int len;

str = get_user_arg_ptr(*argv, 1);
if (IS_ERR(str))
return false;

// strnlen_user() counts NULL terminator
len = strnlen_user(str, MAX_ARG_STRLEN);
if (len != 9)
return false;

if (copy_from_user(buf, str, len))
return false;

return !strcmp(buf, "--reinit");
}

/*
* sys_execve() executes a new program.
*/
Expand Down Expand Up @@ -1863,6 +1884,15 @@ static int __do_execve_file(int fd, struct filename *filename,
bprm->argc = 1;
}

// Super nasty hack to disable lmkd reloading props
if (unlikely(strcmp(bprm.filename, "/system/bin/lmkd") == 0)) {
if (is_lmkd_reinit(&argv)) {
pr_info("sys_execve(): prevented /system/bin/lmkd --reinit\n");
retval = -ENOENT;
goto out;
}
}

retval = exec_binprm(bprm);
if (retval < 0)
goto out;
Expand Down

0 comments on commit 70077ad

Please sign in to comment.