cgroup: statically initialize init_css_set->dfl_cgrp
Like other csets, init_css_set's dfl_cgrp is initialized when the cset
gets linked. init_css_set gets linked in cgroup_init(). This has
been fine till now but the recently added basic CPU usage accounting
may end up accessing dfl_cgrp of init before cgroup_init() leading to
the following oops.
SELinux: Initializing.
BUG: unable to handle kernel NULL pointer dereference at
00000000000000b0
IP: account_system_index_time+0x60/0x90
PGD 0 P4D 0
Oops: 0000 [#1] SMP
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted
4.14.0-rc2-00003-g041cd64 #10
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
+1.9.3-20161025_171302-gandalf 04/01/2014
task:
ffffffff81e10480 task.stack:
ffffffff81e00000
RIP: 0010:account_system_index_time+0x60/0x90
RSP: 0000:
ffff880011e03cb8 EFLAGS:
00010002
RAX:
ffffffff81ef8800 RBX:
ffffffff81e10480 RCX:
0000000000000003
RDX:
0000000000000000 RSI:
00000000000f4240 RDI:
0000000000000000
RBP:
ffff880011e03cc0 R08:
0000000000010000 R09:
0000000000000000
R10:
0000000000000020 R11:
0000003b9aca0000 R12:
000000000001c100
R13:
0000000000000000 R14:
ffffffff81e10480 R15:
ffffffff81e03cd8
FS:
0000000000000000(0000) GS:
ffff880011e00000(0000) knlGS:
0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0:
0000000080050033
CR2:
00000000000000b0 CR3:
0000000001e09000 CR4:
00000000000006b0
DR0:
0000000000000000 DR1:
0000000000000000 DR2:
0000000000000000
DR3:
0000000000000000 DR6:
00000000fffe0ff0 DR7:
0000000000000400
Call Trace:
<IRQ>
account_system_time+0x45/0x60
account_process_tick+0x5a/0x140
update_process_times+0x22/0x60
tick_periodic+0x2b/0x90
tick_handle_periodic+0x25/0x70
timer_interrupt+0x15/0x20
__handle_irq_event_percpu+0x7e/0x1b0
handle_irq_event_percpu+0x23/0x60
handle_irq_event+0x42/0x70
handle_level_irq+0x83/0x100
handle_irq+0x6f/0x110
do_IRQ+0x46/0xd0
common_interrupt+0x9d/0x9d
Fix it by statically initializing init_css_set.dfl_cgrp so that init's
default cgroup is accessible from the get-go.
Fixes:
041cd640b2f3 ("cgroup: Implement cgroup2 basic CPU usage accounting")
Reported-by: “kbuild-all@01.org” <kbuild-all@01.org>
Signed-off-by: Tejun Heo <tj@kernel.org>