Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754358AbbK3OtB (ORCPT ); Mon, 30 Nov 2015 09:49:01 -0500 Received: from mail-yk0-f181.google.com ([209.85.160.181]:34669 "EHLO mail-yk0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753973AbbK3Os7 (ORCPT ); Mon, 30 Nov 2015 09:48:59 -0500 Date: Mon, 30 Nov 2015 09:48:55 -0500 From: Tejun Heo To: Li Zefan , Johannes Weiner Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Dave Jones , Daniel Wagner , kernel-team@fb.com Subject: Re: [PATCH cgroup/for-4.4-fixes] cgroup: make css_set pin its css's to avoid use-afer-free Message-ID: <20151130144855.GA3535@mtj.duckdns.org> References: <20151123195541.GA19072@mtj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20151123195541.GA19072@mtj.duckdns.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2738 Lines: 57 On Mon, Nov 23, 2015 at 02:55:41PM -0500, Tejun Heo wrote: > A css_set represents the relationship between a set of tasks and > css's. css_set never pinned the associated css's. This was okay > because tasks used to always disassociate immediately (in RCU sense) - > either a task is moved to a different css_set or exits and never > accesses css_set again. > > Unfortunately, afcf6c8b7544 ("cgroup: add cgroup_subsys->free() method > and use it to fix pids controller") and patches leading up to it made > a zombie hold onto its css_set and deref the associated css's on its > release. Nothing pins the css's after exit and it might have already > been freed leading to use-after-free. > > general protection fault: 0000 [#1] PREEMPT SMP > task: ffffffff81bf2500 ti: ffffffff81be4000 task.ti: ffffffff81be4000 > RIP: 0010:[] [] pids_cancel.constprop.4+0x5/0x40 > ... > Call Trace: > > [] ? pids_free+0x3d/0xa0 > [] cgroup_free+0x53/0xe0 > [] __put_task_struct+0x42/0x130 > [] delayed_put_task_struct+0x77/0x130 > [] rcu_process_callbacks+0x2f4/0x820 > [] ? rcu_process_callbacks+0x2b3/0x820 > [] __do_softirq+0xd4/0x460 > [] irq_exit+0x89/0xa0 > [] smp_apic_timer_interrupt+0x42/0x50 > [] apic_timer_interrupt+0x84/0x90 > > ... > Code: 5b 5d c3 48 89 df 48 c7 c2 c9 f9 ae 81 48 c7 c6 91 2c ae 81 e8 1d 94 0e 00 31 c0 5b 5d c3 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 83 87 e0 00 00 00 ff 78 01 c3 80 3d 08 7a c1 00 00 74 02 > RIP [] pids_cancel.constprop.4+0x5/0x40 > RSP > ---[ end trace 89a4a4b916b90c49 ]--- > Kernel panic - not syncing: Fatal exception in interrupt > Kernel Offset: disabled > ---[ end Kernel panic - not syncing: Fatal exception in interrupt > > Fix it by making css_set pin the associate css's until its release. > > Signed-off-by: Tejun Heo > Reported-by: Dave Jones > Reported-by: Daniel Wagner > Link: http://lkml.kernel.org/g/20151120041836.GA18390@codemonkey.org.uk > Link: http://lkml.kernel.org/g/5652D448.3080002@bmw-carit.de > Fixes: afcf6c8b7544 ("cgroup: add cgroup_subsys->free() method and use it to fix pids controller") Applied to cgroup/for-4.4-fixes. -- tejun -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/