| 1 | --- a/mm/shmem.c |
| 2 | +++ b/mm/shmem.c |
| 3 | @@ -30,6 +30,7 @@ |
| 4 | #include <linux/module.h> |
| 5 | #include <linux/percpu_counter.h> |
| 6 | #include <linux/swap.h> |
| 7 | +#include <linux/ima.h> |
| 8 | |
| 9 | static struct vfsmount *shm_mnt; |
| 10 | |
| 11 | @@ -2703,6 +2704,16 @@ out: |
| 12 | |
| 13 | /* common code */ |
| 14 | |
| 15 | +void shmem_set_file(struct vm_area_struct *vma, struct file *file) |
| 16 | +{ |
| 17 | + ima_counts_get(file); |
| 18 | + if (vma->vm_file) |
| 19 | + fput(vma->vm_file); |
| 20 | + vma->vm_file = file; |
| 21 | + vma->vm_ops = &shmem_vm_ops; |
| 22 | +} |
| 23 | +EXPORT_SYMBOL_GPL(shmem_set_file); |
| 24 | + |
| 25 | /** |
| 26 | * shmem_file_setup - get an unlinked file living in tmpfs |
| 27 | * @name: name for dentry (to be seen in /proc/<pid>/maps |
| 28 | @@ -2780,10 +2791,7 @@ int shmem_zero_setup(struct vm_area_stru |
| 29 | if (IS_ERR(file)) |
| 30 | return PTR_ERR(file); |
| 31 | |
| 32 | - if (vma->vm_file) |
| 33 | - fput(vma->vm_file); |
| 34 | - vma->vm_file = file; |
| 35 | - vma->vm_ops = &shmem_vm_ops; |
| 36 | + shmem_set_file(vma, file); |
| 37 | vma->vm_flags |= VM_CAN_NONLINEAR; |
| 38 | return 0; |
| 39 | } |
| 40 | --- a/fs/file.c |
| 41 | +++ b/fs/file.c |
| 42 | @@ -264,6 +264,7 @@ int expand_files(struct files_struct *fi |
| 43 | /* All good, so we try */ |
| 44 | return expand_fdtable(files, nr); |
| 45 | } |
| 46 | +EXPORT_SYMBOL_GPL(expand_files); |
| 47 | |
| 48 | static int count_open_files(struct fdtable *fdt) |
| 49 | { |
| 50 | --- a/kernel/exit.c |
| 51 | +++ b/kernel/exit.c |
| 52 | @@ -513,6 +513,7 @@ struct files_struct *get_files_struct(st |
| 53 | |
| 54 | return files; |
| 55 | } |
| 56 | +EXPORT_SYMBOL_GPL(get_files_struct); |
| 57 | |
| 58 | void put_files_struct(struct files_struct *files) |
| 59 | { |
| 60 | @@ -534,6 +535,7 @@ void put_files_struct(struct files_struc |
| 61 | rcu_read_unlock(); |
| 62 | } |
| 63 | } |
| 64 | +EXPORT_SYMBOL_GPL(put_files_struct); |
| 65 | |
| 66 | void reset_files_struct(struct files_struct *files) |
| 67 | { |
| 68 | --- a/kernel/fork.c |
| 69 | +++ b/kernel/fork.c |
| 70 | @@ -191,6 +191,7 @@ void __put_task_struct(struct task_struc |
| 71 | if (!profile_handoff_task(tsk)) |
| 72 | free_task(tsk); |
| 73 | } |
| 74 | +EXPORT_SYMBOL_GPL(__put_task_struct); |
| 75 | |
| 76 | /* |
| 77 | * macro override instead of weak attribute alias, to workaround |
| 78 | --- a/kernel/sched.c |
| 79 | +++ b/kernel/sched.c |
| 80 | @@ -4776,6 +4776,7 @@ int can_nice(const struct task_struct *p |
| 81 | return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) || |
| 82 | capable(CAP_SYS_NICE)); |
| 83 | } |
| 84 | +EXPORT_SYMBOL_GPL(can_nice); |
| 85 | |
| 86 | #ifdef __ARCH_WANT_SYS_NICE |
| 87 | |
| 88 | --- a/mm/memory.c |
| 89 | +++ b/mm/memory.c |
| 90 | @@ -1201,6 +1201,7 @@ unsigned long zap_page_range(struct vm_a |
| 91 | tlb_finish_mmu(tlb, address, end); |
| 92 | return end; |
| 93 | } |
| 94 | +EXPORT_SYMBOL_GPL(zap_page_range); |
| 95 | |
| 96 | /** |
| 97 | * zap_vma_ptes - remove ptes mapping the vma |
| 98 | @@ -2616,6 +2617,7 @@ int vmtruncate_range(struct inode *inode |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | +EXPORT_SYMBOL_GPL(vmtruncate_range); |
| 103 | |
| 104 | /* |
| 105 | * We enter with non-exclusive mmap_sem (to exclude vma changes, |
| 106 | --- a/mm/vmalloc.c |
| 107 | +++ b/mm/vmalloc.c |
| 108 | @@ -1192,6 +1192,7 @@ void unmap_kernel_range(unsigned long ad |
| 109 | vunmap_page_range(addr, end); |
| 110 | flush_tlb_kernel_range(addr, end); |
| 111 | } |
| 112 | +EXPORT_SYMBOL_GPL(unmap_kernel_range); |
| 113 | |
| 114 | int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page ***pages) |
| 115 | { |
| 116 | @@ -1307,6 +1308,7 @@ struct vm_struct *get_vm_area(unsigned l |
| 117 | return __get_vm_area_node(size, 1, flags, VMALLOC_START, VMALLOC_END, |
| 118 | -1, GFP_KERNEL, __builtin_return_address(0)); |
| 119 | } |
| 120 | +EXPORT_SYMBOL_GPL(get_vm_area); |
| 121 | |
| 122 | struct vm_struct *get_vm_area_caller(unsigned long size, unsigned long flags, |
| 123 | void *caller) |
| 124 | --- a/include/linux/mm.h |
| 125 | +++ b/include/linux/mm.h |
| 126 | @@ -746,6 +746,7 @@ extern void show_free_areas(void); |
| 127 | |
| 128 | int shmem_lock(struct file *file, int lock, struct user_struct *user); |
| 129 | struct file *shmem_file_setup(const char *name, loff_t size, unsigned long flags); |
| 130 | +void shmem_set_file(struct vm_area_struct *vma, struct file *file); |
| 131 | int shmem_zero_setup(struct vm_area_struct *); |
| 132 | |
| 133 | #ifndef CONFIG_MMU |
| 134 | |