summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* CI: Add build matrix with multiple Linux distributionsHEADmastermainBiswapriyo Nath2023-05-162-12/+48
| | | | | | | | | | set SETUPTOOLS_SCM_PRETEND_VERSION="0" variable because GitHub Actions does not copy the .git directory into the container. Without that, the build fails with the following error LookupError: setuptools-scm was unable to detect version for /__w/dtc/dtc. Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Correct invalid dts output with mixed phandles and integersDavid Gibson2023-05-143-0/+4
| | | | | | | | | | | | | | | | | | | | The handling of "type preservation" dts output is based on the idea of "phandles with arguments" in properties, which isn't really a thing, other than a fairly common convention about how bindings are written. There's nothing preventing a binding which freely mixes phandles and other integers in an array of cells. Currently write_propval() handles this incorrectly: specifically the case of a phandle which follows a regular integer in a 32-bit cell array, but without a new '< >' delimited causing an extra TYPE_UINT32 marker to be inserted. In this case it omits the necessary space between the integer and the phandle reference, leading to output which can't be sent back into dtc and parsed. Correct this, and update tests to match. I think this is more or less correct for now, but really write_propval() is a big mess :(. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* tests: Add additional tests for device graph checksJohannes Beisswenger2023-05-143-0/+61
| | | | | | | | | | * bad-graph-child-address.dts: additional child address test since the one in bad-graph.dts is now shadowed by its prerequisites also failing. * bad-graph-reg-cells.dts: test warnings produced by check_graph_reg(). Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks: Fix crash in graph_child_address if 'reg' cell size != 1Johannes Beisswenger2023-05-141-25/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If an endpoint node has a 'reg' property which consists of more than one cell (4 bytes) and given that matching '#address-cells' and '#size-cells' properties are specified on the port node an assertion is triggered in check_graph_child_address() before the relevant diagnostic checks in check_graph_reg() (called by check_graph_port() and check_graph_endpoint()) are executed. The issue is fixed by making graph_child_address depend on the graph_port and graph_endpoint checks. Additionally the assertion can also be triggered if the length of the 'reg' property is less than 4 bytes e.g. by specifying 'reg = "a";'. In that case however other warnings are produced highlighting the malformed property before dtc crashes. Example dts file triggering the issue: /dts-v1/; / { bar: bar { port { bar_con: endpoint { remote-endpoint = <&foo_con>; }; }; }; foo { port { #address-cells = <1>; #size-cells = <1>; // should always be 0 foo_con: endpoint@1 { reg = <1 2>; // causes assertion failure instead of diagnostic remote-endpoint = <&bar_con>; }; }; }; }; Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* livetree: fix off-by-one in propval_cell_n() bounds checkJohannes Beisswenger2023-05-141-1/+1
| | | | | Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Add definition for a GitHub Actions CI jobUwe Kleine-König2023-05-141-0/+33
| | | | | | The job just builds the full configuration on latest Ubuntu Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* Drop obsolete/broken CI definitionsUwe Kleine-König2023-05-142-88/+0
| | | | | | | (Free) Travis-ci is gone since November 2020, cirrus seems to be unreliable showing build breakages unrelated to changes. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* yaml: Depend on libyaml >= 0.2.3Uwe Kleine-König2023-05-143-3/+7
| | | | | | | | | | | libyaml before 0.2.3 expects non-const string parameters. Supporting both variants would require either cpp magic or ignoring "discarded-qualifiers" compiler warnings. For the sake of simplicity just support libyaml 0.2.3 and newer. Note that NO_YAML can be overwritten on the make command line. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
* tests: Add test cases for bad endpoint node and remote-endpoint prop checksJohannes Beisswenger2023-05-075-0/+46
| | | | | Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks: Fix segmentation fault in check_graph_nodeJohannes Beisswenger2023-05-071-0/+5
| | | | | | | | | | | | | | | | | | | | | | Dts files which contain an 'endpoint' node as a direct child of the root node cause a segmentation fault inside check_graph_node(). This type of error can easily happen when a 'remote-endpoint' property is accidentally placed outside the corresponding endpoint and port nodes. Example with 'endpoint' node: /dts-v1/; / { endpoint {}; }; Example with remote-endpoint property: /dts-v1/; / { foo { remote-endpoint = <0xdeadbeef>; }; }; Signed-off-by: Johannes Beisswenger <johannes.beisswenger@cetitec.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* improve documentation for fdt_path_offset()Rasmus Villemoes2023-05-031-1/+26
| | | | | | | | | | The current documentation doesn't mention the possibility of passing a non-absolute path and having that treated as an alias. Add that information, along with an example (which will further be expanded in a subsequent patch), and clarify when -FDT_ERR_BADPATH can be returned. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* add fdt_get_symbol() and fdt_get_symbol_namelen() functionsRasmus Villemoes2023-05-032-0/+47
| | | | | | | | The fdt_get_symbol_namelen() function will be used in a subsequent patch. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* use fdt_path_getprop_namelen() in fdt_get_alias_namelen()Rasmus Villemoes2023-05-031-7/+1
| | | | | | | Simplify the code by making use of the new helper. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* add fdt_path_getprop_namelen() helperRasmus Villemoes2023-05-031-0/+12
| | | | | | | | Add a wrapper for fdt_getprop_namelen() allowing one to specify the node by path instead of offset. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* doc: dt-object-internal: Fix a typoUwe Kleine-König2023-04-291-1/+1
| | | | | | Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Message-Id: <20230428163034.775288-1-u.kleine-koenig@pengutronix.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* fdtoverlay: Drop a a repeated articleUwe Kleine-König2023-04-281-1/+1
| | | | | Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* manual: Fix and improve documentation about -@Uwe Kleine-König2023-04-281-5/+3
| | | | | | | | | | | | | Device trees with a /plugin/ tag ("overlays") generate a __fixups__ node when needed and independent of -q being given or not. The same is true for __local__fixups__. So don't mention these two nodes in the paragraph about -@. To not shorten the description too much, describe the semantic of the properties contained in the generated __symbols__ node. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* fdtoverlay: Fix usage string to not mention "<type>"Uwe Kleine-König2023-03-181-3/+1
| | | | | | | | | fdtoverlay doesn't have a -t option, so explaining the type formats and modifier prefixes doesn't make much sense. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Message-Id: <20230315100819.13387-1-u.kleine-koenig@pengutronix.de> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* build-sys: add -Wwrite-stringsMarc-André Lureau2023-03-012-1/+2
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* tests: fix leaks spotted by ASANMarc-André Lureau2023-03-0110-21/+25
| | | | | | | | | Always allocate from open_blob_rw(), to simplify memory management. The fixes are not exhaustive. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* livetree: fix leak spotted by ASANMarc-André Lureau2023-03-011-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | ./dtc -I dts -O dtb -o overlay_base_manual_symbols.test.dtb /home/elmarco/src/dtc/tests/overlay_base_manual_symbols.dts ../data.c:109:2: runtime error: null pointer passed as argument 2, which is declared to never be null ================================================================= ==933317==ERROR: LeakSanitizer: detected memory leaks Direct leak of 24 byte(s) in 1 object(s) allocated from: #0 0x7f49a2aba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af) #1 0x43183d in xmalloc ../util.h:45 #2 0x43482f in data_add_marker ../data.c:230 #3 0x449bb8 in get_node_phandle ../livetree.c:632 #4 0x421058 in fixup_phandle_references ../checks.c:627 #5 0x41b0ba in check_nodes_props ../checks.c:141 #6 0x41b1c8 in check_nodes_props ../checks.c:144 #7 0x41b9f1 in run_check ../checks.c:181 #8 0x430a68 in process_checks ../checks.c:2057 #9 0x436abd in main ../dtc.c:327 #10 0x7f49a30d850f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) Only create data when necessary, and do not alias it. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> [dwg: Small fixup for a slightly different approach to adjacent cleanups] Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Make name_node() xstrdup its name argumentDavid Gibson2023-03-013-12/+15
| | | | | | | | | | | | | | | The name field of 'struct node' was really always supposed to be a malloc()ed string, that is owned by the structure. To avoid an extra strdup() for strings coming up from the lexer, name_node() expects to take uch an already malloc()ed string, which means it's not correct to pass it a static string literal. That's a pretty non-obvious constraint, so a bunch of incorrect uses have crept in. Really, avoiding the extra dup from the lexer isn't a big enough benefit for this demonstrably dangerous interface. So change it to do the xstrdup() itself, removing the burden from callers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Delay xstrdup() of node and property names coming from a flat treeDavid Gibson2023-03-011-12/+9
| | | | | | | | | | | | | | | | | | | The 'name' field of 'struct node' is supposed to be an (individually) malloc()ed string. So, when taking a name from a flattened blob we need to strdup() it. Currently that happens in flat_read_string() as we take it from the flattened structure itself. That obscures what's going on because it's several steps removed from actually inserting it into node->name. It also means we need an additional strdup() and free() for the case of old dtb formats where we need to extract just the final path component from the blob for the name. While we're scanning the blob, we're doing so read-only, so it's fine to have pointers into it. Therefore simplify things a bit by delaying the xstrdup() to the point where we're actually inserting into node->name. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Make build_property() xstrdup its name argumentDavid Gibson2023-03-014-7/+10
| | | | | | | | | | | | | | | The name field of 'struct property' was really always supposed to be a malloc()ed string, that is owned by the structure. To avoid an extra strdup() for strings coming up from the lexer, build_property() and build_property_delete() expect to take such an already malloc()ed string, which means it's not correct to pass it a static string literal. That's a pretty non-obvious constraint, so a bunch of incorrect uses have crept in. Really, avoiding the extra dup from the lexer isn't a big enough benefit for this demonstrably dangerous interface. So change it to do the xstrdup() itself, removing the burden from callers. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks: correct I2C 10-bit address checkMatt Ranostay2023-03-011-3/+4
| | | | | | | | | | | | | Currently if there is a valid 10-bit address the following warning is always displayed due to the 7-bit check failing due to reg > 0x7f "I2C address must be less than 7-bits, got "0x800000a6". Set I2C_TEN_BIT_ADDRESS for 10 bit addresses or fix the property" Fix this issue by checking if a 10-bit address is expected, and is valid in separate if statements. Fixes: 8259d59f ("checks: Improve i2c reg property checking") Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* yamltree.c: fix -Werror=discarded-qualifiers & -Werror=cast-qualMarc-André Lureau2023-03-011-13/+13
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks: make check.data constMarc-André Lureau2023-03-011-5/+5
| | | | | | | | Fixes: ../checks.c:47:25: error: initialization discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks.c: fix check_msg() leakMarc-André Lureau2023-03-011-0/+1
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* checks.c: fix heap-buffer-overflowMarc-André Lureau2023-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | ./dtc -I dts -O dtb -o aliases.dtb /home/elmarco/src/dtc/tests/aliases.dts ================================================================= ==882911==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000113 at pc 0x7f34ba0abf50 bp 0x7ffc8db22450 sp 0x7ffc8db21c00 READ of size 4 at 0x602000000113 thread T0 #0 0x7f34ba0abf4f in MemcmpInterceptorCommon(void*, int (*)(void const*, void const*, unsigned long), void const*, void const*, unsigned long) (/lib64/libasan.so.8+0xabf4f) #1 0x7f34ba0ac5e8 in memcmp (/lib64/libasan.so.8+0xac5e8) #2 0x4282dc in check_spi_bus_bridge ../checks.c:1110 #3 0x41b08d in check_nodes_props ../checks.c:140 #4 0x41b9c4 in run_check ../checks.c:180 #5 0x430a3b in process_checks ../checks.c:2056 #6 0x436a90 in main ../dtc.c:327 #7 0x7f34b964a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f) #8 0x7f34b964a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8) #9 0x4025c4 in _start (/home/elmarco/src/dtc/build/dtc+0x4025c4) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* tests: fix -Wwrite-stringsMarc-André Lureau2023-03-012-3/+3
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* srcpos.c: fix -Wwrite-stringsMarc-André Lureau2023-03-011-6/+6
| | | | | Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* meson: Fix cell overflow tests when running from mesonDavid Gibson2023-02-281-2/+2
| | | | | | | | Because meson always builds out-of-tree we need to reference things in the original source tree via $SRCDIR from run_tests.sh. We forgot a couple of cases for the cell overflow tests. Fix them. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* meson.build: bump version to 1.7.0Nikolay Letov2023-02-281-1/+1
| | | | | | [This was botched in the actual 1.7.0 release :( - David Gibson] Signed-off-by: Nikolay Letov <letov.nikolay@gmail.com>
* Add -Wsuggest-attribute=format warning, correct warnings thus generatedDavid Gibson2023-02-273-3/+5
| | | | | | | | Add this new warning to the default build flags. It suggests adding a ((format)) attribute to xavsprintf_append(), so do that. Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Use #ifdef NO_VALGRINDMarc-André Lureau2023-02-271-1/+1
| | | | | | Using simply #if will fail when NO_VALGRIND is undefined. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Do not redefine _GNU_SOURCE if already setMarc-André Lureau2023-02-272-0/+4
| | | | | | Or else, compilation will fail. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
* Bump version to v1.7.0v1.7.0David Gibson2023-02-091-2/+2
| | | | | | | It's been rather too long since the last release, and quite a lot of changes have accumulated. Finally get around to rolling a release. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Merge remote-tracking branch 'gitlab/main'David Gibson2023-02-051-2/+2
|\
| * checks: Update #{size,address}-cells check for 'dma-ranges'Qun-Wei Lin2023-02-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The "dma-ranges" property value is a sequence of child-address parent-address child-size The size of each field is determined by taking the child's "#address-cells" value, the parent's "#address-cells" value, and the child's "#size-cells" value. However, in the following example, it gives a false alarm: +-----------------------------------+---------------------------------------+ | ranges.dts | dma-ranges.dts | +-----------------------------------+---------------------------------------+ | /dts-v1/; | /dts-v1/; | | | | | /{ | /{ | | #address-cells = <1>; | #address-cells = <1>; | | | | | parent { | parent { | | #address-cells = <1>; | #address-cells = <1>; | | #size-cells = <1>; | #size-cells = <1>; | | ranges = <0x0 0xe000 0x1000>; | dma-ranges = <0x0 0xe000 0x1000>; | | child { | child { | | ... | ... | | }; | }; | | }; | }; | | }; | }; | +-----------------------------------+---------------------------------------+ | no warning | Warning (avoid_unnecessary_addr_size) | +-----------------------------------+---------------------------------------+ Same as "ranges", it should not be reported in this check. Signed-off-by: Qun-Wei Lin <qun-wei.lin@mediatek.com> Message-Id: <20230112125654.13390-1-qun-wei.lin@mediatek.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* | pylibfdt: add size_hint parameter for get_pathLuca Weiss2023-02-052-4/+5
|/ | | | | | | | | This also enables us to test the -NOSPACE condition by adding a test setting size_hint=1 so this path is taken. Message-Id: <20230201181112.1644842-1-luca@z3ntu.xyz> Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* pylibfdt: Work-around SWIG limitations with flexible arraysRob Herring2023-02-021-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit a41509bea3e7 ("libfdt: Replace deprecated 0-length arrays with proper flexible arrays") fails to build pylibfdt: ./pylibfdt/libfdt_wrap.c: In function ‘_wrap_fdt_node_header_name_set’: ./pylibfdt/libfdt_wrap.c:4350:18: error: cast specifies array type 4350 | arg1->name = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); | ^ ./pylibfdt/libfdt_wrap.c:4350:16: error: invalid use of flexible array member 4350 | arg1->name = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); | ^ ./pylibfdt/libfdt_wrap.c:4352:16: error: invalid use of flexible array member 4352 | arg1->name = 0; | ^ ./pylibfdt/libfdt_wrap.c: In function ‘_wrap_fdt_property_data_set’: ./pylibfdt/libfdt_wrap.c:4613:18: error: cast specifies array type 4613 | arg1->data = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); | ^ ./pylibfdt/libfdt_wrap.c:4613:16: error: invalid use of flexible array member 4613 | arg1->data = (char [])(char *)memcpy(malloc((size)*sizeof(char)), (const char *)(arg2), sizeof(char)*(size)); | ^ ./pylibfdt/libfdt_wrap.c:4615:16: error: invalid use of flexible array member 4615 | arg1->data = 0; | ^ Turns out this is known issue with SWIG: https://github.com/swig/swig/issues/1699 Implement the work-around to ignore the flexible array member. Fixes: a41509bea3e7 ("libfdt: Replace deprecated 0-length arrays with proper flexible arrays") Cc: Kees Cook <keescook@chromium.org> Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Rob Herring <robh@kernel.org> Message-Id: <20230201224441.305757-1-robh@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: Replace deprecated 0-length arrays with proper flexible arraysKees Cook2023-01-291-2/+2
| | | | | | | | | | | | | | | Replace the 0-length arrays in structures with proper flexible arrays. This will avoid warnings when building under GCC 13 with -fstrict-flex-arrays, which the Linux kernel will be doing soon: In file included from ../lib/fdt_ro.c:2: ../lib/../scripts/dtc/libfdt/fdt_ro.c: In function 'fdt_get_name': ../lib/../scripts/dtc/libfdt/fdt_ro.c:319:24: warning: 'strrchr' reading 1 or more bytes from a region of size 0 [-Wstringop-overread] 319 | leaf = strrchr(nameptr, '/'); | ^~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* dtc: Warning rather than error on possible truncation of cell valuesDavid Gibson2022-11-214-3/+27
| | | | | | | | | | | | | | | | | | | We always evaluate integer values in cell arrays as 64-bit quantities, then truncate to the size of the array cells (32-bit by default). However to detect accidental truncation of meaningful values, we give an error if the truncated portion isn't either all 0 or all 1 bits. However, this can still give counterintuitive errors. For if the user is thinking in 2's complement 32-bit arithmetic (which would be quite natural), then they'd expect the expression (-0xffffffff-2) to evaluate to -1 (0xffffffff). However in 64-bit it evaluates to 0xfffffffeffffffff which does truncate to the expected value but trips this error message. Because of this reduce the error to only a warnings, with a somewhat more helpful message. Fixes: https://github.com/dgibson/dtc/issues/74 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: tests: add get_next_tag_invalid_prop_lenTadeusz Struk2022-10-125-1/+104
| | | | | | | | | | | Add a new test get_next_tag_invalid_prop_len, which covers fdt_next_tag(), when it is passed an corrupted blob, with invalid property len values. The test runs twice, on a blob in sw and finished state. Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org> Message-Id: <20221011182611.116011-2-tadeusz.struk@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: prevent integer overflow in fdt_next_tagTadeusz Struk2022-10-121-5/+12
| | | | | | | | | | | | Since fdt_next_tag() in a public API function all input parameters, including the fdt blob should not be trusted. It is possible to forge a blob with invalid property length that will cause integer overflow during offset calculation. To prevent that, validate the property length read from the blob before doing calculations. Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org> Message-Id: <20221005232931.3016047-1-tadeusz.struk@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libfdt: add fdt_get_property_by_offset_w helperTadeusz Struk2022-10-121-0/+7
| | | | | | | | | | Add a new fdt_get_property_by_offset_w helper function. It is a wrapper on fdt_get_property_by_offset that returns a writable pointer to a property at a given offset. Signed-off-by: Tadeusz Struk <tadeusz.struk@linaro.org> Message-Id: <20221011182611.116011-1-tadeusz.struk@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Makefile: fix infinite recursion by dropping non-existent `%.output`Sergei Trofimovich2022-09-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Without the change GNU `make-4.4` falls into infinite recursion of trying to generate %.output files (bison is not passed flags to generate debug output). This happens on GNU `make-4.4` only after GNU make change to more eagerly rebuild all target outputs in multiple targets: https://savannah.gnu.org/bugs/index.php?63098 The recursion here is the following: - Makefile depends on *.d files - *.d files depend on *.c files - *.c files are generated by bison - bison is triggered whenever some of it's multiple targets are missing In our case `%.output` is always missing and bison is always reran. *.d files are always regenerated on `make` run. And make is always restarted as *.d files are always regenerated. The fix removes infeasible `%.output`. Signed-off-by: Sergei Trofimovich <slyich@gmail.com> Message-Id: <20220925104203.648449-2-slyich@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Makefile: limit make re-execution to avoid infinite spinSergei Trofimovich2022-09-261-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | make-4.4 became intentionally more eager at rebuilding outdated Makefile includes. Currently this causes `dtc` to spin infinitely in parser/dependency loop: $ make ... CHK version_gen.h BISON dtc-parser.tab.h DEP dtc-lexer.lex.c DEP dtc-parser.tab.c CHK version_gen.h BISON dtc-parser.tab.h DEP dtc-lexer.lex.c DEP dtc-parser.tab.c ... # never stops After the change build eventually fails when gets into this state: $ make ... CHK version_gen.h UPD version_gen.h DEP util.c BISON dtc-parser.tab.h DEP dtc-lexer.lex.c DEP dtc-parser.tab.c CHK version_gen.h BISON dtc-parser.tab.h DEP dtc-lexer.lex.c DEP dtc-parser.tab.c Makefile:394: *** "Make re-executed itself 10 times. Infinite recursion?". Stop. The actual recursion will be fixed separately. Signed-off-by: Sergei Trofimovich <slyich@gmail.com> Message-Id: <20220925104203.648449-1-slyich@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* libdtc: remove duplicate judgmentsJia Xianhua2022-09-161-3/+0
| | | | | | | | There is no need to check the VALID_DTB repeatedly, and can be combined into one if statement. Signed-off-by: Jia Xianhua <jiaxianhua@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
* Don't generate erroneous fixups from reference to pathDavid Gibson2022-07-313-0/+13
| | | | | | | | | | | The dtb overlay format only permits (non local) fixups to reference labels, not paths. That's because the fixup target goes into the property name in the overlay, and property names aren't permitted to include '/' characters. Stop erroneously generating such fixups, because we didn't check for this case. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>