From aa32835ff6a1eeb7ed331d6c7f37bfb604351202 Mon Sep 17 00:00:00 2001 From: Trijal Saha <97483939+Trijal08@users.noreply.github.com> Date: Wed, 7 May 2025 17:18:25 -0400 Subject: [PATCH] kernel: Adapt to old GCC Co-Authored-By: backslashxx <118538522+backslashxx@users.noreply.github.com> --- kernel/allowlist.c | 4 ++-- kernel/core_hook.c | 20 ++++++++++---------- kernel/throne_tracker.c | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/allowlist.c b/kernel/allowlist.c index bcdac3f0..b6b3cdd7 100644 --- a/kernel/allowlist.c +++ b/kernel/allowlist.c @@ -362,7 +362,7 @@ void do_save_allow_list(struct work_struct *work) struct file *fp = ksu_filp_open_compat(KERNEL_SU_ALLOWLIST, O_WRONLY | O_CREAT | O_TRUNC, 0644); if (IS_ERR(fp)) { - pr_err("save_allow_list create file failed: %ld\n", PTR_ERR(fp)); + pr_err("save_allow_list create file failed: %d\n", (int)PTR_ERR(fp)); return; } @@ -409,7 +409,7 @@ void do_load_allow_list(struct work_struct *work) // load allowlist now! fp = ksu_filp_open_compat(KERNEL_SU_ALLOWLIST, O_RDONLY, 0); if (IS_ERR(fp)) { - pr_err("load_allow_list open file failed: %ld\n", PTR_ERR(fp)); + pr_err("load_allow_list open file failed: %d\n", (int)PTR_ERR(fp)); return; } diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 7fee02d4..febd9219 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -371,7 +371,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, // Both root manager and root processes should be allowed to get version if (arg2 == CMD_GET_VERSION) { u32 version = KERNEL_SU_VERSION; - if (copy_to_user(arg3, &version, sizeof(version))) { + if (copy_to_user((void __user *)arg3, &version, sizeof(version))) { pr_err("prctl reply error, cmd: %lu\n", arg2); } u32 version_flags = 0; @@ -379,7 +379,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, version_flags |= 0x1; #endif if (arg4 && - copy_to_user(arg4, &version_flags, sizeof(version_flags))) { + copy_to_user((void __user *)arg4, &version_flags, sizeof(version_flags))) { pr_err("prctl reply error, cmd: %lu\n", arg2); } return 0; @@ -423,7 +423,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, if (!from_root) { return 0; } - if (!handle_sepolicy(arg3, arg4)) { + if (!handle_sepolicy(arg3, (void __user *)arg4)) { if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) { pr_err("sepolicy: prctl reply error\n"); } @@ -448,9 +448,9 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, bool success = ksu_get_allow_list(array, &array_length, arg2 == CMD_GET_ALLOW_LIST); if (success) { - if (!copy_to_user(arg4, &array_length, + if (!copy_to_user((void __user *)arg4, &array_length, sizeof(array_length)) && - !copy_to_user(arg3, array, + !copy_to_user((void __user *)arg3, array, sizeof(u32) * array_length)) { if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) { @@ -474,7 +474,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, } else { pr_err("unknown cmd: %lu\n", arg2); } - if (!copy_to_user(arg4, &allow, sizeof(allow))) { + if (!copy_to_user((void __user *)arg4, &allow, sizeof(allow))) { if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) { pr_err("prctl reply error, cmd: %lu\n", arg2); } @@ -492,14 +492,14 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, // we are already manager if (arg2 == CMD_GET_APP_PROFILE) { struct app_profile profile; - if (copy_from_user(&profile, arg3, sizeof(profile))) { + if (copy_from_user(&profile, (void __user *)arg3, sizeof(profile))) { pr_err("copy profile failed\n"); return 0; } bool success = ksu_get_app_profile(&profile); if (success) { - if (copy_to_user(arg3, &profile, sizeof(profile))) { + if (copy_to_user((void __user *)arg3, &profile, sizeof(profile))) { pr_err("copy profile failed\n"); return 0; } @@ -512,7 +512,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, if (arg2 == CMD_SET_APP_PROFILE) { struct app_profile profile; - if (copy_from_user(&profile, arg3, sizeof(profile))) { + if (copy_from_user(&profile, (void __user *)arg3, sizeof(profile))) { pr_err("copy profile failed\n"); return 0; } @@ -527,7 +527,7 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, } if (arg2 == CMD_IS_SU_ENABLED) { - if (copy_to_user(arg3, &ksu_su_compat_enabled, + if (copy_to_user((void __user *)arg3, &ksu_su_compat_enabled, sizeof(ksu_su_compat_enabled))) { pr_err("copy su compat failed\n"); return 0; diff --git a/kernel/throne_tracker.c b/kernel/throne_tracker.c index 51eafaec..d1b66efa 100644 --- a/kernel/throne_tracker.c +++ b/kernel/throne_tracker.c @@ -299,8 +299,8 @@ void track_throne() struct file *fp = ksu_filp_open_compat(SYSTEM_PACKAGES_LIST_PATH, O_RDONLY, 0); if (IS_ERR(fp)) { - pr_err("%s: open " SYSTEM_PACKAGES_LIST_PATH " failed: %ld\n", - __func__, PTR_ERR(fp)); + pr_err("%s: open " SYSTEM_PACKAGES_LIST_PATH " failed: %d\n", + __func__, (int)PTR_ERR(fp)); return; }