summaryrefslogtreecommitdiff
path: root/ufdt_convert.c
AgeCommit message (Collapse)Author
2022-12-16libufdt: don't overflow when handling propeties > INT_MAX in sizeMike McTernan
Ensure property sizes (read as uint32_t) don't overflow the int return value when being read. Fix up _ufdt_output_property_to_fdt() to avoid int overflow if a property len is near INT_MAX in size. Bug: 259062118 Ignore-AOSP-First: Security Test: mmma system/libufdt Test: system/libufdt/tests/run_tests.sh Test: system/libufdt/tests/run_performance_test.sh Change-Id: I03a56f68a7e53d941809560b943153b8fc31decc
2022-09-28Fix potential invalid root node from fdt_to_ufdt_tree() causing OOB access.Mike McTernan
Ignore-AOSP-First: Security Bug: 248085351 Test: mmma system/libufdt && system/libufdt/tests/run_tests.sh Test: mmma system/libufdt && system/libufdt/tests/run_performance_test.sh Test: Run fuzz reproducer. Test: Run fuzzer for 1 hour with 32 jobs. Change-Id: Idf4f87d45d9ce947a2e7508e5e2eb025b279c514
2022-09-15Fix handling of invalid alias property values.Mike McTernan
Bug: 246194233 Test: mmma system/libufdt && system/libufdt/tests/run_tests.sh Test: mmma system/libufdt && system/libufdt/tests/run_performance_test.sh Test: test with fuzzer case Test: run fuzzer to check coverage beyond added checks Ignore-AOSP-First: Security Change-Id: I229cd2ff97a1bea807fdb9d0f4642af5219fc0af
2022-08-22Merge "Fix count_phandle_node() / set_phandle_table_entry() equivalence. Fix ↵Mike McTernan
error path from ufdt_construct() and fdt_string()." am: 28c6744aeb am: 74077f063d am: b86858baa4 am: fe6d426707 am: c08f589c39 Original change: https://android-review.googlesource.com/c/platform/system/libufdt/+/2186596 Change-Id: I0203316c76d98f2775c34cd02e49eec8733904db Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-18Initialise phandle_table pointer.Mike McTernan
Bug: 242067561 Test: mmma system/libufdt && system/libufdt/tests/run_tests.sh Test: run with reproducer input Change-Id: Iaa7e49d27cfd4c90ed155a9be79aba9eb555e73b
2022-08-16Fix count_phandle_node() / set_phandle_table_entry() equivalence.Mike McTernan
Fix error path from ufdt_construct() and fdt_string(). Bug: 242700781 Test: system/libufdt/tests/run_tests.sh Test: system/libufdt/tests/run_performance_test.sh Test: Run with phandle > 2^31 Change-Id: Ia6e9821799830d1b6c775d20026a3e0aa73f78d9
2022-08-12Don't try and process a NULL ufdt tree.Mike McTernan
Ensure property_dict is freed on error path. Bug: 242090331 Test: Ran before and after fix with reproducer input. Test: system/libufdt/tests/run_tests.sh Tets: system/libufdt/tests/run_performance_tests.sh Change-Id: Id79d56f87e75e16cec733f47d273441788d5e644
2022-08-12Handle error return from fdt_next_tag() to break possible infinite loop.Mike McTernan
Bug: 242166628 Test: Ran before and after fix with reproducer input. Test: system/libufdt/tests/run_tests.sh Tets: system/libufdt/tests/run_performance_tests.sh Change-Id: Icb3dfddb2ffae27901cadcb5cc486556cbb4c6f5
2018-01-31Fix bug in ufdt_get_node_by_phandleHridya Valsaraju
Bug:67779848 Test: mm If the phandle being searched for exceeded the highest phandle in phandle_table.data, the bug was causing the return of the node corresponding to the highest phandle in phandle_table.data. Change-Id: I731c820b0c4bfe75a14cc1d22a34262b9905f365
2017-04-25libufdt: reduce the number of malloc/free callingSzuWei Lin
The performance of some bootloader malloc/free implementation isn't optimized, but libufdt calls huge number of malloc/free to build a real tree data structure. The patch adds an ufdt_node_pool to reduce the number of malloc/free. ufdt_node_pool asks a larger memory block in each time, and distributes the memory into several ufdt_node (ufdt_node_fdt_prop or ufdt_node_fdt_node). libufdt doesn't need to call malloc() to allocate memory until out of larger memory block. The setting of this patch is 1024 nodes in each memory block, so it can reduce ~1023/1024 malloc/free calling times after the patch is applied. Bug: 32969430 Test: ./tests/run_tests.sh Test: ./tests/run_performance_test.sh Change-Id: Id95e74da1235b9e2fc306500686515ee6b93017d
2017-04-15Code reviseSzuWei Lin
- Remove unused code - Remove internel functions from header file - Fix typos - Revise all function names with prefix ufdt_* Test: ./tests/run_tests.sh Change-Id: I4f89e90eb983540e78aadb092c07de62d219e454
2017-04-15Add Apache2 module licenseSzuWei Lin
Bug: 36678371 Test: mmm system/libufdt, and success build Change-Id: I73059f5beca2242f8883fca86cb49d53d0f543b8
2017-04-13Avoid to re-generate string table from ufdt to fdtSzuWei Lin
String table contains the strings of all property name in a fdt. The ufdt_apply_overlay() converts two dtbs from fdt to ufdt, overlays, and converts merged ufdt to fdt. These operations shouldn't create new peroperty names, so we can just re-use the string tables in original dtbs, and just copy them into merged fdt. This solution can enhance a lot of performance for device tree overlaying. To avoid the error that some users could use string offset in string table, the solution also give a same string offset for the name properties by ufdt_prop_dict; Futher, the patch also removed unused header files after changing algorithm. Bug: 35255584 Test: ./tests/run_tests.sh Change-Id: Id422730115531bd20d21117285291bdd860915ff
2017-04-10Fix memory and file leakSzuWei Lin
Bug: 35652061 Test: valgrind --leak-check=yes --show-reachable=yes ufdt_apply_overlay ... and result no leak Change-Id: Iec0fe77468d2fdf6c692209cd9571c02f96e2e44
2016-12-21libufdt: device tree overlay via unflattening FDTLi Chen
The original version of libdtoverlay is slow in searching for particular nodes and adding subnodes/properties due to the operations on flattened device tree (FDT). `libufdt` builds a real tree structure (named ufdt -- unflattned device tree) from FDT. In the real tree, we can perform certain operations (e.g., merge 2 subtrees, search for a node by path) in almost optimal time complexity with acceptable additional memory usage. With libufdt, we improve the merging of two dtb files from O(N^2) to O(N), where N is the number of nodes in the tree. Bug: 30800619 Test: run test scripts (see libufdt/tests/README) Test: manually ported libufdt into a bootloader, checked it can merge a base dtb and a dtbo to generate a final dtb to boot the device Change-Id: I1ff886bb8a62bad1451edcd7c4fe5cb48b7a034a
2016-12-14Revert "libufdt: device tree overlay via unflattening FDT"Jeff Hao
This reverts commit 3084ce7cbdff84093286459758f99c15082e6556. Change-Id: I36f8252ea77c75301711009180c1908bb18e231c
2016-12-05libufdt: device tree overlay via unflattening FDTLiChen
The original version of libdtoverlay is slow in searching for particular nodes and adding subnodes/properties due to the operations on flattened device tree (FDT). `libufdt` builds a real tree structure (named ufdt -- unflattned device tree) from FDT. In the real tree, we can perform certain operations (e.g., merge 2 subtrees, search for a node by path) in almost optimal time complexity with acceptable additional memory usage. With libufdt, we improve the merging of two dtb files from O(N^2) to O(N), where N is the number of nodes in the tree. Bug: 30800619 Test: run test scripts (see libufdt/tests/README) Test: manually ported libufdt into a bootloader, checked it can merge a base dtb and a dtbo to generate a final dtb to boot the device Change-Id: I6a282cc99129d5280ecbf40852723f83735fa523