From: Hui Tang tanghui20@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I5TIOZ CVE: NA
--------------------------------
BUG: KASAN: double-free or invalid-free in sched_prefer_cpus_free[...]
Freed by task 0: save_stack mm/kasan/kasan.c:448 [inline] set_track mm/kasan/kasan.c:460 [inline] __kasan_slab_free+0x120/0x228 mm/kasan/kasan.c:521 kasan_slab_free+0x10/0x18 mm/kasan/kasan.c:528 slab_free_hook mm/slub.c:1397 [inline] slab_free_freelist_hook mm/slub.c:1425 [inline] slab_free mm/slub.c:3004 [inline] kfree+0x84/0x250 mm/slub.c:3965 sched_prefer_cpus_free+0x58/0x78 kernel/sched/core.c:7219 free_task+0xb0/0xe8 kernel/fork.c:463 __delayed_free_task+0x24/0x30 kernel/fork.c:1716 __rcu_reclaim kernel/rcu/rcu.h:236 [inline] rcu_do_batch+0x200/0x5e0 kernel/rcu/tree.c:2584 invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline] __rcu_process_callbacks kernel/rcu/tree.c:2864 [inline] rcu_process_callbacks+0x470/0xb60 kernel/rcu/tree.c:2881 __do_softirq+0x2d0/0xba0 kernel/softirq.c:292
Add init of 'tsk->se.dyn_affi_stats == NULL' in dup_task_struct().
Fixes: ebca52abe099c ("sched: Add statistics for scheduler dynamic affinity") Signed-off-by: Hui Tang tanghui20@huawei.com Reviewed-by: Zhang Qiao zhangqiao22@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- kernel/fork.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/kernel/fork.c b/kernel/fork.c index 4207d5e5958b..b5453a26655e 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -893,6 +893,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
#ifdef CONFIG_QOS_SCHED_DYNAMIC_AFFINITY tsk->prefer_cpus = NULL; + tsk->se.dyn_affi_stats = NULL; #endif
setup_thread_stack(tsk, orig);