drivers: of: bugfix partition fixups
PATCH 1/1 drivers: of: bugfix partition fixups
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.
--- drivers/of/partition.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/partition.c +3 -0
@@ -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 ;
Signature · 7 lines
2.17.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Quoted 3 lines · 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_propertyfunction will never come back on a invaliddevice_node.
of_find_property is not called directly from the code you are changing, so how excatly is the code path that fails?
Quoted 14 lines
My patch check, if the device will exists on device tree before we run the fixup.
Signed-off-by Pascal Vizeli <[email protected]>--- drivers/of/partition.c | 3 +++ 1 file changed, 3 insertions(+)drivers/of/partition.c +0
-0
drivers/of/partition.c static int of_partition_fixup(struct device_node *root, void *ctx) · line 145
Quoted 6 lines
drivers/of/partition.c +3
-0@@ -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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox
2018-06-08 9:05 GMT+02:00 Sascha Hauer <[email protected]>:
Quoted 2 lines
of_find_propertyis 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
Quoted 7 lines
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
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Quoted 14 lines · Pascal Vizeli
2018-06-08 9:05 GMT+02:00 Sascha Hauer <[email protected]>:
Quoted 2 lines
of_find_propertyis 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_propertyQuoted 7 lines
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.
Quoted 6 lines
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 -for 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
Signature · 9 lines
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 [email protected] http://lists.infradead.org/mailman/listinfo/barebox