diff options
| author | Cédric Le Goater <clg@kaod.org> | 2018-10-12 10:07:23 +0200 |
|---|---|---|
| committer | Joel Stanley <joel@jms.id.au> | 2019-03-20 15:13:33 +1030 |
| commit | 4929e6cd69a3fa17781a19547526e124f12ef818 (patch) | |
| tree | dd690ab9f4eded5274ad08f6f00d2d8952e54826 | |
| parent | 4e58371dea4a6ea7db80ff0447760d5f723e2798 (diff) | |
| download | talos-obmc-linux-4929e6cd69a3fa17781a19547526e124f12ef818.tar.gz talos-obmc-linux-4929e6cd69a3fa17781a19547526e124f12ef818.zip | |
/dev/mem: add a devmem kernel parameter to activate the device
For security reasons, some configuration needs to run without /dev/mem
but on some occasions, to debug HW for instance, it's still useful to
be able to reboot the system with access to physical memory.
Add a kernel parameter which activates the /dev/mem device only when
'mem.devmem' is enabled.
OpenBMC-Staging-Count: 3
Signed-off-by: Cédric Le Goater <clg@kaod.org>
Signed-off-by: Joel Stanley <joel@jms.id.au>
| -rw-r--r-- | Documentation/admin-guide/kernel-parameters.txt | 3 | ||||
| -rw-r--r-- | drivers/char/Kconfig | 9 | ||||
| -rw-r--r-- | drivers/char/mem.c | 12 |
3 files changed, 24 insertions, 0 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt index 858b6c0b9a15..b82566d85360 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -2475,6 +2475,9 @@ deep - Suspend-To-RAM or equivalent (if supported) See Documentation/admin-guide/pm/sleep-states.rst. + mem.devmem= Activate the /dev/mem device + Format: <bool> (1/Y/y=enable, 0/N/n=disable) + meye.*= [HW] Set MotionEye Camera parameters See Documentation/media/v4l-drivers/meye.rst. diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 2e2ffe7010aa..05d4d67b3134 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig @@ -16,6 +16,15 @@ config DEVMEM memory. When in doubt, say "Y". +config DEVMEM_BOOTPARAM + bool "mem.devmem boot parameter" + depends on DEVMEM + default n + help + This option adds a 'mem.devmem' kernel parameter which activates + the /dev/mem device when enabled. + When in doubt, say "N". + config DEVKMEM bool "/dev/kmem virtual device support" # On arm64, VMALLOC_START < PAGE_OFFSET, which confuses kmem read/write diff --git a/drivers/char/mem.c b/drivers/char/mem.c index b08dc50f9f26..591366baa53e 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -10,6 +10,7 @@ */ #include <linux/mm.h> +#include <linux/moduleparam.h> #include <linux/miscdevice.h> #include <linux/slab.h> #include <linux/vmalloc.h> @@ -36,6 +37,7 @@ # include <linux/efi.h> #endif +#define DEVMEM_MINOR 1 #define DEVPORT_MINOR 4 static inline unsigned long size_inside_page(unsigned long start, @@ -913,6 +915,12 @@ static char *mem_devnode(struct device *dev, umode_t *mode) return NULL; } +#ifdef CONFIG_DEVMEM_BOOTPARAM +static bool devmem; +module_param(devmem, bool, 0444); +MODULE_PARM_DESC(devmem, "kernel parameter to activate /dev/mem"); +#endif + static struct class *mem_class; static int __init chr_dev_init(void) @@ -931,6 +939,10 @@ static int __init chr_dev_init(void) if (!devlist[minor].name) continue; +#ifdef CONFIG_DEVMEM_BOOTPARAM + if (minor == DEVMEM_MINOR && !devmem) + continue; +#endif /* * Create /dev/port? */ |

