Received: by 2002:a25:d80d:0:0:0:0:0 with SMTP id p13csp222102ybg; Sat, 23 May 2020 12:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8e4iD4fis4gbP+EfnBiHpj95V77obV3H2wdiuKlFRjMRcNv2zqL52rikDRVnlTUyITm4Z X-Received: by 2002:a50:9dcd:: with SMTP id l13mr8513164edk.126.1590260865785; Sat, 23 May 2020 12:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590260865; cv=none; d=google.com; s=arc-20160816; b=L88+B3g+kkHGMnKverGxmVXRJwifa4m2P+nZfunQPMRBxw5f4ppUXQ7jzY4Y+Vzo3d nvB7PZUSNUjUj4ZGChYlCsPHDBHp7WE4B4OMJVmFT99eTNEKGO0bXQj2clplBQMMalek WUkCPe4FGx/GpeuhCFeYOJbfAjx/o92zpRIKz167PkiThuoQ1B5PSMh1YQNPnsteaSkn v5MMLrjNZtMbOQoj2Z6vsFn/4stXqQOxPSaI9qdvB3UeCBSUgkiHO6AGnmrbFmVEa4HB 4Nm2BkWqwP2oFYszbZ7IJH7UkirdgytpMkYD3Y4LJ4APzS5VEij1NkMrfDSCeQouK+sN 4+OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0LV47rSe890XlogISSGIE6i2W6NCdilGYWQjmkeWAcI=; b=AaW/UJKwGVvJgQJw/BD03v1txIhlh6Qx8b1rbyvJtltWpSNAGq7nLeUP/B6I432B33 PUSf3yctUFnH3m9LW5cx4LzbgLOvwZhhdt/ugdDgFzMDnnPJiVn4Ql+aC6Ag3I/Sbhi1 OX5nFjvdqsUF6NEsDvdus1opPaydDLhfbbJ1lkEaqcoDOjQ35OiA6f2WjSG7WRgzwhMT 91TnNaX4b+Y/+65dPJMc8EDhVZU5MmKtrQAN0lJxzv56Eg2/j0hcq70PzbojAL0lo8DK yjjztl7BJso3kG333misr6u7iW1vQwEDbhkOkdidsuwIzUyJr+ddOCKdn1t3DCaxbAfo GBMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MuNYv47+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si6565691edv.49.2020.05.23.12.07.23; Sat, 23 May 2020 12:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MuNYv47+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387843AbgEWTEp (ORCPT + 99 others); Sat, 23 May 2020 15:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387536AbgEWTEo (ORCPT ); Sat, 23 May 2020 15:04:44 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62B03C061A0E for ; Sat, 23 May 2020 12:04:43 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id r2so2853047ila.4 for ; Sat, 23 May 2020 12:04:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0LV47rSe890XlogISSGIE6i2W6NCdilGYWQjmkeWAcI=; b=MuNYv47+N7wRiR6DVM2pf+KbMZNdP4Jmmg/+eibCEvfZxDyF/ypNY7XnSb/unnXcpi dmwBTLa4AS/9LkWJMVX7blfX/bi/37u61nq5+ZjWr8Po491XDEByhvIhVo4sp1V/DibH NaLrB91HEVJbnbtCj+8IpyWJi55kNivatt1psiherUomDFFxxC+Rn7WRxv2H82NlrPk1 xcFvGzfBDg7nT7Au3OqrYVFMhkhg34d2AqTD3C72TezUbCbqBhx6F+cQVKkwzK0GWiIZ Il9QoPaQS1eLnnjiB/MwEr/H4MXSrY5HWuDB/t8g2Ak+NECpzS2riffmdqUzJzwiEHb4 2WVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0LV47rSe890XlogISSGIE6i2W6NCdilGYWQjmkeWAcI=; b=dh8U7h+9SgD9DgpV5AGzYA9xLHUUcvUtX2kGbc0AxKVghlEjrLMCF2zrz/UJ5G7k82 xlQnYtfYrAE8NdJO7mkjA8Ra3egRT0NEzwK0vHGgpmkuVY6Hc+223JKgHCCBjb8nlr+i IMDmQSwY1wjXSJFaKV4h65yzDDD6Xqbk7IfX88DlJOMvM27WQx+ND3MLT+oVqmNiPVb2 yWtBoTItntuHJM0qkQBXoWpYwY/hpq0cAqxfoT189yKZ0zYMH9la9CgFxMzWJtu2KG2d 3NdejNNgyfbD3q0pihua7I/MTK9D0WLsDTjrYtrQVdpp5Ljqhc7TMdFF1tbZS2WDZQy8 CfPw== X-Gm-Message-State: AOAM5322BzW4HWXeoZ/urSo0nueOSiTjB8oKDhgEhNKC46+08CBDhYVv ldrdvA20T6wDcECMd7LqZaOJ/wL/aLYJN239+/c= X-Received: by 2002:a92:6411:: with SMTP id y17mr18834396ilb.161.1590260682377; Sat, 23 May 2020 12:04:42 -0700 (PDT) MIME-Version: 1.0 References: <20200513151840.36400-1-heikki.krogerus@linux.intel.com> <20200523153643.GA226270@kroah.com> <7a5e4740-8099-ef70-776f-0d92ce84ab3d@infradead.org> In-Reply-To: <7a5e4740-8099-ef70-776f-0d92ce84ab3d@infradead.org> From: Dmitry Torokhov Date: Sat, 23 May 2020 12:04:30 -0700 Message-ID: Subject: Re: [PATCH] kobject: Make sure the parent does not get released before its children To: Randy Dunlap Cc: Greg Kroah-Hartman , Heikki Krogerus , lkml , Naresh Kamboju , kernel test robot , Brendan Higgins , "Rafael J. Wysocki" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 23, 2020 at 8:48 AM Randy Dunlap wrote: > > On 5/23/20 8:36 AM, Greg Kroah-Hartman wrote: > > On Wed, May 13, 2020 at 06:18:40PM +0300, Heikki Krogerus wrote: > >> In the function kobject_cleanup(), kobject_del(kobj) is > >> called before the kobj->release(). That makes it possible to > >> release the parent of the kobject before the kobject itself. > >> > >> To fix that, adding function __kboject_del() that does > >> everything that kobject_del() does except release the parent > >> reference. kobject_cleanup() then calls __kobject_del() > >> instead of kobject_del(), and separately decrements the > >> reference count of the parent kobject after kobj->release() > >> has been called. > >> > >> Reported-by: Naresh Kamboju > >> Reported-by: kernel test robot > >> Fixes: 7589238a8cf3 ("Revert "software node: Simplify software_node_release() function"") > >> Suggested-by: "Rafael J. Wysocki" > >> Signed-off-by: Heikki Krogerus > >> Reviewed-by: Rafael J. Wysocki > >> Reviewed-by: Brendan Higgins > >> Tested-by: Brendan Higgins > >> Acked-by: Randy Dunlap > >> --- > >> lib/kobject.c | 30 ++++++++++++++++++++---------- > >> 1 file changed, 20 insertions(+), 10 deletions(-) > > > > Stepping back, now that it turns out this patch causes more problems > > than it fixes, how is everyone reproducing the original crash here? > > Just load lib/test_printf.ko and boom! > > > > Is it just the KUNIT_DRIVER_PE_TEST that is causing the issue? > > > > In looking at 7589238a8cf3 ("Revert "software node: Simplify > > software_node_release() function""), the log messages there look > > correct. sysfs can't create a duplicate file, and so when your test is > > written to try to create software nodes, you always have to check the > > return value. If you run the test in parallel, or before another test > > has had a chance to clean up, the function will fail, correctly. > > > > So what real-world thing is this test "failure" trying to show? Well, not sure about the test, but speaking more generally, should not we postpone releasing parent's reference until we are in kobj->release() handler? I.e. after all child state is cleared, and all memory is freed, _then_ we unpin the parent? Thanks. -- Dmitry