Android 14.0.0 release 29
# -----BEGIN PGP SIGNATURE-----
#
# iF0EABECAB0WIQRDQNE1cO+UXoOBCWTorT+BmrEOeAUCZeZWyQAKCRDorT+BmrEO
# eCurAKCMOLzC9jKbJRZe0b/ZNoNv9wlE3ACeO6DTK0llqb4qNN+/W1JFTPbTBro=
# =/Jha
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue Mar 5 01:18:33 2024 EET
# gpg: using DSA key 4340D13570EF945E83810964E8AD3F819AB10E78
# gpg: Good signature from "The Android Open Source Project <initial-contribution@android.com>" [marginal]
# gpg: initial-contribution@android.com: Verified 2339 signatures in the past
# 2 years. Encrypted 4 messages in the past 2 years.
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 4340 D135 70EF 945E 8381 0964 E8AD 3F81 9AB1 0E78
# By Pierre-Clément Tosi (12) and others
# Via Automerger Merge Worker (50) and others
* tag 'android-14.0.0_r29':
ANDROID: Generate version_gen.h in Soong and Bazel
FROMGIT: libfdt: fdt_get_alias_namelen: Validate aliases
FROMGIT: use fdt_path_getprop_namelen() in fdt_get_alias_namelen()
FROMGIT: add fdt_path_getprop_namelen() helper
ANDROID: Revert "libfdt: Validate alias property value is a valid string."
FROMLIST: libdft: fdt_next_tag: Harden offset overflow check
FROMGIT: libfdt: prevent integer overflow in fdt_next_tag
ANDROID: Revert "Fix integer wrap sanitisation."
FROMGIT: libfdt: fdt_path_offset_namelen: Reject empty path
ANDROID: Revert "libfdt: fdt_path_offset_namelen: Reject empty paths"
ANDROID: bazel: Clean up lexer and parser rules
ANDROID: bazel: Fix dtc header dependencies
ANDROID: Use -Wall and more when building libfdt
ANDROID: Use -Wno-macro-redefined for DTC tools
ANDROID: De-dup fdt_path_offset_namelen check
build: Add BUILD.bazel file
Change-Id: Id735f73688acfa3758902473383abd9eea6e8f5a
* changes:
FROMGIT: libfdt: fdt_get_alias_namelen: Validate aliases
FROMGIT: use fdt_path_getprop_namelen() in fdt_get_alias_namelen()
FROMGIT: add fdt_path_getprop_namelen() helper
ANDROID: Revert "libfdt: Validate alias property value is a valid string."
Upstream provides a DTC_VERSION preprocessor macro to its C code by
generating a version_gen.h header from either of its supported build
systems: Make formats the header from its internal variables (VERSION,
PATCHLEVEL, SUBLEVEL, ...) while Meson uses its vcs_tag() function on
a template, version_gen.h.in.
As AOSP doesn't make use of these build systems, aosp/204511 decided to
hardcode a version_non_gen.h file and patch the corresponding #include.
This unsurprisingly ended up bitrotting as the repo was being upgraded.
Instead, replicate the version_gen.h.in patching in our build systems,
extracting the version number from the METADATA file, which
external_updater.sh will keep up-to-date. Note that this introduces a
dependency on sed in the genrule(), the impact of which is minimized by
making METADATA_version.sed POSIX-compliant.
Keep appending the suffix '-Android-build' to the upstream version.
Test: m dtc && ${ANDROID_HOST_OUT}/bin/dtc --version
Test: bazel build //:dtc && bazel-bin/dtc --version
Change-Id: I6b780c1dbe14d415891defeb652f0692988ed0b1
Ensure that the alias found matches the device tree specification v0.4:
Each property of the /aliases node defines an alias. The property
name specifies the alias name. The property value specifies the full
path to a node in the devicetree.
This protects against a stack overflow caused by
fdt_path_offset_namelen(fdt, path, namelen)
calling
fdt_path_offset(fdt, fdt_get_alias_namelen(fdt, path, namelen))
leading to infinite recursion on DTs with "circular" aliases.
This fix was originally written by Mike McTernan for Android in [1].
[1]: 9308e7f977
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Acked-by: Mike McTernan <mikemcternan@google.com>
Message-ID: <20231010092725.63h7c45p2fnmj577@google.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
(cherry-picked from commit 79b9e326a162b15ca5758ee214e350f4f7c038fe git://git.kernel.org/pub/scm/utils/dtc/dtc.git main)
Test: N/A
Change-Id: I1e5a89039f6b70c82e17739379d97dbf130036e8
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>
(cherry-picked from commit 18f5ec12a10ec84e957222074dadf4a3e4cc8d59 git://git.kernel.org/pub/scm/utils/dtc/dtc.git main)
Test: N/A
Change-Id: I43c6ad22dbaa718cd77421a44d5e87d188d26ca0
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>
(cherry-picked from commit df093279282ca0cff4d20ceb3bb5857117ed4cc4 git://git.kernel.org/pub/scm/utils/dtc/dtc.git main)
Test: N/A
Change-Id: If9a102a622dfa726b7cb10f58c38f1b52d233be6
As 'offset' is obtained through various paths within the function by
adding user-provided values to 'startoffset' and as we validate its
final value by substracting it from the initial one, there is a risk
that one of the paths might have lead to an overflow, making the check
validate a "negative" (wrong) length, potentially causing fdt_next_tag()
to report an invalid offset as valid through 'nextoffset'.
For example, when parsing an FDT_PROP, we currently validate that
offset = startoffset + len + FDT_TAGSIZE
doesn't overflow but then assign
offset = startoffset + len + sizeof(struct fdt_property)
so harden all paths by validating the offset in the very last check.
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
(am from https://lore.kernel.org/devicetree-compiler/20231011172427.g4tlsew3wsjtddil@google.com/)
Test: N/A
Change-Id: I0b17b0827ccc0ece0a2d1795b388408fb599aed7
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>
(cherry-picked from commit 73590342fc85ca207ca1e6cbc110179873a96962 git://git.kernel.org/pub/scm/utils/dtc/dtc.git main)
Test: N/A
Change-Id: I894051ed101255800717001a71a5a74ac66fd897
This reverts commit 0e783e26f7.
Revert the patch we've had in Android now that upstream has [1]
commit 73590342fc85 ("libfdt: prevent integer overflow in fdt_next_tag")
which addresses the same bug.
As that patch is less rigorous w.r.t. the final value of 'offset' than
the one, the last 'if' is upstreamed by [2], which will be cherry-picked
here.
[1]: 73590342fc
[2]: https://lore.kernel.org/devicetree-compiler/20231011172427.g4tlsew3wsjtddil@google.com/
Test: N/A
Change-Id: I662a599713b4090abd090322bca0a78e58f4c92c
Reject empty paths and negative lengths, according to the DT spec v0.4:
The convention for specifying a device path is:
/node-name-1/node-name-2/node-name-N
The path to the root node is /.
This prevents the access to path[0] from ever being out-of-bounds.
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
Message-ID: <20231010092822.qo2nxc3g47t26dqs@google.com>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Test: N/A
Change-Id: I8efee39a06fa62f1f057a975e8133a295be0a656
This reverts commit 3c28f3e3a1.
Now that this change has been upstreamed, revert the Android patch in
order to cherry-pick the upstream one.
Test: N/A
Change-Id: I5295898fa6670436533290f32a10e3f672e2696c
Simplify the build file as
- dtc_gen creates an unnecessarily broad (and confusing) dependency list
by using glob([".h"]) as its header list. Instead, dtc now lists
explicitly the few headers it actually needs;
- generating dtc-lexer.lex.c does not require dtc-parser.{c,h};
- Bison can be told to directly create dtc-parser.{c,h} so no need for
an unnecessarily broad copying of *.[ch] to move some intermediate
results.
As a result, we get two genrule() wrapping the source files respectively
generated through lex and bison, which can be listed as srcs of dtc.
Test: bazel build //:all
Change-Id: I238d963af8a338c46f39c8ba9e4314fe536948cf
As dtc compiles util.c, which includes util.h and version_non_gen.h
(or version_gen.h upstream), the cc_binary should list those
dependencies explicitly so that a change in them triggers a rebuild.
Furthermore, dtc also depends on dtc.h and srcpos.h, which are only
found as dependencies by Bazel through the overkill glob(["*.h"]) header
list of dtc_gen so list them explicitly here so that that cc_library can
be dropped.
Introduce the UTILS list to DRY the build file.
Test: bazel build //:dtc
Change-Id: I32076c65b60820dc91f6dc84c3ee3cad310c1db5
Build libfdt with the same warnings as the DTC tools. This effectively
starts using -Wno-missing-field-initializers, -Wno-unused-parameter, and
-Wall.
Test: m libfdt
Test: bazel build //:libfdt
Change-Id: I5a2ae1ee86b4613d0aa7a0174d235976d7be45cc
As we use the flag when building libfdt, also enable it for the tools.
Test: m dtc fdtget fdtoverlay
Test: bazel build //:all
Change-Id: I3c0775436bb9be1367e1937e99a6e87d1dce664c