[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT RFC PATCH] plat/common:Add helper to simplify accessing fdt for arm





On 11/15/18 6:09 AM, Jianyong Wu (Arm Technology China) wrote:
Hi,

Hi,


+
+       UK_ASSERT(device != -1);
+        naddr = fdt_address_cells(dtb, device);
+        UK_ASSERT(naddr < FDT_MAX_NCELLS);
+
+        *nsize = fdt_size_cells(dtb, device);
+        UK_ASSERT(*nsize < FDT_MAX_NCELLS);
+
+        *regs = fdt_getprop(dtb, device, "reg", &prop_len);
+        prop_min_len = (int)sizeof(fdt32_t) * (naddr + *nsize);
+        UK_ASSERT(*regs != NULL && prop_len >= prop_min_len);

This assert is not very useful for "regs" property describing more
than
1 regions. I think it would make sense to move the check in the
uk_dtb_read_term to check if the region requested by the caller is correct.

Ok, I will check reg in uk_dtb_read_term.

But, how to check reg in uk_dtb_read_term? I have an idea that check *(reg + 
index*(naddr+nsize) *4)
Does that make sence?

You want to make sure you are not going to read past the size of the property. So ((index + 1) * (naddr + nsize) * 4) < size should be fine.

Cheers,

--
Julien Grall

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.