param: initialize store function to NULL if not available.
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 23 Dec 2014 04:35:36 +0000 (15:05 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 23 Dec 2014 04:37:41 +0000 (15:07 +1030)
I rebased Kees' 'param: do not set store func without write perm'
on top of my 'params: cleanup sysfs allocation'.  However, my patch
uses krealloc which doesn't zero memory, leaving .store unset.

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
kernel/params.c

index 0af9b2c4e56c6cf604699096d0ac4d44c874b36e..bd65d136a470ccba8355402aab1e808a17a0a187 100644 (file)
@@ -648,6 +648,8 @@ static __modinit int add_sysfs_param(struct module_kobject *mk,
        /* Do not allow runtime DAC changes to make param writable. */
        if ((kp->perm & (S_IWUSR | S_IWGRP | S_IWOTH)) != 0)
                mk->mp->attrs[mk->mp->num].mattr.store = param_attr_store;
+       else
+               mk->mp->attrs[mk->mp->num].mattr.store = NULL;
        mk->mp->attrs[mk->mp->num].mattr.attr.name = (char *)name;
        mk->mp->attrs[mk->mp->num].mattr.attr.mode = kp->perm;
        mk->mp->num++;