All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Konstantin Khlebnikov <khlebnikov@yandex-team.ru>,
	"Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>,
	Matt Fleming <matt@codeblueprint.co.uk>
Subject: [PATCH 4.4 35/91] sched/cgroup: Move sched_online_group() back into css_online() to fix crash
Date: Fri,  4 Aug 2017 16:15:31 -0700	[thread overview]
Message-ID: <20170804231557.880361873@linuxfoundation.org> (raw)
In-Reply-To: <20170804231555.678888089@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>

commit 96b777452d8881480fd5be50112f791c17db4b6b upstream.

Commit:

  2f5177f0fd7e ("sched/cgroup: Fix/cleanup cgroup teardown/init")

.. moved sched_online_group() from css_online() to css_alloc().
It exposes half-baked task group into global lists before initializing
generic cgroup stuff.

LTP testcase (third in cgroup_regression_test) written for testing
similar race in kernels 2.6.26-2.6.28 easily triggers this oops:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
  IP: kernfs_path_from_node_locked+0x260/0x320
  CPU: 1 PID: 30346 Comm: cat Not tainted 4.10.0-rc5-test #4
  Call Trace:
  ? kernfs_path_from_node+0x4f/0x60
  kernfs_path_from_node+0x3e/0x60
  print_rt_rq+0x44/0x2b0
  print_rt_stats+0x7a/0xd0
  print_cpu+0x2fc/0xe80
  ? __might_sleep+0x4a/0x80
  sched_debug_show+0x17/0x30
  seq_read+0xf2/0x3b0
  proc_reg_read+0x42/0x70
  __vfs_read+0x28/0x130
  ? security_file_permission+0x9b/0xc0
  ? rw_verify_area+0x4e/0xb0
  vfs_read+0xa5/0x170
  SyS_read+0x46/0xa0
  entry_SYSCALL_64_fastpath+0x1e/0xad

Here the task group is already linked into the global RCU-protected 'task_groups'
list, but the css->cgroup pointer is still NULL.

This patch reverts this chunk and moves online back to css_online().

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: 2f5177f0fd7e ("sched/cgroup: Fix/cleanup cgroup teardown/init")
Link: http://lkml.kernel.org/r/148655324740.424917.5302984537258726349.stgit@buzz
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/sched/core.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8253,11 +8253,20 @@ cpu_cgroup_css_alloc(struct cgroup_subsy
 	if (IS_ERR(tg))
 		return ERR_PTR(-ENOMEM);
 
-	sched_online_group(tg, parent);
-
 	return &tg->css;
 }
 
+/* Expose task group only after completing cgroup initialization */
+static int cpu_cgroup_css_online(struct cgroup_subsys_state *css)
+{
+	struct task_group *tg = css_tg(css);
+	struct task_group *parent = css_tg(css->parent);
+
+	if (parent)
+		sched_online_group(tg, parent);
+	return 0;
+}
+
 static void cpu_cgroup_css_released(struct cgroup_subsys_state *css)
 {
 	struct task_group *tg = css_tg(css);
@@ -8632,6 +8641,7 @@ static struct cftype cpu_files[] = {
 
 struct cgroup_subsys cpu_cgrp_subsys = {
 	.css_alloc	= cpu_cgroup_css_alloc,
+	.css_online	= cpu_cgroup_css_online,
 	.css_released	= cpu_cgroup_css_released,
 	.css_free	= cpu_cgroup_css_free,
 	.fork		= cpu_cgroup_fork,

  parent reply	other threads:[~2017-08-04 23:27 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-04 23:14 [PATCH 4.4 00/91] 4.4.80-stable review Greg Kroah-Hartman
2017-08-04 23:14 ` [PATCH 4.4 01/91] af_key: Add lock to key dump Greg Kroah-Hartman
2017-08-04 23:14 ` [PATCH 4.4 02/91] pstore: Make spinlock per zone instead of global Greg Kroah-Hartman
2017-08-04 23:14 ` [PATCH 4.4 03/91] net: reduce skb_warn_bad_offload() noise Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 04/91] powerpc/pseries: Fix of_node_put() underflow during reconfig remove Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 05/91] crypto: authencesn - Fix digest_null crash Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 06/91] md/raid5: add thread_group worker async_tx_issue_pending_all Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 07/91] drm/vmwgfx: Fix gcc-7.1.1 warning Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 08/91] drm/nouveau/bar/gf100: fix access to upper half of BAR2 Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 09/91] KVM: PPC: Book3S HV: Context-switch EBB registers properly Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 10/91] KVM: PPC: Book3S HV: Restore critical SPRs to host values on guest exit Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 11/91] KVM: PPC: Book3S HV: Reload HTM registers explicitly Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 12/91] KVM: PPC: Book3S HV: Save/restore host values of debug registers Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 13/91] Revert "powerpc/numa: Fix percpu allocations to be NUMA aware" Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 14/91] Staging: comedi: comedi_fops: Avoid orphaned proc entry Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 15/91] drm/rcar: Nuke preclose hook Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 16/91] drm: rcar-du: Perform initialization/cleanup at probe/remove time Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 17/91] drm: rcar-du: Simplify and fix probe error handling Greg Kroah-Hartman
2017-08-07 15:17   ` Ben Hutchings
2017-08-08 16:29     ` Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 18/91] perf intel-pt: Fix ip compression Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 19/91] perf intel-pt: Fix last_ip usage Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 20/91] perf intel-pt: Use FUP always when scanning for an IP Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 21/91] perf intel-pt: Ensure never to set last_ip when packet count is zero Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 22/91] xfs: dont BUG() on mixed direct and mapped I/O Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 23/91] nfc: fdp: fix NULL pointer dereference Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 24/91] net: phy: Do not perform software reset for Generic PHY Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 25/91] isdn: Fix a sleep-in-atomic bug Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 26/91] isdn/i4l: fix buffer overflow Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 27/91] ath10k: fix null deref on wmi-tlv when trying spectral scan Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 28/91] wil6210: fix deadlock when using fw_no_recovery option Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 29/91] mailbox: always wait in mbox_send_message for blocking Tx mode Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 30/91] mailbox: skip complete wait event if timer expired Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 31/91] mailbox: handle empty message in tx_tick Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 32/91] mpt3sas: Dont overreach ioc->reply_post[] during initialization Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 33/91] kaweth: fix firmware download Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 34/91] kaweth: fix oops upon failed memory allocation Greg Kroah-Hartman
2017-08-04 23:15 ` Greg Kroah-Hartman [this message]
2017-08-04 23:15 ` [PATCH 4.4 36/91] PM / Domains: defer dev_pm_domain_set() until genpd->attach_dev succeeds if present Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 37/91] RDMA/uverbs: Fix the check for port number Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 38/91] libnvdimm, btt: fix btt_rw_page not returning errors Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 39/91] ipmi/watchdog: fix watchdog timeout set on reboot Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 40/91] dentry name snapshots Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 41/91] [media] v4l: s5c73m3: fix negation operator Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 42/91] Make file credentials available to the seqfile interfaces Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 43/91] /proc/iomem: only expose physical resource addresses to privileged users Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 44/91] vlan: Propagate MAC address to VLANs Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 45/91] pstore: Allow prz to control need for locking Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 46/91] pstore: Correctly initialize spinlock and flags Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 47/91] pstore: Use dynamic spinlock initializer Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 48/91] net: skb_needs_check() accepts CHECKSUM_NONE for tx Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 52/91] tpm: fix a kernel memory leak in tpm-sysfs.c Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 53/91] tpm: Replace device number bitmap with IDR Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 54/91] x86/mce/AMD: Make the init code more robust Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 55/91] r8169: add support for RTL8168 series add-on card Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 57/91] ipv6: Should use consistent conditional judgement for ip6 fragment between __ip6_append_data and ip6_finish_output Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 58/91] net/mlx4: Remove BUG_ON from ICM allocation routine Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 59/91] drm/msm: Ensure that the hardware write pointer is valid Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 60/91] drm/msm: Verify that MSM_SUBMIT_BO_FLAGS are set Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 61/91] vfio-pci: use 32-bit comparisons for register address for gcc-4.5 Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 62/91] irqchip/keystone: Fix "scheduling while atomic" on rt Greg Kroah-Hartman
2017-08-04 23:15 ` [PATCH 4.4 63/91] ASoC: tlv320aic3x: Mark the RESET register as volatile Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 64/91] spi: dw: Make debugfs name unique between instances Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 65/91] ASoC: nau8825: fix invalid configuration in Pre-Scalar of FLL Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 66/91] irqchip/mxs: Enable SKIP_SET_WAKE and MASK_ON_SUSPEND Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 67/91] openrisc: Add _text symbol to fix ksym build error Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 68/91] dmaengine: ioatdma: Add Skylake PCI Dev ID Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 69/91] dmaengine: ioatdma: workaround SKX ioatdma version Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 70/91] dmaengine: ti-dma-crossbar: Add some of_node_put() in error path Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 71/91] ARM64: zynqmp: Fix W=1 dtc 1.4 warnings Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 73/91] ARM: s3c2410_defconfig: Fix invalid values for NF_CT_PROTO_* Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 74/91] ACPI / scan: Prefer devices without _HID/_CID for _ADR matching Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 75/91] usb: gadget: Fix copy/pasted error message Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 76/91] Btrfs: adjust outstanding_extents counter properly when dio write is split Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 77/91] tools lib traceevent: Fix prev/next_prio for deadline tasks Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 78/91] xfrm: Dont use sk_family for socket policy lookups Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 79/91] perf tools: Install tools/lib/traceevent plugins with install-bin Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 80/91] perf symbols: Robustify reading of build-id from sysfs Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 81/91] video: fbdev: cobalt_lcdfb: Handle return NULL error from devm_ioremap Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 82/91] vfio-pci: Handle error from pci_iomap Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 83/91] arm64: mm: fix show_pte KERN_CONT fallout Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 84/91] nvmem: imx-ocotp: Fix wrong register size Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 85/91] sh_eth: enable RX descriptor word 0 shift on SH7734 Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 86/91] ALSA: usb-audio: test EP_FLAG_RUNNING at urb completion Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 87/91] HID: ignore Petzl USB headlamp Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 88/91] scsi: fnic: Avoid sending reset to firmware when another reset is in progress Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 89/91] scsi: snic: Return error code on memory allocation failure Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 90/91] ASoC: dpcm: Avoid putting stream state to STOP when FE stream is paused Greg Kroah-Hartman
2017-08-04 23:16 ` [PATCH 4.4 91/91] Btrfs: use down_read_nested to make lockdep silent Greg Kroah-Hartman
2017-08-05  1:52 ` [PATCH 4.4 00/91] 4.4.80-stable review Shuah Khan
2017-08-05  6:13 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170804231557.880361873@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=khlebnikov@yandex-team.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt@codeblueprint.co.uk \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tj@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.