ubi: part: Claim only the block device UBI created
Subsystems (2)
PATCH 1/1 ubi: part: Claim only the block device UBI created
part_test_ubi() reports success for any block device whose first block it can read, as soon as a UBI device is attached anywhere in the system. It never looks at which device it was handed, so any device that has no partition table of its own is labelled as holding UBI volumes:
=> ut imagemap ubiblock
=> blkmap create x
=> blkmap map x 0 800 mem 0x1000000
=> part list blkmap 0
Partition Map for blkmap device 0 -- Partition Type: ubi
0: vol0
The blkmap there is blank, and vol0 lives on nand2.
Check that the descriptor belongs to the block device ubi_bind() created before claiming it. cmd/ubi.c and test/boot/imagemap.c already pick that device out the same way.
---
This was discovered while adding additional tests for the GPT layout using blkmap, where it turned out that a stale UBI partition table gets recognized on the blkmap where none exists.
CI for this: https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1327
--- drivers/mtd/ubi/part.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mtd/ubi/part.c +9 -0
@@ -8,6 +8,7 @@#include <memalign.h> #include <part.h> #include <ubi_uboot.h> +#include <dm/device.h> static inline struct ubi_device *get_ubi_device (void ) {
@@ -92,6 +93,14 @@ static int part_test_ubi(struct blk_desc *dev_desc)if (!get_ubi_device ())return -1 ; +/* +* Only the block device UBI itself created holds UBI volumes. Without +* this, every readable block device in the system is claimed as soon as +* a UBI device is attached anywhere. +*/ +if (!dev_desc->bdev || dev_desc->bdev->driver !=DM_DRIVER_GET (ubi_blk)) +return -1 ; +if (blk_dread (dev_desc,0 ,1 , (ulong *)buffer) !=1 )return -1 ;
---
base-commit: b8e0086b585791a771416ce51b58ce0097bc0b28
change-id: 20260918-ubi-part-test-b261e36d6a78
Best regards,
Signature · 1 line
Alexey Charkov <[email protected]>
Hello Alexey,
Quoted 27 lines · Alexey Charkov
part_test_ubi()reports success for any block device whose first block it can read, as soon as a UBI device is attached anywhere in the system. It never looks at which device it was handed, so any device that has no partition table of its own is labelled as holding UBI volumes:=> ut imagemap ubiblock
=> blkmap create x
=> blkmap map x 0 800 mem0x1000000
=> part list blkmap 0Partition Map for blkmap device 0 -- Partition Type: ubi
0: vol0The blkmap there is blank, and vol0 lives on nand2.
Check that the descriptor belongs to the block device
ubi_bind()created before claiming it.cmd/ubi.candtest/boot/imagemap.calready pick that device out the same way.Fixes aa5b67ce2262 ("disk: support UBI partitions")Signed-off-by Alexey Charkov <[email protected]>---
This was discovered while adding additional tests for the GPT layout using blkmap, where it turned out that a stale UBI partition table gets recognized on the blkmap where none exists.
Quoted 4 lines
CI for this: https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1327
--- drivers/mtd/ubi/part.c | 9 +++++++++ 1 file changed, 9 insertions(+)
Thanks!
bye,
Heiko
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic
Hello Alexey,
Quoted 30 lines · Heiko Schocher
Hello Alexey,
Quoted 27 lines · Alexey Charkov
part_test_ubi()reports success for any block device whose first block it can read, as soon as a UBI device is attached anywhere in the system. It never looks at which device it was handed, so any device that has no partition table of its own is labelled as holding UBI volumes:=> ut imagemap ubiblock
=> blkmap create x
=> blkmap map x 0 800 mem0x1000000
=> part list blkmap 0Partition Map for blkmap device 0 -- Partition Type: ubi
0: vol0
The blkmap there is blank, and vol0 lives on nand2.
Check that the descriptor belongs to the block device
ubi_bind()created before claiming it.cmd/ubi.candtest/boot/imagemap.calready pick that device out the same way.Fixes aa5b67ce2262 ("disk: support UBI partitions")Signed-off-by Alexey Charkov <[email protected]>---
This was discovered while adding additional tests for the GPT layout using blkmap, where it turned out that a stale UBI partition table gets recognized on the blkmap where none exists.
Quoted 6 lines
Quoted 4 lines
CI for this: https://git.u-boot-project.org/u-boot/contributors/alchark/u-boot/-/pipelines/1327
---
drivers/mtd/ubi/part.c| 9 +++++++++1 file changed, 9 insertions(+)Reviewed-by Heiko Schocher <[email protected]>
pushed to u-boot-ubi, thanks!
bye,
Heiko
Quoted 5 lines
Thanks!
bye,
Heiko
Signature · 5 lines
Nabla Software Engineering HRB 40522 Augsburg Phone: +49 821 45592596 E-Mail: [email protected] Geschäftsführer : Stefano Babic