aboutsummaryrefslogtreecommitdiff
path: root/common/image-fit.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-02-15 17:08:06 -0700
committerTom Rini <trini@konsulko.com>2021-02-15 19:17:25 -0500
commit79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4 (patch)
treefbaa2047d6a09d349e0ad78faaf75d6ffc3aff00 /common/image-fit.c
parent8a7d4cf9820ea16fabd25a6379351b4dc291204b (diff)
downloadu-boot-79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4.zip
u-boot-79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4.tar.gz
u-boot-79af75f7776fc20b0d7eb6afe1e27c00fdb4b9b4.tar.bz2
fit: Don't allow verification of images with @ nodes
When searching for a node called 'fred', any unit address appended to the name is ignored by libfdt, meaning that 'fred' can match 'fred@1'. This means that we cannot be sure that the node originally intended is the one that is used. Disallow use of nodes with unit addresses. Update the forge test also, since it uses @ addresses. CVE-2021-27138 Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Bruce Monroe <bruce.monroe@intel.com> Reported-by: Arie Haenel <arie.haenel@intel.com> Reported-by: Julien Lenoir <julien.lenoir@intel.com>
Diffstat (limited to 'common/image-fit.c')
-rw-r--r--common/image-fit.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/common/image-fit.c b/common/image-fit.c
index adc3e55..c3dc814 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -1369,21 +1369,31 @@ error:
*/
int fit_image_verify(const void *fit, int image_noffset)
{
+ const char *name = fit_get_name(fit, image_noffset, NULL);
const void *data;
size_t size;
- int noffset = 0;
char *err_msg = "";
+ if (strchr(name, '@')) {
+ /*
+ * We don't support this since libfdt considers names with the
+ * name root but different @ suffix to be equal
+ */
+ err_msg = "Node name contains @";
+ goto err;
+ }
/* Get image data and data length */
if (fit_image_get_data_and_size(fit, image_noffset, &data, &size)) {
err_msg = "Can't get image data/size";
- printf("error!\n%s for '%s' hash node in '%s' image node\n",
- err_msg, fit_get_name(fit, noffset, NULL),
- fit_get_name(fit, image_noffset, NULL));
- return 0;
+ goto err;
}
return fit_image_verify_with_data(fit, image_noffset, data, size);
+
+err:
+ printf("error!\n%s in '%s' image node\n", err_msg,
+ fit_get_name(fit, image_noffset, NULL));
+ return 0;
}
/**