Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5818446yba; Tue, 30 Apr 2019 23:54:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzk0F6pd0gv5uvCOcqIdkNcufmX5KzjJChUXDI/pOo80KAGE4xo0qPKeXLT4hiUl2yYeO/Q X-Received: by 2002:a63:cd15:: with SMTP id i21mr9109929pgg.269.1556693668675; Tue, 30 Apr 2019 23:54:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556693668; cv=none; d=google.com; s=arc-20160816; b=W7PdiBskYwFoZ0B+Ag5zsJK0PYjSMzFDz7iwt/ifXi9on/Qr4kvXSeg6jy/v0zKydq HNw9bAgcscfIusG07S9ERcJ7YzTEVjfWcgcwGlsTrQ+/LfRO3eu49deV3T4+vvBFcDRv /DCP1LOzBRgFrqfRD/YAauKcWIdByygpzw09f2vhg7nuvUhdqdNPAyGtlBAf1UkzdU1E vZ9uTbjb2F0+w+jIcQ0OgbhzlEq6xzEqYWXTt+vjoUKOQwyklCgEj6RBfqf6Kl6j73Hi 1uDozsyW+lSADdMmHOrC0WgR8IVPrRwzmBbf48NvsdIvmZXCwpP/UG3V9Q3YrZjq/iSO dByg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=6DG7pCoX/cwKF79BRs3hs3xhJzt4God6HCDvs7KxWgA=; b=MCc+i5+eZ650WRsBcv51NgYn7B+fT5OibVL8NY6776zdahlp5eAdK9Yg8SCRrBwU35 7FCypdx7xGC5SB995wLJ7dyTqcUkQC1h+aBS0fdUI0YOVRuvBMjywxcUQflPEy3V3j0+ gELzqb4TMUcrM+x5iUiycEi2KDQlkJc3/7bvt1KRm+bBSH/GKvhsJLFDKyjWnyWxvmoM 8X8Y7fxY4z2JNhzfb7k+IIVovPSgQsQXezMH1Da8W1L+1QbsvrsMblpEtmigXrLigely P39u99kse/vARnOZWJsHMzgaPxtzs4cSagGZ14u4jLa+K3P2JEZ02kxkM8Vt3Et6zEuv 4/xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ahachlGd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l184si24991560pfl.43.2019.04.30.23.54.11; Tue, 30 Apr 2019 23:54:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ahachlGd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726067AbfEAGxQ (ORCPT + 99 others); Wed, 1 May 2019 02:53:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42260 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725776AbfEAGxQ (ORCPT ); Wed, 1 May 2019 02:53:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 845D82081C; Wed, 1 May 2019 06:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556693596; bh=PduymaNULleI3+rM/Kqu6TZyeDN3bnvLgbkS1YjZ5uQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ahachlGdeHlkWbny9eJPH2gNA/wJctMWyYiTY/uZ1ZIFisO0I4tb5EHU4VrSURglf oVNXaEiCVqOHB3QlJ7p4Oyvi48dAoXXg/PZ6oeVSz2NTkV7LJVXEJJFa2O4cdXFTOU ibJj1g4BJMkMwskrZGIdk53izOCoTCSoghnpoUzk= Date: Wed, 1 May 2019 08:53:13 +0200 From: Greg KH To: Prateek Sood Cc: rafael@kernel.org, sramana@codeaurora.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V2] drivers: core: Remove glue dirs early only when refcount is 1 Message-ID: <20190501065313.GA30616@kroah.com> References: <1556632540-17382-1-git-send-email-prsood@codeaurora.org> <1556684567-26710-1-git-send-email-prsood@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1556684567-26710-1-git-send-email-prsood@codeaurora.org> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 01, 2019 at 09:52:47AM +0530, Prateek Sood wrote: > While loading firmware blobs parallely in different threads, it is possible > to free sysfs node of glue_dirs in device_del() from a thread while another > thread is trying to add subdir from device_add() in glue_dirs sysfs node. > > CPU1 CPU2 > fw_load_sysfs_fallback() > device_add() > get_device_parent() > class_dir_create_and_add() > kobject_add_internal() > create_dir() // glue_dir > > fw_load_sysfs_fallback() > device_add() > get_device_parent() > kobject_get() //glue_dir > > device_del() > cleanup_glue_dir() > kobject_del() > > kobject_add() > kobject_add_internal() > create_dir() // in glue_dir > kernfs_create_dir_ns() > > sysfs_remove_dir() //glue_dir->sd=NULL > sysfs_put() // free glue_dir->sd > > kernfs_new_node() > kernfs_get(glue_dir) > > Fix this race by making sure that kernfs_node for glue_dir is released only > when refcount for glue_dir kobj is 1. > > Signed-off-by: Prateek Sood > --- > drivers/base/core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) What changed from v1? That always has to go below the --- line. v3 please.