mmap.c (e6bfb70959a0ca6ddedb29e779a293c6f71ed0e7) | mmap.c (62b5f7d013fc455b8db26cf01e421f4c0d264b92) |
---|---|
1/* 2 * mm/mmap.c 3 * 4 * Written by obz. 5 * 6 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 7 */ 8 --- 29 unchanged lines hidden (view full) --- 38#include <linux/uprobes.h> 39#include <linux/rbtree_augmented.h> 40#include <linux/sched/sysctl.h> 41#include <linux/notifier.h> 42#include <linux/memory.h> 43#include <linux/printk.h> 44#include <linux/userfaultfd_k.h> 45#include <linux/moduleparam.h> | 1/* 2 * mm/mmap.c 3 * 4 * Written by obz. 5 * 6 * Address space accounting code <alan@lxorguk.ukuu.org.uk> 7 */ 8 --- 29 unchanged lines hidden (view full) --- 38#include <linux/uprobes.h> 39#include <linux/rbtree_augmented.h> 40#include <linux/sched/sysctl.h> 41#include <linux/notifier.h> 42#include <linux/memory.h> 43#include <linux/printk.h> 44#include <linux/userfaultfd_k.h> 45#include <linux/moduleparam.h> |
46#include <linux/pkeys.h> |
|
46 47#include <asm/uaccess.h> 48#include <asm/cacheflush.h> 49#include <asm/tlb.h> 50#include <asm/mmu_context.h> 51 52#include "internal.h" 53 --- 1211 unchanged lines hidden (view full) --- 1265 * The caller must hold down_write(¤t->mm->mmap_sem). 1266 */ 1267unsigned long do_mmap(struct file *file, unsigned long addr, 1268 unsigned long len, unsigned long prot, 1269 unsigned long flags, vm_flags_t vm_flags, 1270 unsigned long pgoff, unsigned long *populate) 1271{ 1272 struct mm_struct *mm = current->mm; | 47 48#include <asm/uaccess.h> 49#include <asm/cacheflush.h> 50#include <asm/tlb.h> 51#include <asm/mmu_context.h> 52 53#include "internal.h" 54 --- 1211 unchanged lines hidden (view full) --- 1266 * The caller must hold down_write(¤t->mm->mmap_sem). 1267 */ 1268unsigned long do_mmap(struct file *file, unsigned long addr, 1269 unsigned long len, unsigned long prot, 1270 unsigned long flags, vm_flags_t vm_flags, 1271 unsigned long pgoff, unsigned long *populate) 1272{ 1273 struct mm_struct *mm = current->mm; |
1274 int pkey = 0; |
|
1273 1274 *populate = 0; 1275 1276 if (!len) 1277 return -EINVAL; 1278 1279 /* 1280 * Does the application expect PROT_READ to imply PROT_EXEC? --- 23 unchanged lines hidden (view full) --- 1304 1305 /* Obtain the address to map to. we verify (or select) it and ensure 1306 * that it represents a valid section of the address space. 1307 */ 1308 addr = get_unmapped_area(file, addr, len, pgoff, flags); 1309 if (offset_in_page(addr)) 1310 return addr; 1311 | 1275 1276 *populate = 0; 1277 1278 if (!len) 1279 return -EINVAL; 1280 1281 /* 1282 * Does the application expect PROT_READ to imply PROT_EXEC? --- 23 unchanged lines hidden (view full) --- 1306 1307 /* Obtain the address to map to. we verify (or select) it and ensure 1308 * that it represents a valid section of the address space. 1309 */ 1310 addr = get_unmapped_area(file, addr, len, pgoff, flags); 1311 if (offset_in_page(addr)) 1312 return addr; 1313 |
1314 if (prot == PROT_EXEC) { 1315 pkey = execute_only_pkey(mm); 1316 if (pkey < 0) 1317 pkey = 0; 1318 } 1319 |
|
1312 /* Do simple checking here so the lower-level routines won't have 1313 * to. we assume access permissions have been handled by the open 1314 * of the memory object, so we don't do any here. 1315 */ | 1320 /* Do simple checking here so the lower-level routines won't have 1321 * to. we assume access permissions have been handled by the open 1322 * of the memory object, so we don't do any here. 1323 */ |
1316 vm_flags |= calc_vm_prot_bits(prot, 0) | calc_vm_flag_bits(flags) | | 1324 vm_flags |= calc_vm_prot_bits(prot, pkey) | calc_vm_flag_bits(flags) | |
1317 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; 1318 1319 if (flags & MAP_LOCKED) 1320 if (!can_do_mlock()) 1321 return -EPERM; 1322 1323 if (mlock_future_check(mm, vm_flags, len)) 1324 return -EAGAIN; --- 2113 unchanged lines hidden --- | 1325 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC; 1326 1327 if (flags & MAP_LOCKED) 1328 if (!can_do_mlock()) 1329 return -EPERM; 1330 1331 if (mlock_future_check(mm, vm_flags, len)) 1332 return -EAGAIN; --- 2113 unchanged lines hidden --- |