@@ -48,7 +48,7 @@ for i in "${patch_files[@]}"; do
4848
4949 sed -i ' /#include <linux\/vmalloc.h>/a\#ifdef CONFIG_KSU_SUSFS\n#include <linux/susfs_def.h>\n#endif' fs/exec.c
5050 sed -i ' /^static int do_execveat_common(int fd, struct filename \*filename,/i\#ifdef CONFIG_KSU\nextern bool ksu_execveat_hook __read_mostly;\nextern bool __ksu_is_allow_uid_for_current(uid_t uid);\nextern int ksu_handle_execveat(int *fd, struct filename **filename_ptr, void *argv,\n\t\t\tvoid *envp, int *flags);\nextern int ksu_handle_execveat_sucompat(int *fd, struct filename **filename_ptr,\n\t\t\t\t void *argv, void *envp, int *flags);\n#endif\n' fs/exec.c
51- if grep " __do_execve_file" " fs/exec.c" ; then
51+ if grep -q " __do_execve_file" " fs/exec.c" ; then
5252 sed -i ' /return __do_execve_file(fd, filename, argv, envp, flags, NULL);/i #ifdef CONFIG_KSU_SUSFS\n\tif (likely(susfs_is_current_proc_umounted())) {\n\t\tgoto orig_flow;\n\t}\n\tif (unlikely(ksu_execveat_hook)) {\n\t\tksu_handle_execveat(&fd, &filename, &argv, &envp, &flags);\n\t} else if ((__ksu_is_allow_uid_for_current(current_uid().val))) {\n\t\tksu_handle_execveat_sucompat(&fd, &filename, &argv, &envp, &flags);\n\t}\norig_flow:\n#endif' fs/exec.c
5353 else
5454 sed -i ' /return PTR_ERR(filename);/a\#ifdef CONFIG_KSU_SUSFS\n\tif (likely(susfs_is_current_proc_umounted())) {\n\t\tgoto orig_flow;\n\t}\n\tif (unlikely(ksu_execveat_hook)) {\n\t\tksu_handle_execveat(\&fd, \&filename, \&argv, \&envp, \&flags);\n\t} else if ((__ksu_is_allow_uid_for_current(current_uid().val))) {\n\t\tksu_handle_execveat_sucompat(\&fd, \&filename, \&argv, \&envp, \&flags);\n\t}\norig_flow:\n#endif' fs/exec.c
@@ -222,7 +222,7 @@ for i in "${patch_files[@]}"; do
222222 else
223223 echo " [-] security/selinux/hooks.c patch failed for unknown reasons, please provide feedback in time."
224224 fi
225- elif [ " $FIRST_VERSION " -lt 5 ] && [ " $SECOND_VERSION " -lt 10 ] && grep -q " grab_transition_sids " " drivers/kernelsu/ksud.c " ; then
225+ else
226226 sed -i ' /^static int check_nnp_nosuid(const struct linux_binprm \*bprm,/i\#ifdef CONFIG_KSU\nextern bool is_ksu_transition(const struct task_security_struct *old_tsec,\n\t\t\t\tconst struct task_security_struct *new_tsec);\n#endif\n' security/selinux/hooks.c
227227 sed -i ' /rc = security_bounded_transition(old_tsec->sid, new_tsec->sid);/i\#ifdef CONFIG_KSU\n\tif (is_ksu_transition(old_tsec, new_tsec))\n\t\treturn 0;\n#endif\n' security/selinux/hooks.c
228228
@@ -232,19 +232,6 @@ for i in "${patch_files[@]}"; do
232232 else
233233 echo " [-] security/selinux/hooks.c patch failed for unknown reasons, please provide feedback in time."
234234 fi
235- elif [ " $FIRST_VERSION " -lt 5 ] && [ " $SECOND_VERSION " -lt 10 ]; then
236- sed -i ' /int nnp = (bprm->unsafe & LSM_UNSAFE_NO_NEW_PRIVS);/i\#ifdef CONFIG_KSU\n static u32 ksu_sid;\n char *secdata;\n#endif' security/selinux/hooks.c
237- sed -i ' /if (!nnp && !nosuid)/i\#ifdef CONFIG_KSU\n int error;\n u32 seclen;\n#endif' security/selinux/hooks.c
238- sed -i ' /return 0; \/\* No change in credentials \*\//a\\n#ifdef CONFIG_KSU\n if (!ksu_sid)\n security_secctx_to_secid("u:r:su:s0", strlen("u:r:su:s0"), &ksu_sid);\n\n error = security_secid_to_secctx(old_tsec->sid, &secdata, &seclen);\n if (!error) {\n rc = strcmp("u:r:init:s0", secdata);\n security_release_secctx(secdata, seclen);\n if (rc == 0 && new_tsec->sid == ksu_sid)\n return 0;\n }\n#endif' security/selinux/hooks.c
239-
240- if grep -q " security_secid_to_secctx" " security/selinux/hooks.c" ; then
241- echo " [+] security/selinux/hooks.c Patched!"
242- echo " [+] Count: $( grep -c " security_secid_to_secctx" " security/selinux/hooks.c" ) "
243- else
244- echo " [-] security/selinux/hooks.c patch failed for unknown reasons, please provide feedback in time."
245- fi
246- else
247- echo " [-] Kernel needn't selinux fix, Skipped."
248235 fi
249236
250237 echo " ======================================"
0 commit comments