mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] drivers: of: bugfix partition fixups
@ 2018-06-07 17:40 Pascal Vizeli
  2018-06-08  7:05 ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Vizeli @ 2018-06-07 17:40 UTC (permalink / raw)
  To: barebox; +Cc: Pascal Vizeli

If we load a new device tree for linux kernel with a diferent layout,
the fixup of partition going into endless loop. Exactly the of_find_property
function will never come back on a invalid device_node.

My patch check, if the device will exists on device tree before we run the
fixup.

Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
---
 drivers/of/partition.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/of/partition.c b/drivers/of/partition.c
index aa6e601b7..17e420964 100644
--- a/drivers/of/partition.c
+++ b/drivers/of/partition.c
@@ -140,6 +140,9 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
 	if (!cdev->device_node)
 		return -EINVAL;
 
+	if (!of_find_node_by_path(cdev->device_node->full_name))
+		return -EINVAL;
+
 	list_for_each_entry(partcdev, &cdev->partitions, partition_entry) {
 		if (partcdev->flags & DEVFS_PARTITION_FROM_TABLE)
 			continue;
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/1] drivers: of: bugfix partition fixups
  2018-06-07 17:40 [PATCH 1/1] drivers: of: bugfix partition fixups Pascal Vizeli
@ 2018-06-08  7:05 ` Sascha Hauer
  2018-06-08  7:31   ` Pascal Vizeli
  0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2018-06-08  7:05 UTC (permalink / raw)
  To: Pascal Vizeli; +Cc: barebox

On Thu, Jun 07, 2018 at 05:40:11PM +0000, Pascal Vizeli wrote:
> If we load a new device tree for linux kernel with a diferent layout,
> the fixup of partition going into endless loop. Exactly the of_find_property
> function will never come back on a invalid device_node.

of_find_property is not called directly from the code you are changing,
so how excatly is the code path that fails?

> 
> My patch check, if the device will exists on device tree before we run the
> fixup.
> 
> Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch>
> ---
>  drivers/of/partition.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/of/partition.c b/drivers/of/partition.c
> index aa6e601b7..17e420964 100644
> --- a/drivers/of/partition.c
> +++ b/drivers/of/partition.c
> @@ -140,6 +140,9 @@ static int of_partition_fixup(struct device_node *root, void *ctx)
>  	if (!cdev->device_node)
>  		return -EINVAL;
>  
> +	if (!of_find_node_by_path(cdev->device_node->full_name))
> +		return -EINVAL;
> +

What are you doing to get into this situation? This test should never
fail or else we are in trouble. Is there some "oftree -f" command
involved? I should really remove this command since in a device tree
based system there are always references to device nodes which are not
expected to become invalid.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/1] drivers: of: bugfix partition fixups
  2018-06-08  7:05 ` Sascha Hauer
@ 2018-06-08  7:31   ` Pascal Vizeli
  2018-06-11  6:41     ` Sascha Hauer
  0 siblings, 1 reply; 4+ messages in thread
From: Pascal Vizeli @ 2018-06-08  7:31 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox, Pascal Vizeli

2018-06-08 9:05 GMT+02:00 Sascha Hauer <s.hauer@pengutronix.de>:
> of_find_property is not called directly from the code you are changing,
> so how excatly is the code path that fails?

of_get_reproducible_name -> of_get_property -> of_find_property

>
> What are you doing to get into this situation? This test should never
> fail or else we are in trouble. Is there some "oftree -f" command
> involved? I should really remove this command since in a device tree
> based system there are always references to device nodes which are not
> expected to become invalid.
>

Yes, I load the device tree from first bootloader and overlay some state dtbo.
But how I should do this without flush? I can do that also an a file
and load this
to bootm, but the fixups will also run on this and fails too.

I think we need remove `oftree -f` or apply this patch for hardening.

Greets
Pascal

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/1] drivers: of: bugfix partition fixups
  2018-06-08  7:31   ` Pascal Vizeli
@ 2018-06-11  6:41     ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2018-06-11  6:41 UTC (permalink / raw)
  To: Pascal Vizeli; +Cc: barebox, Pascal Vizeli

On Fri, Jun 08, 2018 at 09:31:24AM +0200, Pascal Vizeli wrote:
> 2018-06-08 9:05 GMT+02:00 Sascha Hauer <s.hauer@pengutronix.de>:
> > of_find_property is not called directly from the code you are changing,
> > so how excatly is the code path that fails?
> 
> of_get_reproducible_name -> of_get_property -> of_find_property
> 
> >
> > What are you doing to get into this situation? This test should never
> > fail or else we are in trouble. Is there some "oftree -f" command
> > involved? I should really remove this command since in a device tree
> > based system there are always references to device nodes which are not
> > expected to become invalid.
> >
> 
> Yes, I load the device tree from first bootloader and overlay some state dtbo.
> But how I should do this without flush? I can do that also an a file
> and load this
> to bootm, but the fixups will also run on this and fails too.
> 
> I think we need remove `oftree -f` or apply this patch for hardening.

Just sent a patch for the former as the latter is a goal we do not seem
to reach.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2018-06-11  6:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 17:40 [PATCH 1/1] drivers: of: bugfix partition fixups Pascal Vizeli
2018-06-08  7:05 ` Sascha Hauer
2018-06-08  7:31   ` Pascal Vizeli
2018-06-11  6:41     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox