From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753105AbdAZTiS (ORCPT ); Thu, 26 Jan 2017 14:38:18 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33282 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752844AbdAZTiP (ORCPT ); Thu, 26 Jan 2017 14:38:15 -0500 Date: Thu, 26 Jan 2017 14:37:54 -0500 From: Tejun Heo To: Konstantin Khlebnikov Cc: Peter Zijlstra , Ingo Molnar , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 2/2] kernfs: define name and path to "(null)" for NULL pointer kernfs nodes Message-ID: <20170126193754.GC32152@htj.duckdns.org> References: <148542370148.63697.501199781041713381.stgit@buzz> <148542370808.63697.11031298116868200840.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <148542370808.63697.11031298116868200840.stgit@buzz> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Thu, Jan 26, 2017 at 12:41:48PM +0300, Konstantin Khlebnikov wrote: > The same LTP testcase triggers NULL deref css->cgroup->kn in the same place. > > Commit a5bca2152036 ("cgroup: factor out cgroup_create() out of > cgroup_mkdir()") reordered cgroup construction. Now css created and > set online twice: first in cgroup_create(), second in cgroup_mkdir(). > First happens before creation of kernfs node. It's isn't set online twice. It's onlined and then made visible later. The problem here is that cgroup_name/path() depend on a kernfs node being associated with it and there's a gap between onlining and kernfs_node association. It's fine in cgroup proper but cgroup_name/path() are used from other places too, so it is problematic. > It seems safer and cleaner to handle NULL pointer right in kernfs than > spreading this magic across all other code. Now all functions that > prints kernfs path and name prints "(null)" for NULL pointer. I'm not against this patch but yeah this doesn't address the root cause here. Can you please send the patch to Greg? Please feel free to add my Acked-by. > Also it might be a good idea to reorder cgroup construction to make these > NULL pointers unreachable: online css only after complete initialization. > After that NULL checks in kernfs could be surrounded with WARN_ON(). Oh yeah, definitely. The names should be available before online. Will look into it. Thanks. -- tejun