On Tue, Nov 09, 2021 at 01:01:30AM +0100, Hans-Gert Dahmen wrote:Because it is very hard to access the SPI flash to read the BIOS contents for (security) analysis and this works without the more complex and unfinished SPI drivers and it does so on a system where we may not access the full /dev/mem.
Make the 16MiB long memory-mapped BIOS region of the platform SPI flash
on X86_64 system available via /sys/kernel/firmware/flash_mmap/bios_region
for pen-testing, security analysis and malware detection on kernels
which restrict module loading and/or access to /dev/mem.
That feels like a big security hole we would be opening up for no good
reason.
It will be used by the open source Converged Security Suite.
https://github.com/9elements/converged-security-suite
What is the reason for this, and what use is this new interface?
> Please set the attribute to the platform driver before you create the+static int __init flash_mmap_init(void)
+{
+ int ret;
+
+ pdev = platform_device_register_simple("flash_mmap", -1, NULL, 0);
+ if (IS_ERR(pdev))
+ return PTR_ERR(pdev);
+
+ ret = sysfs_create_group(&pdev->dev.kobj, &flash_mmap_group);
You just raced with userspace and lost >
Also, you just bound this driver to ANY platform that it was loaded on,
with no actual detection of the hardware present, which feels like it
could cause big problems on all platforms. Please, if you really want
to do this, restrict it to hardware that actually has the hardware you
are wanting to access, not all machines in the world.