CHROMIUM: ramoops: remove module parameters
authorKees Cook <keescook@chromium.org>
Mon, 9 Apr 2012 19:46:29 +0000 (19:46 +0000)
committerOlof Johansson <olof@lixom.net>
Fri, 1 Jun 2012 06:53:58 +0000 (23:53 -0700)
The ramoops driver is intended to be used with platforms that define
persistent memory regions. If memory regions were configurable with
module parameters, it would be possible to read some RAM regions via
the new /proc interface without access to /dev/mem (which would
result in a loss of kernel memory privacy when a system is built with
STRICT_DEVMEM), so remove this ability completely.

BUG=chromium-os:12059
TEST=x86-alex build and boot, manually verified /dev/pstore/dmesg-ramoops-N
    showing breakme crash reports.

Change-Id: I5177af5b0a237b01633a9a202172504c8564c914
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/11618

drivers/char/ramoops.c

index 9efec0e..14feb04 100644 (file)
 #define RAMOOPS_KERNMSG_HDR "===="
 #define MIN_MEM_SIZE 4096UL
 
-static ulong record_size = MIN_MEM_SIZE;
-module_param(record_size, ulong, 0400);
-MODULE_PARM_DESC(record_size,
-               "size of each dump done on oops/panic");
-
-static ulong mem_address;
-module_param(mem_address, ulong, 0400);
-MODULE_PARM_DESC(mem_address,
-               "start of reserved RAM used to store oops/panic logs");
-
-static ulong mem_size;
-module_param(mem_size, ulong, 0400);
-MODULE_PARM_DESC(mem_size,
-               "size of reserved RAM used to store oops/panic logs");
-
 static int ramoops_pstore_open(struct pstore_info *psi);
 static int ramoops_pstore_close(struct pstore_info *psi);
 static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
@@ -75,9 +60,6 @@ struct ramoops_context {
        struct pstore_info pstore;
 };
 
-static struct platform_device *dummy;
-static struct ramoops_platform_data *dummy_data;
-
 static struct ramoops_context oops_cxt = {
        .pstore = {
                .owner  = THIS_MODULE,
@@ -235,7 +217,6 @@ static int __init ramoops_probe(struct platform_device *pdev)
        cxt->size = pdata->mem_size;
        cxt->phys_addr = pdata->mem_address;
        cxt->record_size = pdata->record_size;
-       cxt->dump_oops = pdata->dump_oops;
 
        cxt->pstore.bufsize = cxt->record_size;
        cxt->pstore.buf = kmalloc(cxt->pstore.bufsize, GFP_KERNEL);
@@ -263,15 +244,6 @@ static int __init ramoops_probe(struct platform_device *pdev)
                goto fail1;
        }
 
-       /*
-        * Update the module parameter variables as well so they are visible
-        * through /sys/module/ramoops/parameters/
-        */
-       mem_size = pdata->mem_size;
-       mem_address = pdata->mem_address;
-       record_size = pdata->record_size;
-       dump_oops = pdata->dump_oops;
-
        return 0;
 
 fail1:
@@ -317,38 +289,12 @@ static struct platform_driver ramoops_driver = {
 
 static int __init ramoops_init(void)
 {
-       int ret;
-       ret = platform_driver_probe(&ramoops_driver, ramoops_probe);
-       if (ret == -ENODEV) {
-               /*
-                * If we didn't find a platform device, we use module parameters
-                * building platform data on the fly.
-                */
-               pr_info("platform device not found, using module parameters\n");
-               dummy_data = kzalloc(sizeof(struct ramoops_platform_data),
-                                    GFP_KERNEL);
-               if (!dummy_data)
-                       return -ENOMEM;
-               dummy_data->mem_size = mem_size;
-               dummy_data->mem_address = mem_address;
-               dummy_data->record_size = record_size;
-               dummy = platform_create_bundle(&ramoops_driver, ramoops_probe,
-                       NULL, 0, dummy_data,
-                       sizeof(struct ramoops_platform_data));
-
-               if (IS_ERR(dummy))
-                       ret = PTR_ERR(dummy);
-               else
-                       ret = 0;
-       }
-
-       return ret;
+       return platform_driver_probe(&ramoops_driver, ramoops_probe);
 }
 
 static void __exit ramoops_exit(void)
 {
        platform_driver_unregister(&ramoops_driver);
-       kfree(dummy_data);
 }
 
 module_init(ramoops_init);