hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I9R2TB
--------------------------------
for_each_process_thread() only include init_task and its descendant, but not include idle tasks. Idle tasks also require calltraces checking.
Signed-off-by: Zheng Yejian zhengyejian1@huawei.com --- arch/arm/kernel/livepatch.c | 6 ++++++ arch/arm64/kernel/livepatch.c | 6 ++++++ arch/powerpc/kernel/livepatch_32.c | 6 ++++++ arch/powerpc/kernel/livepatch_64.c | 6 ++++++ arch/x86/kernel/livepatch.c | 7 ++++++- 5 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kernel/livepatch.c b/arch/arm/kernel/livepatch.c index 41ee14992b59..af298045f67f 100644 --- a/arch/arm/kernel/livepatch.c +++ b/arch/arm/kernel/livepatch.c @@ -246,6 +246,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args, { int ret; struct task_struct *g, *t; + unsigned int cpu;
for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) @@ -254,6 +255,11 @@ static int do_check_calltrace(struct walk_stackframe_args *args, if (ret) return ret; } + for_each_online_cpu(cpu) { + ret = check_task_calltrace(idle_task(cpu), args, fn); + if (ret) + return ret; + } return 0; }
diff --git a/arch/arm64/kernel/livepatch.c b/arch/arm64/kernel/livepatch.c index 90932ac5f3f5..71a95489855b 100644 --- a/arch/arm64/kernel/livepatch.c +++ b/arch/arm64/kernel/livepatch.c @@ -242,6 +242,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args, { int ret; struct task_struct *g, *t; + unsigned int cpu;
for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) @@ -250,6 +251,11 @@ static int do_check_calltrace(struct walk_stackframe_args *args, if (ret) return ret; } + for_each_online_cpu(cpu) { + ret = check_task_calltrace(idle_task(cpu), args, fn); + if (ret) + return ret; + } return 0; }
diff --git a/arch/powerpc/kernel/livepatch_32.c b/arch/powerpc/kernel/livepatch_32.c index 7feb8a04f2e3..c01a958e3242 100644 --- a/arch/powerpc/kernel/livepatch_32.c +++ b/arch/powerpc/kernel/livepatch_32.c @@ -281,6 +281,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args, { int ret; struct task_struct *g, *t; + unsigned int cpu;
for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) @@ -289,6 +290,11 @@ static int do_check_calltrace(struct walk_stackframe_args *args, if (ret) return ret; } + for_each_online_cpu(cpu) { + ret = check_task_calltrace(idle_task(cpu), args, fn); + if (ret) + return ret; + } return 0; }
diff --git a/arch/powerpc/kernel/livepatch_64.c b/arch/powerpc/kernel/livepatch_64.c index 7f7c5fcb6e92..f644c5dde9cb 100644 --- a/arch/powerpc/kernel/livepatch_64.c +++ b/arch/powerpc/kernel/livepatch_64.c @@ -284,6 +284,7 @@ static int do_check_calltrace(struct walk_stackframe_args *args, { int ret; struct task_struct *g, *t; + unsigned int cpu;
for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) @@ -292,6 +293,11 @@ static int do_check_calltrace(struct walk_stackframe_args *args, if (ret) return ret; } + for_each_online_cpu(cpu) { + ret = check_task_calltrace(idle_task(cpu), args, fn); + if (ret) + return ret; + } return 0; }
diff --git a/arch/x86/kernel/livepatch.c b/arch/x86/kernel/livepatch.c index 0675357bd16c..b630bab1060a 100644 --- a/arch/x86/kernel/livepatch.c +++ b/arch/x86/kernel/livepatch.c @@ -299,6 +299,7 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da { int ret = 0; struct task_struct *g, *t; + unsigned int cpu;
for_each_process_thread(g, t) { if (klp_is_migration_thread(t->comm)) @@ -308,7 +309,11 @@ static int do_check_calltrace(bool (*fn)(void *, int *, unsigned long), void *da if (ret) return ret; } - + for_each_online_cpu(cpu) { + ret = check_task_calltrace(idle_task(cpu), fn, data); + if (ret) + return ret; + } return 0; }