Merge tag 'selinux-pr-20180814' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / security / selinux / hooks.c
index f78318a..ad9a9b8 100644 (file)
@@ -3860,7 +3860,7 @@ static int selinux_file_receive(struct file *file)
        return file_has_perm(cred, file, file_to_av(file));
 }
 
-static int selinux_file_open(struct file *file, const struct cred *cred)
+static int selinux_file_open(struct file *file)
 {
        struct file_security_struct *fsec;
        struct inode_security_struct *isec;
@@ -3884,7 +3884,7 @@ static int selinux_file_open(struct file *file, const struct cred *cred)
         * new inode label or new policy.
         * This check is not redundant - do not remove.
         */
-       return file_path_has_perm(cred, file, open_file_to_av(file));
+       return file_path_has_perm(file->f_cred, file, open_file_to_av(file));
 }
 
 /* task security operations */
@@ -4071,6 +4071,20 @@ static int selinux_kernel_read_file(struct file *file,
        return rc;
 }
 
+static int selinux_kernel_load_data(enum kernel_load_data_id id)
+{
+       int rc = 0;
+
+       switch (id) {
+       case LOADING_MODULE:
+               rc = selinux_kernel_module_from_file(NULL);
+       default:
+               break;
+       }
+
+       return rc;
+}
+
 static int selinux_task_setpgid(struct task_struct *p, pid_t pgid)
 {
        return avc_has_perm(&selinux_state,
@@ -6970,6 +6984,7 @@ static struct security_hook_list selinux_hooks[] __lsm_ro_after_init = {
        LSM_HOOK_INIT(kernel_act_as, selinux_kernel_act_as),
        LSM_HOOK_INIT(kernel_create_files_as, selinux_kernel_create_files_as),
        LSM_HOOK_INIT(kernel_module_request, selinux_kernel_module_request),
+       LSM_HOOK_INIT(kernel_load_data, selinux_kernel_load_data),
        LSM_HOOK_INIT(kernel_read_file, selinux_kernel_read_file),
        LSM_HOOK_INIT(task_setpgid, selinux_task_setpgid),
        LSM_HOOK_INIT(task_getpgid, selinux_task_getpgid),