Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739283

[PATCH cgroup/for-4.15] cgroup: statically initialize init_css_set->dfl_cgrp

Path csiph.com!news.freedyn.net!open-news-network.org!newsfeed.datemas.de!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject [PATCH cgroup/for-4.15] cgroup: statically initialize init_css_set->dfl_cgrp
Date Mon, 25 Sep 2017 23:20:01 +0200
Message-ID <utIXf-3we-11@gated-at.bofh.it> (permalink)
References <udl8B-5QR-19@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=AyejRBhmaXx40UWSrglDwIjXUz664ObTQ61SwPhBBfY=; b=rqp+DuDx1Pvh8tQF/Rf0zWKLtXmx2kUvaHCulNLCI20Zu2+umcINsqm3U7ZMtgI7zB k6BuMoeMhDteXaZ0InI0ZpNZbl/7C6bk9Lhxnk9ZQQbmKWmOIF3YlmcAj3cyZa1W2+iB wx7Dm+CWJf2XVQdnL8ddpgRkzB3L1Dmp9wLKlxjEvjhGMxPgFIJOqMFmUIl+lSdd5bBk Qwm3+fR2FmFkgPlVSAdChwnvKisJ5flcxX+z89kCRCG7VGZtCTkLaKXiUEyJzXbTh8EI srAOdHVwAawwfB2XjD+C/aDrzqMNawSYdlR2MjRhOwBK1MBM7GaVFIOTEkyZOWqZPDkE bHDg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=AyejRBhmaXx40UWSrglDwIjXUz664ObTQ61SwPhBBfY=; b=dQH8U7doAs9ya5pfB5FP+rK3+TSP2NbLh1+bhQeOE41p5G278K7CwkLvUqrbKNPaue AqM9QHeU5wnipSuocuGWHnlEBwp5jzeIf8YuHB9Gt1xb4yGtzGfNj5Oh8akBrA+/38Nn giXb0LMjJKQLkPWzBvGjsfdqznJyTIrjXaqfOvcRp/dLmopqEEYHKZau1Z/o8mkpz6IW mWQTH8mmsvGSBNXHGg8X2CUjDTazGgxiXQ1KIqj3bJxRNis7zR9CNHg84PJ34lG8KTOl kVsCgdVVbjIbtuztff5zybUg/yAdIhx16/dUntTYqc4ZW+R1n5z/sR4VLlQUl+FQEbXl 450w==
X-Gm-Message-State AHPjjUjFaRY9VmEQU8wuu51Q0gaHyB5ialjSao1/xxJIWlY9wNKxAHQh 1QPtFKeA4T1iEpY8Hl8hs20=
X-Google-SMTP-Source AOwi7QBZOmVLi/HKWHnSNpBC+AXNgTnj7XUNtpCdqX4BwsHHgShPB3BqVdynnp2w4r/F96DQZpUeng==
X-Received by 10.55.16.198 with SMTP id 67mr12349560qkq.116.1506373834024; Mon, 25 Sep 2017 14:10:34 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Disposition inline
Content-Transfer-Encoding 8bit
User-Agent Mutt/1.5.21 (2010-09-15)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 92
Organization linux.* mail to news gateway
X-Original-Cc cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, pjt@google.com, luto@amacapital.net, efault@gmx.de, torvalds@linux-foundation.org, guro@fb.com
X-Original-Date Mon, 25 Sep 2017 14:10:30 -0700
X-Original-Message-ID <20170925211030.GB560070@devbig577.frc2.facebook.com>
X-Original-References <20170811163754.3939102-1-tj@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1739283

Show key headers only | View raw


Hello,

A follow-up patch to fix sporadic oops during boot which is caused by
trying dereference the default cgroup from accounting code before
cgroup is initialized.

Applied to cgroup/for-4.15.

Thanks.
------ 8< ------
From 38683148828165ea0b66ace93a9fedc2d3281e27 Mon Sep 17 00:00:00 2001
From: Tejun Heo <tj@kernel.org>
Date: Mon, 25 Sep 2017 13:50:20 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
---
 kernel/cgroup/cgroup.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index d036625..7975b20 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -649,6 +649,14 @@ struct css_set init_css_set = {
 	.cgrp_links		= LIST_HEAD_INIT(init_css_set.cgrp_links),
 	.mg_preload_node	= LIST_HEAD_INIT(init_css_set.mg_preload_node),
 	.mg_node		= LIST_HEAD_INIT(init_css_set.mg_node),
+
+	/*
+	 * The following field is re-initialized when this cset gets linked
+	 * in cgroup_init().  However, let's initialize the field
+	 * statically too so that the default cgroup can be accessed safely
+	 * early during boot.
+	 */
+	.dfl_cgrp		= &cgrp_dfl_root.cgrp,
 };
 
 static int css_set_count	= 1;	/* 1 for init_css_set */
-- 
2.9.5

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH cgroup/for-4.15] cgroup: statically initialize  init_css_set->dfl_cgrp Tejun Heo <tj@kernel.org> - 2017-09-25 23:20 +0200

csiph-web