Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4925310ybf; Wed, 4 Mar 2020 13:33:44 -0800 (PST) X-Google-Smtp-Source: ADFU+vsmx9REj8jpCaxBT6iQ/9tRclCG1GT8Hwoee5q2UMOmw9Nh0j0UgYXHiB8eiRqX09buR7zm X-Received: by 2002:aca:5491:: with SMTP id i139mr3311020oib.24.1583357624174; Wed, 04 Mar 2020 13:33:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583357624; cv=none; d=google.com; s=arc-20160816; b=FWp9860yInPx0TE2Zii5CoSTK2t09z4OzGMwBIwm5ufJhoap3rq8FL3xvk8AJ+RCMp BEaXGySwajYoCmUBrGjpQb+p5XNUkVLuR9PdcBC5B0dDrRa5NMil+aVYlWKa2OfOrcYF /VLBGBT21p/eyVp9SmxofUHfPLhJlYINVqf0r4eS6UAILKvvNgrGIiogujvzmSWvfIJO UDGW8YcoK3BIVBIE94boWtAu+7GsqRDduh7Yvk3NJNF4ESQ/4JOCUqCEHEg5K6I2duaS Is4XtOt+gVRyTD9e4zvLjF9yV3wJMZRhUkUm46c4E87Y96YC2j44vcKRnRAN+XOJZUL+ FJvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject; bh=lAs44Ni/YsqXEbyrNf1n+Ko+3QyG7OFBGT7/mWQz6qc=; b=Ry+HIEbQTn9pWihf5CK4Kmu4naJWKe96NW5fFJOuBwU+eFVi9Zf8poRYfe81P2qgnz S45y1UAAZCCSgTFP7d/6w+4ssoX+EkTrZzzT3YU+PAvSa9/uckRiW0F3dyUYKsAHSyQS nsUPhl2EZbsvB5EoWFs1AZxK0TRh4Bfgt8VHKt9yGG2BgE19XfILtNn7T941KlGJUKKc ZQettbaaxjUr+jVPp61WAXfpqrRj9yml+M4EsmWycjSOEFZ+rd1wy/hvzpg6F7dlsHJ6 CDBouzgFndK8L35zaLRRXgxQ/aGAPt3t2rF/zMZyu+Ze3GJd0OVHP8GdFssZ1wY3ODUj r4rA== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r13si1749601oic.97.2020.03.04.13.33.31; Wed, 04 Mar 2020 13:33:44 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388281AbgCDVdN (ORCPT + 99 others); Wed, 4 Mar 2020 16:33:13 -0500 Received: from mga17.intel.com ([192.55.52.151]:49685 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726440AbgCDVdN (ORCPT ); Wed, 4 Mar 2020 16:33:13 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2020 13:33:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,515,1574150400"; d="scan'208";a="263743798" Received: from rjwysock-mobl1.ger.corp.intel.com (HELO [10.249.153.168]) ([10.249.153.168]) by fmsmga004.fm.intel.com with ESMTP; 04 Mar 2020 13:33:11 -0800 Subject: Re: [PATCH v1] Revert "software node: Simplify software_node_release() function" To: Heikki Krogerus , Brendan Higgins Cc: gregkh@linuxfoundation.org, rafael@kernel.org, linux-kernel@vger.kernel.org, davidgow@google.com, Heidi Fahim , Hans de Goede References: <20200228000001.240428-1-brendanhiggins@google.com> <20200302135738.GD22243@kuha.fi.intel.com> From: "Rafael J. Wysocki" Organization: Intel Technology Poland Sp. z o. o., KRS 101882, ul. Slowackiego 173, 80-298 Gdansk Message-ID: Date: Wed, 4 Mar 2020 22:33:10 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200302135738.GD22243@kuha.fi.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/2020 2:57 PM, Heikki Krogerus wrote: > On Thu, Feb 27, 2020 at 04:00:01PM -0800, Brendan Higgins wrote: >> This reverts commit 3df85a1ae51f6b256982fe9d17c2dc5bfb4cc402. >> >> The reverted commit says "It's possible to release the node ID >> immediately when fwnode_remove_software_node() is called, no need to >> wait for software_node_release() with that." However, releasing the node >> ID before waiting for software_node_release() to be called causes the >> node ID to be released before the kobject and the underlying sysfs >> entry; this means there is a period of time where a sysfs entry exists >> that is associated with an unallocated node ID. >> >> Once consequence of this is that there is a race condition where it is >> possible to call fwnode_create_software_node() with no parent node >> specified (NULL) and have it fail with -EEXIST because the node ID that >> was assigned is still associated with a stale sysfs entry that hasn't >> been cleaned up yet. >> >> Although it is difficult to reproduce this race condition under normal >> conditions, it can be deterministically reproduced with the following >> minconfig on UML: >> >> CONFIG_KUNIT_DRIVER_PE_TEST=y >> CONFIG_DEBUG_KERNEL=y >> CONFIG_DEBUG_OBJECTS=y >> CONFIG_DEBUG_OBJECTS_TIMERS=y >> CONFIG_DEBUG_KOBJECT_RELEASE=y >> CONFIG_KUNIT=y >> >> Running the tests with this configuration causes the following failure: >> >> >> kobject: 'node0' ((____ptrval____)): kobject_release, parent (____ptrval____) (delayed 400) >> ok 1 - pe_test_uints >> sysfs: cannot create duplicate filename '/kernel/software_nodes/node0' >> CPU: 0 PID: 28 Comm: kunit_try_catch Not tainted 5.6.0-rc3-next-20200227 #14 >> >> kobject_add_internal failed for node0 with -EEXIST, don't try to register things with the same name in the same directory. >> kobject: 'node0' ((____ptrval____)): kobject_release, parent (____ptrval____) (delayed 100) >> # pe_test_uint_arrays: ASSERTION FAILED at drivers/base/test/property-entry-test.c:123 >> Expected node is not error, but is: -17 >> not ok 2 - pe_test_uint_arrays >> >> >> Reported-by: Heidi Fahim >> Signed-off-by: Brendan Higgins >> Cc: Heikki Krogerus >> Cc: Hans de Goede >> Cc: Rafael J. Wysocki > Reviewed-by: Heikki Krogerus > >> --- >> drivers/base/swnode.c | 14 +++++++------- >> 1 file changed, 7 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c >> index 0b081dee1e95c..de8d3543e8fe3 100644 >> --- a/drivers/base/swnode.c >> +++ b/drivers/base/swnode.c >> @@ -608,6 +608,13 @@ static void software_node_release(struct kobject *kobj) >> { >> struct swnode *swnode = kobj_to_swnode(kobj); >> >> + if (swnode->parent) { >> + ida_simple_remove(&swnode->parent->child_ids, swnode->id); >> + list_del(&swnode->entry); >> + } else { >> + ida_simple_remove(&swnode_root_ids, swnode->id); >> + } >> + >> if (swnode->allocated) { >> property_entries_free(swnode->node->properties); >> kfree(swnode->node); >> @@ -773,13 +780,6 @@ void fwnode_remove_software_node(struct fwnode_handle *fwnode) >> if (!swnode) >> return; >> >> - if (swnode->parent) { >> - ida_simple_remove(&swnode->parent->child_ids, swnode->id); >> - list_del(&swnode->entry); >> - } else { >> - ida_simple_remove(&swnode_root_ids, swnode->id); >> - } >> - >> kobject_put(&swnode->kobj); >> } >> EXPORT_SYMBOL_GPL(fwnode_remove_software_node); >> -- >> 2.25.1.481.gfbce0eb801-goog > thanks, > Patch applied as a fix for 5.6, thanks!