RE: [PATCH 1/2 V2] ACPI/APEI: Add parameter check before error injection

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

 



+	/* ensure param1/param2 existed */
+	if (!(param_extension || acpi5))
+		goto inject;
+
+	/* ensure injection is memory related */
+	if (type & ACPI5_VENDOR_BIT) {
+		if (vendor_flags != SETWA_FLAGS_MEM)
+			goto inject;
+	} else if (!(type & MEM_ERROR_MASK))
+		goto inject;

Maybe a comment before all these three goto blocks saying why we are jumping
around.  Perhaps:

	/* We need extra sanity checks for memory errors. Other types leap directly to injection */

+
+	/*
+	 * When error injection type is memory related, param2 is the address
+	 * mask of param1. This mask is used to ensure that the final address
+	 * (param1 & param2) is meaningful. If param2 has a *weird* style
+	 * like 0xf0f0f0f0f0f0f0f0, it means the injection address can be
+	 * anywhere around param1, and that must be forbidden. In that reason,
+	 * PAGE_MASK is employed to avoid injection address discontinuous.
+	 * If one finds a special case not to satisfy this requirement, please
+	 * fix it.
+	 */
+	pfn = PFN_DOWN(param1 & param2);
+	if (!page_is_ram(pfn) || ((param2 & PAGE_MASK) != PAGE_MASK))
+		return -EINVAL;

This has too much comment (rare!) and is still too complicated. Split the tests apart?

	/*
	 * Disallow crazy address masks that give BIOS leeway to pick injection address
	 * almost anywhere. Insist on page or better granularity
	 */
	if ((param2 & PAGE_MASK) != PAGE_MASK)
		return -EINVAL;

	/* make sure target address is normal memory */
	pfn = PFN_DOWN(param1 & param2);
	if (!page_is_ram(pfn))
		return -EINVAL;

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux