
From: Zhang Jian <zhangjian210@huawei.com> ascend inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4JICC CVE: NA ------------------------------------------------- When we access the process's sp_group file and the precess is a kernel process, it's task_struct->mm value will be 0, so we must check it, and make sure the process is not a kernel process. v1->v2: The path of a process as a kernel process is not often triggered, so add a unlikely function to accelerate execytion. Signed-off-by: Zhang Jian <zhangjian210@huawei.com> Reviewed-by: Ding Tianhong <dingtianhong@huawei.com> Reviewed-by: Weilong Chen <chenweilong@huawei.com> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- mm/share_pool.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/share_pool.c b/mm/share_pool.c index c6dcae92f67b5..2cc15f894cf84 100644 --- a/mm/share_pool.c +++ b/mm/share_pool.c @@ -3851,13 +3851,17 @@ int proc_sp_group_state(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { struct mm_struct *mm = task->mm; - struct sp_group_master *master = mm->sp_group_master; + struct sp_group_master *master; struct sp_proc_stat *proc_stat; struct spg_proc_stat *spg_proc_stat; int i; unsigned long anon, file, shmem, total_rss, prot; long sp_res, sp_res_nsize, non_sp_res, non_sp_shm; + if (unlikely(!mm)) + return 0; + + master = mm->sp_group_master; if (!master) return 0; -- 2.25.1