devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] of: unittest: Run overlay apply/revert sequence three times
@ 2023-08-22 10:22 Geert Uytterhoeven
  2023-08-22 15:32 ` Rob Herring
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2023-08-22 10:22 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand, Peng Fan
  Cc: devicetree, linux-renesas-soc, Geert Uytterhoeven

Run the test for the overlay apply/revert sequence three times, to
test if there are unbalanced of_node_put() calls causing reference
counts to become negative.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This is a reproducer for the issue fixed by commit 7882541ca06d51a6
("of/platform: increase refcount of fwnode") in dt/linus.
---
 drivers/of/unittest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 9af5337c76f62162..67e32977341a6f0c 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3035,6 +3035,7 @@ static void __init of_unittest_overlay_notify(void)
 static void __init of_unittest_overlay(void)
 {
 	struct device_node *bus_np = NULL;
+	unsigned int i;
 
 	if (platform_driver_register(&unittest_driver)) {
 		unittest(0, "could not register unittest driver\n");
@@ -3072,7 +3073,8 @@ static void __init of_unittest_overlay(void)
 	of_unittest_overlay_2();
 	of_unittest_overlay_3();
 	of_unittest_overlay_4();
-	of_unittest_overlay_5();
+	for (i = 0; i < 3; i++)
+		of_unittest_overlay_5();
 	of_unittest_overlay_6();
 	of_unittest_overlay_8();
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-22 10:22 [PATCH] of: unittest: Run overlay apply/revert sequence three times Geert Uytterhoeven
@ 2023-08-22 15:32 ` Rob Herring
  2023-08-22 17:52   ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2023-08-22 15:32 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> Run the test for the overlay apply/revert sequence three times, to
> test if there are unbalanced of_node_put() calls causing reference
> counts to become negative.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> ("of/platform: increase refcount of fwnode") in dt/linus.

Is this necessary? There were WARN backtraces without that fix.

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-22 15:32 ` Rob Herring
@ 2023-08-22 17:52   ` Geert Uytterhoeven
  2023-08-22 17:59     ` Rob Herring
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2023-08-22 17:52 UTC (permalink / raw)
  To: Rob Herring; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

Hi Rob,

On Tue, Aug 22, 2023 at 5:32 PM Rob Herring <robh@kernel.org> wrote:
> On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> > Run the test for the overlay apply/revert sequence three times, to
> > test if there are unbalanced of_node_put() calls causing reference
> > counts to become negative.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> > ("of/platform: increase refcount of fwnode") in dt/linus.
>
> Is this necessary? There were WARN backtraces without that fix.

Did you see them?
Peng saw them with the out-of-tree jailhouse hypervisor enable/disable
test, and I saw them with the out-of-tree overlay configfs patches.
I am not aware of any in-tree kernel code triggering them.  If we
would have had this in the unittests, I would have noticed this
regression earlier...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-22 17:52   ` Geert Uytterhoeven
@ 2023-08-22 17:59     ` Rob Herring
  2023-08-22 19:21       ` Rob Herring
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2023-08-22 17:59 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

On Tue, Aug 22, 2023 at 12:52 PM Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>
> Hi Rob,
>
> On Tue, Aug 22, 2023 at 5:32 PM Rob Herring <robh@kernel.org> wrote:
> > On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> > > Run the test for the overlay apply/revert sequence three times, to
> > > test if there are unbalanced of_node_put() calls causing reference
> > > counts to become negative.
> > >
> > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > ---
> > > This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> > > ("of/platform: increase refcount of fwnode") in dt/linus.
> >
> > Is this necessary? There were WARN backtraces without that fix.
>
> Did you see them?

Yes, but that was also with your series applied. When I tested the
fix, I had dropped that, so maybe your series triggered it too.

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-22 17:59     ` Rob Herring
@ 2023-08-22 19:21       ` Rob Herring
  2023-08-23  7:41         ` Geert Uytterhoeven
  0 siblings, 1 reply; 8+ messages in thread
From: Rob Herring @ 2023-08-22 19:21 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

On Tue, Aug 22, 2023 at 12:59 PM Rob Herring <robh@kernel.org> wrote:
>
> On Tue, Aug 22, 2023 at 12:52 PM Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> >
> > Hi Rob,
> >
> > On Tue, Aug 22, 2023 at 5:32 PM Rob Herring <robh@kernel.org> wrote:
> > > On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> > > > Run the test for the overlay apply/revert sequence three times, to
> > > > test if there are unbalanced of_node_put() calls causing reference
> > > > counts to become negative.
> > > >
> > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > ---
> > > > This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> > > > ("of/platform: increase refcount of fwnode") in dt/linus.
> > >
> > > Is this necessary? There were WARN backtraces without that fix.
> >
> > Did you see them?
>
> Yes, but that was also with your series applied. When I tested the
> fix, I had dropped that, so maybe your series triggered it too.

With the fix reverted on my dt/linus branch, I get this:

[ 1.269977] ### dt-test ### pass of_unittest_overlay_10():2507
[ 1.270123] ### dt-test ### pass of_unittest_overlay_10():2513
[ 1.270290] ### dt-test ### pass of_unittest_overlay_10():2519
[ 1.275673] ------------[ cut here ]------------
[ 1.275790] refcount_t: addition on 0; use-after-free.
[ 1.276118] WARNING: CPU: 1 PID: 1 at lib/refcount.c:25
refcount_warn_saturate+0x120/0x144
[ 1.276343] Modules linked in:
[ 1.276558] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G N
6.5.0-rc1-00010-g8e081e8346d1 #84
[ 1.276791] Hardware name: linux,dummy-virt (DT)
[ 1.276973] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 1.277114] pc : refcount_warn_saturate+0x120/0x144
[ 1.277219] lr : refcount_warn_saturate+0x120/0x144
[ 1.277332] sp : ffff80008002b630
[ 1.277410] x29: ffff80008002b630 x28: ffff80008002b978 x27: ffff0a00ffffff05
[ 1.277585] x26: ffff80008002b9a9 x25: ffffd5ba808bec2f x24: ffff452a08002f18
[ 1.277738] x23: ffff0000ffffff00 x22: ffff80008002b978 x21: 0000000000000000
[ 1.277895] x20: ffff80008002b9dd x19: ffff452a08002f80 x18: 0000000000000006
[ 1.278052] x17: 73657474696e752d x16: 747365743a313174 x15: 0765076507720766
[ 1.278200] x14: 072d077207650774 x13: ffffd5b9814a0660 x12: 000000000000069c
[ 1.278357] x11: 0000000000000234 x10: ffffd5b9814f8660 x9 : ffffd5b9814a0660
[ 1.278529] x8 : 00000000ffffefff x7 : ffffd5b9814f8660 x6 : 80000000fffff000
[ 1.278680] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
[ 1.278829] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff452a02cb8000
[ 1.279041] Call trace:
[ 1.279171] refcount_warn_saturate+0x120/0x144
[ 1.279322] kobject_get+0xb8/0xbc
[ 1.279416] of_node_get+0x20/0x34
[ 1.279497] of_fwnode_get+0x34/0x54
[ 1.279567] fwnode_get_nth_parent+0xf0/0x12c
[ 1.279666] fwnode_full_name_string+0x48/0xb8
[ 1.279764] device_node_string+0x380/0x5a4
[ 1.279841] pointer+0x38c/0x4ac
[ 1.279900] vsnprintf+0x14c/0x6d0
[ 1.279970] vprintk_store+0x168/0x47c
[ 1.280055] vprintk_emit+0x104/0x2b4
[ 1.280122] vprintk_default+0x38/0x44
[ 1.280189] vprintk+0xd4/0xf0
[ 1.280262] _printk+0x5c/0x84
[ 1.280332] of_node_release+0x1ac/0x1b4
[ 1.280413] kobject_put+0xb0/0x220
[ 1.280492] of_changeset_destroy+0x50/0xf4
[ 1.280584] free_overlay_changeset+0x24/0x104
[ 1.280680] of_overlay_remove+0x240/0x2b8
[ 1.280766] of_unittest_apply_revert_overlay_check.constprop.0+0xa8/0x310
[ 1.280904] of_unittest+0xbf4/0x2e64
[ 1.280986] do_one_initcall+0x7c/0x1c0
[ 1.281072] kernel_init_freeable+0x1c4/0x294
[ 1.281161] kernel_init+0x24/0x1dc
[ 1.281242] ret_from_fork+0x10/0x20

Then later on:

[ 1.459652] ### dt-test ### EXPECT \ : ------------[ cut here ]------------
[ 1.459877] ### dt-test ### EXPECT \ : WARNING: <<all>>
[ 1.460227] ### dt-test ### EXPECT \ : refcount_t: underflow; use-after-free.
[ 1.460508] ### dt-test ### EXPECT \ : ---[ end trace <<int>> ]---
[ 1.460860] ### dt-test ### pass of_unittest_lifecycle():3187
[ 1.461455] ### dt-test ### EXPECT / : ---[ end trace <<int>> ]---
[ 1.461463] ### dt-test ### EXPECT / : refcount_t: underflow; use-after-free.
[ 1.461789] ### dt-test ### EXPECT / : WARNING: <<all>>
[ 1.462137] ### dt-test ### EXPECT / : ------------[ cut here ]------------

So it seems we were getting the warning, but at the wrong point.

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-22 19:21       ` Rob Herring
@ 2023-08-23  7:41         ` Geert Uytterhoeven
  2023-08-23 13:26           ` Rob Herring
  0 siblings, 1 reply; 8+ messages in thread
From: Geert Uytterhoeven @ 2023-08-23  7:41 UTC (permalink / raw)
  To: Rob Herring; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

Hi Rob,

On Tue, Aug 22, 2023 at 9:22 PM Rob Herring <robh@kernel.org> wrote:
> On Tue, Aug 22, 2023 at 12:59 PM Rob Herring <robh@kernel.org> wrote:
> > On Tue, Aug 22, 2023 at 12:52 PM Geert Uytterhoeven
> > <geert@linux-m68k.org> wrote:
> > >
> > > Hi Rob,
> > >
> > > On Tue, Aug 22, 2023 at 5:32 PM Rob Herring <robh@kernel.org> wrote:
> > > > On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> > > > > Run the test for the overlay apply/revert sequence three times, to
> > > > > test if there are unbalanced of_node_put() calls causing reference
> > > > > counts to become negative.
> > > > >
> > > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > > ---
> > > > > This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> > > > > ("of/platform: increase refcount of fwnode") in dt/linus.
> > > >
> > > > Is this necessary? There were WARN backtraces without that fix.
> > >
> > > Did you see them?
> >
> > Yes, but that was also with your series applied. When I tested the
> > fix, I had dropped that, so maybe your series triggered it too.
>
> With the fix reverted on my dt/linus branch, I get this:
>
> [ 1.269977] ### dt-test ### pass of_unittest_overlay_10():2507
> [ 1.270123] ### dt-test ### pass of_unittest_overlay_10():2513
> [ 1.270290] ### dt-test ### pass of_unittest_overlay_10():2519
> [ 1.275673] ------------[ cut here ]------------
> [ 1.275790] refcount_t: addition on 0; use-after-free.
> [ 1.276118] WARNING: CPU: 1 PID: 1 at lib/refcount.c:25
> refcount_warn_saturate+0x120/0x144
> [ 1.276343] Modules linked in:
> [ 1.276558] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G N
> 6.5.0-rc1-00010-g8e081e8346d1 #84
> [ 1.276791] Hardware name: linux,dummy-virt (DT)
> [ 1.276973] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [ 1.277114] pc : refcount_warn_saturate+0x120/0x144
> [ 1.277219] lr : refcount_warn_saturate+0x120/0x144
> [ 1.277332] sp : ffff80008002b630
> [ 1.277410] x29: ffff80008002b630 x28: ffff80008002b978 x27: ffff0a00ffffff05
> [ 1.277585] x26: ffff80008002b9a9 x25: ffffd5ba808bec2f x24: ffff452a08002f18
> [ 1.277738] x23: ffff0000ffffff00 x22: ffff80008002b978 x21: 0000000000000000
> [ 1.277895] x20: ffff80008002b9dd x19: ffff452a08002f80 x18: 0000000000000006
> [ 1.278052] x17: 73657474696e752d x16: 747365743a313174 x15: 0765076507720766
> [ 1.278200] x14: 072d077207650774 x13: ffffd5b9814a0660 x12: 000000000000069c
> [ 1.278357] x11: 0000000000000234 x10: ffffd5b9814f8660 x9 : ffffd5b9814a0660
> [ 1.278529] x8 : 00000000ffffefff x7 : ffffd5b9814f8660 x6 : 80000000fffff000
> [ 1.278680] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
> [ 1.278829] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff452a02cb8000
> [ 1.279041] Call trace:
> [ 1.279171] refcount_warn_saturate+0x120/0x144
> [ 1.279322] kobject_get+0xb8/0xbc
> [ 1.279416] of_node_get+0x20/0x34
> [ 1.279497] of_fwnode_get+0x34/0x54
> [ 1.279567] fwnode_get_nth_parent+0xf0/0x12c
> [ 1.279666] fwnode_full_name_string+0x48/0xb8
> [ 1.279764] device_node_string+0x380/0x5a4
> [ 1.279841] pointer+0x38c/0x4ac
> [ 1.279900] vsnprintf+0x14c/0x6d0
> [ 1.279970] vprintk_store+0x168/0x47c
> [ 1.280055] vprintk_emit+0x104/0x2b4
> [ 1.280122] vprintk_default+0x38/0x44
> [ 1.280189] vprintk+0xd4/0xf0
> [ 1.280262] _printk+0x5c/0x84
> [ 1.280332] of_node_release+0x1ac/0x1b4
> [ 1.280413] kobject_put+0xb0/0x220
> [ 1.280492] of_changeset_destroy+0x50/0xf4
> [ 1.280584] free_overlay_changeset+0x24/0x104
> [ 1.280680] of_overlay_remove+0x240/0x2b8
> [ 1.280766] of_unittest_apply_revert_overlay_check.constprop.0+0xa8/0x310
> [ 1.280904] of_unittest+0xbf4/0x2e64
> [ 1.280986] do_one_initcall+0x7c/0x1c0
> [ 1.281072] kernel_init_freeable+0x1c4/0x294
> [ 1.281161] kernel_init+0x24/0x1dc
> [ 1.281242] ret_from_fork+0x10/0x20
>
> Then later on:
>
> [ 1.459652] ### dt-test ### EXPECT \ : ------------[ cut here ]------------
> [ 1.459877] ### dt-test ### EXPECT \ : WARNING: <<all>>
> [ 1.460227] ### dt-test ### EXPECT \ : refcount_t: underflow; use-after-free.
> [ 1.460508] ### dt-test ### EXPECT \ : ---[ end trace <<int>> ]---
> [ 1.460860] ### dt-test ### pass of_unittest_lifecycle():3187
> [ 1.461455] ### dt-test ### EXPECT / : ---[ end trace <<int>> ]---
> [ 1.461463] ### dt-test ### EXPECT / : refcount_t: underflow; use-after-free.
> [ 1.461789] ### dt-test ### EXPECT / : WARNING: <<all>>
> [ 1.462137] ### dt-test ### EXPECT / : ------------[ cut here ]------------
>
> So it seems we were getting the warning, but at the wrong point.

Thanks (and confirmed), I had missed that.

Note that it did not cause any test failures, though:

    ### dt-test ### end of unittest - 302 passed, 0 failed

With this patch:

    ### dt-test ### end of unittest - 303 passed, 1 failed

Anyway, it's up to you to decide to apply or not...

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
  2023-08-23  7:41         ` Geert Uytterhoeven
@ 2023-08-23 13:26           ` Rob Herring
  0 siblings, 0 replies; 8+ messages in thread
From: Rob Herring @ 2023-08-23 13:26 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: Frank Rowand, Peng Fan, devicetree, linux-renesas-soc

On Wed, Aug 23, 2023 at 09:41:40AM +0200, Geert Uytterhoeven wrote:
> Hi Rob,
> 
> On Tue, Aug 22, 2023 at 9:22 PM Rob Herring <robh@kernel.org> wrote:
> > On Tue, Aug 22, 2023 at 12:59 PM Rob Herring <robh@kernel.org> wrote:
> > > On Tue, Aug 22, 2023 at 12:52 PM Geert Uytterhoeven
> > > <geert@linux-m68k.org> wrote:
> > > >
> > > > Hi Rob,
> > > >
> > > > On Tue, Aug 22, 2023 at 5:32 PM Rob Herring <robh@kernel.org> wrote:
> > > > > On Tue, Aug 22, 2023 at 12:22:34PM +0200, Geert Uytterhoeven wrote:
> > > > > > Run the test for the overlay apply/revert sequence three times, to
> > > > > > test if there are unbalanced of_node_put() calls causing reference
> > > > > > counts to become negative.
> > > > > >
> > > > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > > > > > ---
> > > > > > This is a reproducer for the issue fixed by commit 7882541ca06d51a6
> > > > > > ("of/platform: increase refcount of fwnode") in dt/linus.
> > > > >
> > > > > Is this necessary? There were WARN backtraces without that fix.
> > > >
> > > > Did you see them?
> > >
> > > Yes, but that was also with your series applied. When I tested the
> > > fix, I had dropped that, so maybe your series triggered it too.
> >
> > With the fix reverted on my dt/linus branch, I get this:
> >
> > [ 1.269977] ### dt-test ### pass of_unittest_overlay_10():2507
> > [ 1.270123] ### dt-test ### pass of_unittest_overlay_10():2513
> > [ 1.270290] ### dt-test ### pass of_unittest_overlay_10():2519
> > [ 1.275673] ------------[ cut here ]------------
> > [ 1.275790] refcount_t: addition on 0; use-after-free.
> > [ 1.276118] WARNING: CPU: 1 PID: 1 at lib/refcount.c:25
> > refcount_warn_saturate+0x120/0x144
> > [ 1.276343] Modules linked in:
> > [ 1.276558] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G N
> > 6.5.0-rc1-00010-g8e081e8346d1 #84
> > [ 1.276791] Hardware name: linux,dummy-virt (DT)
> > [ 1.276973] pstate: 600000c5 (nZCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> > [ 1.277114] pc : refcount_warn_saturate+0x120/0x144
> > [ 1.277219] lr : refcount_warn_saturate+0x120/0x144
> > [ 1.277332] sp : ffff80008002b630
> > [ 1.277410] x29: ffff80008002b630 x28: ffff80008002b978 x27: ffff0a00ffffff05
> > [ 1.277585] x26: ffff80008002b9a9 x25: ffffd5ba808bec2f x24: ffff452a08002f18
> > [ 1.277738] x23: ffff0000ffffff00 x22: ffff80008002b978 x21: 0000000000000000
> > [ 1.277895] x20: ffff80008002b9dd x19: ffff452a08002f80 x18: 0000000000000006
> > [ 1.278052] x17: 73657474696e752d x16: 747365743a313174 x15: 0765076507720766
> > [ 1.278200] x14: 072d077207650774 x13: ffffd5b9814a0660 x12: 000000000000069c
> > [ 1.278357] x11: 0000000000000234 x10: ffffd5b9814f8660 x9 : ffffd5b9814a0660
> > [ 1.278529] x8 : 00000000ffffefff x7 : ffffd5b9814f8660 x6 : 80000000fffff000
> > [ 1.278680] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
> > [ 1.278829] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff452a02cb8000
> > [ 1.279041] Call trace:
> > [ 1.279171] refcount_warn_saturate+0x120/0x144
> > [ 1.279322] kobject_get+0xb8/0xbc
> > [ 1.279416] of_node_get+0x20/0x34
> > [ 1.279497] of_fwnode_get+0x34/0x54
> > [ 1.279567] fwnode_get_nth_parent+0xf0/0x12c
> > [ 1.279666] fwnode_full_name_string+0x48/0xb8
> > [ 1.279764] device_node_string+0x380/0x5a4
> > [ 1.279841] pointer+0x38c/0x4ac
> > [ 1.279900] vsnprintf+0x14c/0x6d0
> > [ 1.279970] vprintk_store+0x168/0x47c
> > [ 1.280055] vprintk_emit+0x104/0x2b4
> > [ 1.280122] vprintk_default+0x38/0x44
> > [ 1.280189] vprintk+0xd4/0xf0
> > [ 1.280262] _printk+0x5c/0x84
> > [ 1.280332] of_node_release+0x1ac/0x1b4
> > [ 1.280413] kobject_put+0xb0/0x220
> > [ 1.280492] of_changeset_destroy+0x50/0xf4
> > [ 1.280584] free_overlay_changeset+0x24/0x104
> > [ 1.280680] of_overlay_remove+0x240/0x2b8
> > [ 1.280766] of_unittest_apply_revert_overlay_check.constprop.0+0xa8/0x310
> > [ 1.280904] of_unittest+0xbf4/0x2e64
> > [ 1.280986] do_one_initcall+0x7c/0x1c0
> > [ 1.281072] kernel_init_freeable+0x1c4/0x294
> > [ 1.281161] kernel_init+0x24/0x1dc
> > [ 1.281242] ret_from_fork+0x10/0x20
> >
> > Then later on:
> >
> > [ 1.459652] ### dt-test ### EXPECT \ : ------------[ cut here ]------------
> > [ 1.459877] ### dt-test ### EXPECT \ : WARNING: <<all>>
> > [ 1.460227] ### dt-test ### EXPECT \ : refcount_t: underflow; use-after-free.
> > [ 1.460508] ### dt-test ### EXPECT \ : ---[ end trace <<int>> ]---
> > [ 1.460860] ### dt-test ### pass of_unittest_lifecycle():3187
> > [ 1.461455] ### dt-test ### EXPECT / : ---[ end trace <<int>> ]---
> > [ 1.461463] ### dt-test ### EXPECT / : refcount_t: underflow; use-after-free.
> > [ 1.461789] ### dt-test ### EXPECT / : WARNING: <<all>>
> > [ 1.462137] ### dt-test ### EXPECT / : ------------[ cut here ]------------
> >
> > So it seems we were getting the warning, but at the wrong point.
> 
> Thanks (and confirmed), I had missed that.
> 
> Note that it did not cause any test failures, though:
> 
>     ### dt-test ### end of unittest - 302 passed, 0 failed
> 
> With this patch:
> 
>     ### dt-test ### end of unittest - 303 passed, 1 failed
> 
> Anyway, it's up to you to decide to apply or not...

I guess that is better than searching thru the log. Applied.

Rob

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] of: unittest: Run overlay apply/revert sequence three times
       [not found] <a9fb4eb560c58d11a7f167bc78a137b46e76cf15.1692699743.git.geert%2Brenesas@glider.be>
@ 2023-08-29  4:37 ` kernel test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2023-08-29  4:37 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: oe-lkp, lkp, devicetree, Rob Herring, Frank Rowand, Peng Fan,
	linux-renesas-soc, Geert Uytterhoeven, oliver.sang



Hello,

kernel test robot noticed "WARNING:at_fs/kernfs/dir.c:#kernfs_remove_by_name_ns" on:

commit: 95a0a69f906c49a1d6ccdcf226e5bda43559548b ("[PATCH] of: unittest: Run overlay apply/revert sequence three times")
url: https://github.com/intel-lab-lkp/linux/commits/Geert-Uytterhoeven/of-unittest-Run-overlay-apply-revert-sequence-three-times/20230822-182410
base: https://git.kernel.org/cgit/linux/kernel/git/robh/linux.git for-next
patch link: https://lore.kernel.org/all/a9fb4eb560c58d11a7f167bc78a137b46e76cf15.1692699743.git.geert%2Brenesas@glider.be/
patch subject: [PATCH] of: unittest: Run overlay apply/revert sequence three times

in testcase: boot

compiler: gcc-9
test machine: qemu-system-i386 -enable-kvm -cpu SandyBridge -smp 2 -m 4G

(please refer to attached dmesg/kmsg for entire log/backtrace)



If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202308251623.c4668e73-oliver.sang@intel.com



[   24.207339][    T1] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
[   24.209547][    T1] ------------[ cut here ]------------
[   24.210305][    T1] kernfs: can not remove 'status', no directory
[   24.211312][    T1] WARNING: CPU: 0 PID: 1 at fs/kernfs/dir.c:1658 kernfs_remove_by_name_ns+0x17/0x76
[   24.212833][    T1] Modules linked in:
[   24.213403][    T1] CPU: 0 PID: 1 Comm: swapper Tainted: G        W        N 6.5.0-rc1-00023-g95a0a69f906c #1
[   24.214935][    T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
[   24.216555][    T1] EIP: kernfs_remove_by_name_ns+0x17/0x76
[   24.217540][    T1] Code: f0 e8 96 d2 e7 ff 8a 55 df 88 d0 83 c4 18 5b 5e 5f 5d c3 55 89 e5 56 53 83 ec 08 85 c0 75 16 52 68 35 75 4f b2 e8 0e fc e4 ff <0f> 0b 58 b8 fe ff ff ff 5a eb 4d 89 4d f0 89 c3 89 55 f4 e8 69 e6
[   24.220332][    T1] EAX: 0000002d EBX: ed6ed158 ECX: 00000000 EDX: 00000002
[   24.221538][    T1] ESI: 00000000 EDI: 00000216 EBP: b42f7d88 ESP: b42f7d70
[   24.222665][    T1] DS: 007b ES: 007b FS: 0000 GS: 0000 SS: 0068 EFLAGS: 00010246
[   24.223933][    T1] CR0: 80050033 CR2: ffddb000 CR3: 02f04000 CR4: 00040690
[   24.225140][    T1] DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
[   24.226298][    T1] DR6: fffe0ff0 DR7: 00000400
[   24.227115][    T1] Call Trace:
[   24.227804][    T1]  ? show_regs+0x49/0x4f
[   24.228595][    T1]  ? kernfs_remove_by_name_ns+0x17/0x76
[   24.229560][    T1]  ? __warn+0x81/0xfe
[   24.230152][    T1]  ? report_bug+0xb0/0x10c
[   24.230975][    T1]  ? kernfs_remove_by_name_ns+0x17/0x76
[   24.231914][    T1]  ? exc_overflow+0x37/0x37
[   24.232734][    T1]  ? handle_bug+0x2b/0x47
[   24.233364][    T1]  ? exc_invalid_op+0x19/0x55
[   24.234248][    T1]  ? handle_exception+0xfd/0xfd
[   24.235098][    T1]  ? exc_overflow+0x37/0x37
[   24.235877][    T1]  ? kernfs_remove_by_name_ns+0x17/0x76
[   24.236835][    T1]  ? exc_overflow+0x37/0x37
[   24.237662][    T1]  ? kernfs_remove_by_name_ns+0x17/0x76
[   24.238667][    T1]  sysfs_remove_bin_file+0xf/0x11
[   24.239383][    T1]  __of_sysfs_remove_bin_file+0x11/0x1c
[   24.240341][    T1]  __of_update_property_sysfs+0x1e/0x2d
[   24.241249][    T1]  __of_changeset_entry_apply+0x150/0x15a
[   24.242221][    T1]  __of_changeset_apply_entries+0x1b/0x65
[   24.243185][    T1]  ? overlay_notify+0x37/0x81
[   24.243954][    T1]  of_overlay_fdt_apply+0x3e3/0x463
[   24.244827][    T1]  overlay_data_apply+0x5c/0x94
[   24.245635][    T1]  of_unittest_apply_overlay+0x18/0x54
[   24.246690][    T1]  of_unittest_apply_revert_overlay_check+0x57/0x142
[   24.247934][    T1]  of_unittest_overlay+0x2b1/0x8bc
[   24.248801][    T1]  of_unittest+0xcaf/0xcf5
[   24.249537][    T1]  ? sched_clock_noinstr+0x8/0xc
[   24.250258][    T1]  ? of_unittest_changeset+0x838/0x838
[   24.251123][    T1]  do_one_initcall+0x6a/0x1a5
[   24.251928][    T1]  kernel_init_freeable+0x17a/0x1c9
[   24.252774][    T1]  ? rest_init+0x140/0x140
[   24.253396][    T1]  kernel_init+0x12/0xf8
[   24.254130][    T1]  ret_from_fork+0x19/0x24
[   24.254890][    T1] irq event stamp: 2494581
[   24.255636][    T1] hardirqs last  enabled at (2494593): [<b1067cf6>] __up_console_sem+0x3d/0x52
[   24.257029][    T1] hardirqs last disabled at (2494604): [<b1067cd9>] __up_console_sem+0x20/0x52
[   24.258525][    T1] softirqs last  enabled at (2494484): [<b1e9fe62>] __do_softirq+0x2aa/0x2d8
[   24.259940][    T1] softirqs last disabled at (2494473): [<b1008ef8>] do_softirq_own_stack+0x2a/0x30
[   24.261703][    T1] ---[ end trace 0000000000000000 ]---
[   24.262682][    T1] ### dt-test ### FAIL of_unittest_apply_revert_overlay_check():2167 overlay_5 failed to create @"/testcase-data/overlay-node/test-bus/test-unittest5" disabled
[   24.265226][    T1] ### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest5/status
[   24.265263][    T1] ### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
[   24.267833][    T1] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
[   24.273345][    T1] ### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest6/status
[   24.273352][    T1] ### dt-test ### EXPECT \ : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
[   24.275907][    T1] OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status
[   24.281335][    T1] ### dt-test ### EXPECT / : OF: overlay: WARNING: memory leak will occur if overlay removed, property: /testcase-data/overlay-node/test-bus/test-unittest7/status



The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20230825/202308251623.c4668e73-oliver.sang@intel.com



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-08-29  4:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-22 10:22 [PATCH] of: unittest: Run overlay apply/revert sequence three times Geert Uytterhoeven
2023-08-22 15:32 ` Rob Herring
2023-08-22 17:52   ` Geert Uytterhoeven
2023-08-22 17:59     ` Rob Herring
2023-08-22 19:21       ` Rob Herring
2023-08-23  7:41         ` Geert Uytterhoeven
2023-08-23 13:26           ` Rob Herring
     [not found] <a9fb4eb560c58d11a7f167bc78a137b46e76cf15.1692699743.git.geert%2Brenesas@glider.be>
2023-08-29  4:37 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).