lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Fri,  8 Jul 2022 18:03:59 +0100
From:   Ben Dooks <ben.dooks@...ive.com>
To:     devicetree@...r.kernel.org, frowand.list@...il.com
Cc:     linux-kernel@...r.kernel.org, robh+dt@...nel.org,
        Sudip Mukherjee <sudip.mukherjee@...ive.com>,
        Jude Onyenegecha <jude.onyenegecha@...ive.com>,
        Ben Dooks <ben.dooks@...ive.com>
Subject: [PATCH] scripts/dtc: dma-ranges is a multiple of 3 cells

The dma-ranges property is a set 3 cells of #address-size, so don't treat
it like the ranges property when generating warnings.

Signed-off-by: Ben Dooks <ben.dooks@...ive.com>
---
 scripts/dtc/checks.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 781ba1129a8e..791b93e8e02a 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -823,7 +823,36 @@ static void check_ranges_format(struct check *c, struct dt_info *dti,
 	}
 }
 WARNING(ranges_format, check_ranges_format, "ranges", &addr_size_cells);
-WARNING(dma_ranges_format, check_ranges_format, "dma-ranges", &addr_size_cells);
+
+static void check_dma_ranges_format(struct check *c, struct dt_info *dti,
+				struct node *node)
+{
+	struct property *prop;
+	int c_size_cells, p_size_cells, entrylen;
+	const char *ranges = c->data;
+
+	prop = get_property(node, ranges);
+	if (!prop)
+		return;
+
+	if (!node->parent) {
+		FAIL_PROP(c, dti, node, prop, "Root node has a \"%s\" property",
+			  ranges);
+		return;
+	}
+
+	c_size_cells = node_size_cells(node);
+	p_size_cells = node_size_cells(node->parent);
+	entrylen = (p_size_cells + 2 * c_size_cells) * sizeof(cell_t);
+
+	if (!is_multiple_of(prop->val.len, entrylen)) {
+		FAIL_PROP(c, dti, node, prop, "\"%s\" property has invalid length (%d bytes) "
+			  "(parent #address-cells == %d, "
+			  "child #address-cells == %d)", ranges, prop->val.len,
+			  p_size_cells, c_size_cells);
+	}
+}
+WARNING(dma_ranges_format, check_dma_ranges_format, "dma-ranges", &addr_size_cells);
 
 static const struct bus_type pci_bus = {
 	.name = "PCI",
-- 
2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ