From de72eedb4684ccabec18db73d7d2afc16db7f138 Mon Sep 17 00:00:00 2001 From: weishu Date: Sat, 3 Jun 2023 17:26:00 +0800 Subject: [PATCH] kernel: don't copy profile when not found --- kernel/core_hook.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index 6e11e434..74b928da 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -336,13 +336,15 @@ int ksu_handle_prctl(int option, unsigned long arg2, unsigned long arg3, return 0; } - ksu_get_app_profile(&profile); - if (copy_to_user(arg3, &profile, sizeof(profile))) { - pr_err("copy profile failed\n"); - return 0; - } - if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) { - pr_err("prctl reply error, cmd: %d\n", arg2); + bool success = ksu_get_app_profile(&profile); + if (success) { + if (copy_to_user(arg3, &profile, sizeof(profile))) { + pr_err("copy profile failed\n"); + return 0; + } + if (copy_to_user(result, &reply_ok, sizeof(reply_ok))) { + pr_err("prctl reply error, cmd: %d\n", arg2); + } } return 0; }