hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8OIQR
----------------------------------------------------------------------
If files_cgroup of file is not inited, and migrate process, it will lead to null pointer access. PGD 0 P4D 0 Oops: 0002 [#1] PREEMPT SMP NOPTI CPU: 5 PID: 453 Comm: bash Not tainted 6.6.0-02775-g7381ac6593bc-di8 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14 RIP: 0010:page_counter_uncharge+0x1c/0x80 Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 41 54 4d RSP: 0018:ffffc9000081bc88 EFLAGS: 00000206 RAX: 0000000000000005 RBX: 0000000000000100 RCX: 0000000000000005 RDX: ffff888104b8d620 RSI: fffffffffffffffb RDI: 0000000000000100 RBP: 0000000000000005 R08: ffffc9000081bd70 R09: ffffc9000081bcb0 R10: ffff88810736f740 R11: 0000000000000001 R12: fffffffffffffffb R13: ffff888100bdc218 R14: 0000000000000100 R15: ffff888107481c00 FS: 00007fb78e5b9740(0000) GS:ffff888237b40000(0000) knlGS:00000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000100 CR3: 00000001012c2000 CR4: 00000000000006e0 Call Trace: <TASK> ? __die+0x1f/0x70 ? page_fault_oops+0x156/0x420 ? search_exception_tables+0x37/0x50 ? fixup_exception+0x21/0x310 ? exc_page_fault+0x69/0x150 ? asm_exc_page_fault+0x26/0x30 ? page_counter_uncharge+0x1c/0x80 files_cgroup_can_attach+0x98/0x1c0 cgroup_migrate_execute+0x79/0x470 ? cgroup_migrate_prepare_dst+0x43/0x220 cgroup_attach_task+0x141/0x1f0 __cgroup1_procs_write.constprop.0+0x10a/0x150 kernfs_fop_write_iter+0x117/0x1b0 vfs_write+0x2bd/0x3e0 ksys_write+0x5e/0xe0 do_syscall_64+0x3f/0x90 entry_SYSCALL_64_after_hwframe+0x6e/0xd8
Signed-off-by: Chen Ridong chenridong@huawei.com --- fs/filescontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/filescontrol.c b/fs/filescontrol.c index 8222497ad131..000f257d7a51 100644 --- a/fs/filescontrol.c +++ b/fs/filescontrol.c @@ -115,7 +115,7 @@ static int files_cgroup_can_attach(struct cgroup_taskset *tset)
task_lock(task); files = task->files; - if (!files || files == &init_files) { + if (!files || !files->files_cgroup || files == &init_files) { task_unlock(task); return 0; }