linux-kernel.vger.kernel.org archive mirror
 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, Michal Hocko <mhocko@suse.cz>,
	Paul Furtado <paulfurtado91@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 3.15 15/42] memcg: oom_notify use-after-free fix
Date: Tue,  5 Aug 2014 11:13:29 -0700	[thread overview]
Message-ID: <20140805181321.481551052@linuxfoundation.org> (raw)
In-Reply-To: <20140805181321.018370988@linuxfoundation.org>

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

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

From: Michal Hocko <mhocko@suse.cz>

commit 2bcf2e92c3918ce62ab4e934256e47e9a16d19c3 upstream.

Paul Furtado has reported the following GPF:

  general protection fault: 0000 [#1] SMP
  Modules linked in: ipv6 dm_mod xen_netfront coretemp hwmon x86_pkg_temp_thermal crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel ablk_helper cryptd lrw gf128mul glue_helper aes_x86_64 microcode pcspkr ext4 jbd2 mbcache raid0 xen_blkfront
  CPU: 3 PID: 3062 Comm: java Not tainted 3.16.0-rc5 #1
  task: ffff8801cfe8f170 ti: ffff8801d2ec4000 task.ti: ffff8801d2ec4000
  RIP: e030:mem_cgroup_oom_synchronize+0x140/0x240
  RSP: e02b:ffff8801d2ec7d48  EFLAGS: 00010283
  RAX: 0000000000000001 RBX: ffff88009d633800 RCX: 000000000000000e
  RDX: fffffffffffffffe RSI: ffff88009d630200 RDI: ffff88009d630200
  RBP: ffff8801d2ec7da8 R08: 0000000000000012 R09: 00000000fffffffe
  R10: 0000000000000000 R11: 0000000000000000 R12: ffff88009d633800
  R13: ffff8801d2ec7d48 R14: dead000000100100 R15: ffff88009d633a30
  FS:  00007f1748bb4700(0000) GS:ffff8801def80000(0000) knlGS:0000000000000000
  CS:  e033 DS: 0000 ES: 0000 CR0: 000000008005003b
  CR2: 00007f4110300308 CR3: 00000000c05f7000 CR4: 0000000000002660
  Call Trace:
    pagefault_out_of_memory+0x18/0x90
    mm_fault_error+0xa9/0x1a0
    __do_page_fault+0x478/0x4c0
    do_page_fault+0x2c/0x40
    page_fault+0x28/0x30
  Code: 44 00 00 48 89 df e8 40 ca ff ff 48 85 c0 49 89 c4 74 35 4c 8b b0 30 02 00 00 4c 8d b8 30 02 00 00 4d 39 fe 74 1b 0f 1f 44 00 00 <49> 8b 7e 10 be 01 00 00 00 e8 42 d2 04 00 4d 8b 36 4d 39 fe 75
  RIP  mem_cgroup_oom_synchronize+0x140/0x240

Commit fb2a6fc56be6 ("mm: memcg: rework and document OOM waiting and
wakeup") has moved mem_cgroup_oom_notify outside of memcg_oom_lock
assuming it is protected by the hierarchical OOM-lock.

Although this is true for the notification part the protection doesn't
cover unregistration of event which can happen in parallel now so
mem_cgroup_oom_notify can see already unlinked and/or freed
mem_cgroup_eventfd_list.

Fix this by using memcg_oom_lock also in mem_cgroup_oom_notify.

Addresses https://bugzilla.kernel.org/show_bug.cgi?id=80881

Fixes: fb2a6fc56be6 (mm: memcg: rework and document OOM waiting and wakeup)
Signed-off-by: Michal Hocko <mhocko@suse.cz>
Reported-by: Paul Furtado <paulfurtado91@gmail.com>
Tested-by: Paul Furtado <paulfurtado91@gmail.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 mm/memcontrol.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -5544,8 +5544,12 @@ static int mem_cgroup_oom_notify_cb(stru
 {
 	struct mem_cgroup_eventfd_list *ev;
 
+	spin_lock(&memcg_oom_lock);
+
 	list_for_each_entry(ev, &memcg->oom_notify, list)
 		eventfd_signal(ev->eventfd, 1);
+
+	spin_unlock(&memcg_oom_lock);
 	return 0;
 }
 



  parent reply	other threads:[~2014-08-05 18:53 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 18:13 [PATCH 3.15 00/42] 3.15.9-stable review Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 01/42] powerpc/perf: Fix MMCR2 handling for EBB Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 02/42] crypto: arm-aes - fix encryption of unaligned data Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 03/42] crypto: af_alg - properly label AF_ALG socket Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 04/42] ARM: dts: fix L2 address in Hi3620 Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 05/42] ARM: OMAP2+: gpmc: fix gpmc_hwecc_bch_capable() Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 06/42] ARM: fix alignment of keystone page table fixup Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 07/42] ARM: 8115/1: LPAE: reduce damage caused by idmap to virtual memory layout Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 08/42] ath9k: fix aggregation session lockup Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 09/42] cfg80211: fix mic_failure tracing Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 10/42] Revert "mac80211: move "bufferable MMPDU" check to fix AP mode scan" Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 11/42] rapidio/tsi721_dma: fix failure to obtain transaction descriptor Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 12/42] scsi: handle flush errors properly Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 13/42] mm/page-writeback.c: fix divide by zero in bdi_dirty_limits() Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 14/42] mm, thp: do not allow thp faults to avoid cpuset restrictions Greg Kroah-Hartman
2014-08-05 18:13 ` Greg Kroah-Hartman [this message]
2014-08-05 18:13 ` [PATCH 3.15 16/42] staging: vt6655: Fix disassociated messages every 10 seconds Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 17/42] ACPI / PNP: Fix acpi_pnp_match() Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 18/42] iio:bma180: Fix scale factors to report correct acceleration units Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 19/42] iio:bma180: Missing check for frequency fractional part Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 20/42] iio: buffer: Fix demux table creation Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 21/42] dm bufio: fully initialize shrinker Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 22/42] dm cache: fix race affecting dirty block count Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 23/42] printk: rename printk_sched to printk_deferred Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 24/42] sched_clock: Avoid corrupting hrtimer tree during suspend Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 25/42] timer: Fix lock inversion between hrtimer_bases.lock and scheduler locks Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 26/42] Revert "x86-64, modify_ldt: Make support for 16-bit segments a runtime option" Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 27/42] x86-64, espfix: Dont leak bits 31:16 of %esp returning to 16-bit stack Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 28/42] x86, espfix: Move espfix definitions into a separate header file Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 29/42] x86, espfix: Fix broken header guard Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 30/42] x86, espfix: Make espfix64 a Kconfig option, fix UML Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 31/42] x86, espfix: Make it possible to disable 16-bit support Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 32/42] x86_64/entry/xen: Do not invoke espfix64 on Xen Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 33/42] pinctrl: dra: dt-bindings: Fix pull enable/disable Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 34/42] vfs: fix check for fallocate on active swapfile Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 35/42] ARM: dts: dra7-evm: Make VDDA_1V8_PHY supply always on Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 36/42] staging: vt6655: Fix Warning on boot handle_irq_event_percpu Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 37/42] drm/i915: Ignore VBT backlight presence check on HP Chromebook 14 Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 38/42] x86/xen: no need to explicitly register an NMI callback Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 39/42] xtensa: add fixup for double exception raised in window overflow Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 40/42] net/l2tp: dont fall back on UDP [get|set]sockopt Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 41/42] lib/btree.c: fix leak of whole btree nodes Greg Kroah-Hartman
2014-08-05 18:13 ` [PATCH 3.15 42/42] x86/espfix/xen: Fix allocation of pages for paravirt page tables Greg Kroah-Hartman
2014-08-05 23:07 ` [PATCH 3.15 00/42] 3.15.9-stable review Shuah Khan
2014-08-05 23:27   ` Greg Kroah-Hartman
2014-08-06 11:44     ` Satoru Takeuchi
2014-08-06 14:20       ` Greg Kroah-Hartman
2014-08-06  2:35 ` Guenter Roeck
2014-08-06  2:38   ` Greg Kroah-Hartman

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=20140805181321.481551052@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=paulfurtado91@gmail.com \
    --cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).