mprotect.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * mm/mprotect.c
  4. *
  5. * (C) Copyright 1994 Linus Torvalds
  6. * (C) Copyright 2002 Christoph Hellwig
  7. *
  8. * Address space accounting code <alan@lxorguk.ukuu.org.uk>
  9. * (C) Copyright 2002 Red Hat Inc, All Rights Reserved
  10. */
  11. #include <linux/mm.h>
  12. #include <linux/hugetlb.h>
  13. #include <linux/shm.h>
  14. #include <linux/mman.h>
  15. #include <linux/fs.h>
  16. #include <linux/highmem.h>
  17. #include <linux/security.h>
  18. #include <linux/mempolicy.h>
  19. #include <linux/personality.h>
  20. #include <linux/syscalls.h>
  21. #include <linux/swap.h>
  22. #include <linux/swapops.h>
  23. #include <linux/mmu_notifier.h>
  24. #include <linux/migrate.h>
  25. #include <linux/perf_event.h>
  26. #include <linux/pkeys.h>
  27. #include <linux/ksm.h>
  28. #include <linux/uaccess.h>
  29. #include <asm/pgtable.h>
  30. #include <asm/cacheflush.h>
  31. #include <asm/mmu_context.h>
  32. #include <asm/tlbflush.h>
  33. #include "internal.h"
  34. static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
  35. unsigned long addr, unsigned long end, pgprot_t newprot,
  36. int dirty_accountable, int prot_numa)
  37. {
  38. struct mm_struct *mm = vma->vm_mm;
  39. pte_t *pte, oldpte;
  40. spinlock_t *ptl;
  41. unsigned long pages = 0;
  42. int target_node = NUMA_NO_NODE;
  43. /*
  44. * Can be called with only the mmap_sem for reading by
  45. * prot_numa so we must check the pmd isn't constantly
  46. * changing from under us from pmd_none to pmd_trans_huge
  47. * and/or the other way around.
  48. */
  49. if (pmd_trans_unstable(pmd))
  50. return 0;
  51. /*
  52. * The pmd points to a regular pte so the pmd can't change
  53. * from under us even if the mmap_sem is only hold for
  54. * reading.
  55. */
  56. pte = pte_offset_map_lock(vma->vm_mm, pmd, addr, &ptl);
  57. /* Get target node for single threaded private VMAs */
  58. if (prot_numa && !(vma->vm_flags & VM_SHARED) &&
  59. atomic_read(&vma->vm_mm->mm_users) == 1)
  60. target_node = numa_node_id();
  61. flush_tlb_batched_pending(vma->vm_mm);
  62. arch_enter_lazy_mmu_mode();
  63. do {
  64. oldpte = *pte;
  65. if (pte_present(oldpte)) {
  66. pte_t ptent;
  67. bool preserve_write = prot_numa && pte_write(oldpte);
  68. /*
  69. * Avoid trapping faults against the zero or KSM
  70. * pages. See similar comment in change_huge_pmd.
  71. */
  72. if (prot_numa) {
  73. struct page *page;
  74. page = vm_normal_page(vma, addr, oldpte);
  75. if (!page || PageKsm(page))
  76. continue;
  77. /* Avoid TLB flush if possible */
  78. if (pte_protnone(oldpte))
  79. continue;
  80. /*
  81. * Don't mess with PTEs if page is already on the node
  82. * a single-threaded process is running on.
  83. */
  84. if (target_node == page_to_nid(page))
  85. continue;
  86. }
  87. ptent = ptep_modify_prot_start(mm, addr, pte);
  88. ptent = pte_modify(ptent, newprot);
  89. if (preserve_write)
  90. ptent = pte_mk_savedwrite(ptent);
  91. /* Avoid taking write faults for known dirty pages */
  92. if (dirty_accountable && pte_dirty(ptent) &&
  93. (pte_soft_dirty(ptent) ||
  94. !(vma->vm_flags & VM_SOFTDIRTY))) {
  95. ptent = pte_mkwrite(ptent);
  96. }
  97. ptep_modify_prot_commit(mm, addr, pte, ptent);
  98. pages++;
  99. } else if (IS_ENABLED(CONFIG_MIGRATION)) {
  100. swp_entry_t entry = pte_to_swp_entry(oldpte);
  101. if (is_write_migration_entry(entry)) {
  102. pte_t newpte;
  103. /*
  104. * A protection check is difficult so
  105. * just be safe and disable write
  106. */
  107. make_migration_entry_read(&entry);
  108. newpte = swp_entry_to_pte(entry);
  109. if (pte_swp_soft_dirty(oldpte))
  110. newpte = pte_swp_mksoft_dirty(newpte);
  111. set_pte_at(mm, addr, pte, newpte);
  112. pages++;
  113. }
  114. if (is_write_device_private_entry(entry)) {
  115. pte_t newpte;
  116. /*
  117. * We do not preserve soft-dirtiness. See
  118. * copy_one_pte() for explanation.
  119. */
  120. make_device_private_entry_read(&entry);
  121. newpte = swp_entry_to_pte(entry);
  122. set_pte_at(mm, addr, pte, newpte);
  123. pages++;
  124. }
  125. }
  126. } while (pte++, addr += PAGE_SIZE, addr != end);
  127. arch_leave_lazy_mmu_mode();
  128. pte_unmap_unlock(pte - 1, ptl);
  129. return pages;
  130. }
  131. /*
  132. * Used when setting automatic NUMA hinting protection where it is
  133. * critical that a numa hinting PMD is not confused with a bad PMD.
  134. */
  135. static inline int pmd_none_or_clear_bad_unless_trans_huge(pmd_t *pmd)
  136. {
  137. pmd_t pmdval = pmd_read_atomic(pmd);
  138. /* See pmd_none_or_trans_huge_or_clear_bad for info on barrier */
  139. #ifdef CONFIG_TRANSPARENT_HUGEPAGE
  140. barrier();
  141. #endif
  142. if (pmd_none(pmdval))
  143. return 1;
  144. if (pmd_trans_huge(pmdval))
  145. return 0;
  146. if (unlikely(pmd_bad(pmdval))) {
  147. pmd_clear_bad(pmd);
  148. return 1;
  149. }
  150. return 0;
  151. }
  152. static inline unsigned long change_pmd_range(struct vm_area_struct *vma,
  153. pud_t *pud, unsigned long addr, unsigned long end,
  154. pgprot_t newprot, int dirty_accountable, int prot_numa)
  155. {
  156. pmd_t *pmd;
  157. struct mm_struct *mm = vma->vm_mm;
  158. unsigned long next;
  159. unsigned long pages = 0;
  160. unsigned long nr_huge_updates = 0;
  161. unsigned long mni_start = 0;
  162. pmd = pmd_offset(pud, addr);
  163. do {
  164. unsigned long this_pages;
  165. next = pmd_addr_end(addr, end);
  166. /*
  167. * Automatic NUMA balancing walks the tables with mmap_sem
  168. * held for read. It's possible a parallel update to occur
  169. * between pmd_trans_huge() and a pmd_none_or_clear_bad()
  170. * check leading to a false positive and clearing.
  171. * Hence, it's necessary to atomically read the PMD value
  172. * for all the checks.
  173. */
  174. if (!is_swap_pmd(*pmd) && !pmd_devmap(*pmd) &&
  175. pmd_none_or_clear_bad_unless_trans_huge(pmd))
  176. goto next;
  177. /* invoke the mmu notifier if the pmd is populated */
  178. if (!mni_start) {
  179. mni_start = addr;
  180. mmu_notifier_invalidate_range_start(mm, mni_start, end);
  181. }
  182. if (is_swap_pmd(*pmd) || pmd_trans_huge(*pmd) || pmd_devmap(*pmd)) {
  183. if (next - addr != HPAGE_PMD_SIZE) {
  184. __split_huge_pmd(vma, pmd, addr, false, NULL);
  185. } else {
  186. int nr_ptes = change_huge_pmd(vma, pmd, addr,
  187. newprot, prot_numa);
  188. if (nr_ptes) {
  189. if (nr_ptes == HPAGE_PMD_NR) {
  190. pages += HPAGE_PMD_NR;
  191. nr_huge_updates++;
  192. }
  193. /* huge pmd was handled */
  194. goto next;
  195. }
  196. }
  197. /* fall through, the trans huge pmd just split */
  198. }
  199. this_pages = change_pte_range(vma, pmd, addr, next, newprot,
  200. dirty_accountable, prot_numa);
  201. pages += this_pages;
  202. next:
  203. cond_resched();
  204. } while (pmd++, addr = next, addr != end);
  205. if (mni_start)
  206. mmu_notifier_invalidate_range_end(mm, mni_start, end);
  207. if (nr_huge_updates)
  208. count_vm_numa_events(NUMA_HUGE_PTE_UPDATES, nr_huge_updates);
  209. return pages;
  210. }
  211. static inline unsigned long change_pud_range(struct vm_area_struct *vma,
  212. p4d_t *p4d, unsigned long addr, unsigned long end,
  213. pgprot_t newprot, int dirty_accountable, int prot_numa)
  214. {
  215. pud_t *pud;
  216. unsigned long next;
  217. unsigned long pages = 0;
  218. pud = pud_offset(p4d, addr);
  219. do {
  220. next = pud_addr_end(addr, end);
  221. if (pud_none_or_clear_bad(pud))
  222. continue;
  223. pages += change_pmd_range(vma, pud, addr, next, newprot,
  224. dirty_accountable, prot_numa);
  225. } while (pud++, addr = next, addr != end);
  226. return pages;
  227. }
  228. static inline unsigned long change_p4d_range(struct vm_area_struct *vma,
  229. pgd_t *pgd, unsigned long addr, unsigned long end,
  230. pgprot_t newprot, int dirty_accountable, int prot_numa)
  231. {
  232. p4d_t *p4d;
  233. unsigned long next;
  234. unsigned long pages = 0;
  235. p4d = p4d_offset(pgd, addr);
  236. do {
  237. next = p4d_addr_end(addr, end);
  238. if (p4d_none_or_clear_bad(p4d))
  239. continue;
  240. pages += change_pud_range(vma, p4d, addr, next, newprot,
  241. dirty_accountable, prot_numa);
  242. } while (p4d++, addr = next, addr != end);
  243. return pages;
  244. }
  245. static unsigned long change_protection_range(struct vm_area_struct *vma,
  246. unsigned long addr, unsigned long end, pgprot_t newprot,
  247. int dirty_accountable, int prot_numa)
  248. {
  249. struct mm_struct *mm = vma->vm_mm;
  250. pgd_t *pgd;
  251. unsigned long next;
  252. unsigned long start = addr;
  253. unsigned long pages = 0;
  254. BUG_ON(addr >= end);
  255. pgd = pgd_offset(mm, addr);
  256. flush_cache_range(vma, addr, end);
  257. inc_tlb_flush_pending(mm);
  258. do {
  259. next = pgd_addr_end(addr, end);
  260. if (pgd_none_or_clear_bad(pgd))
  261. continue;
  262. pages += change_p4d_range(vma, pgd, addr, next, newprot,
  263. dirty_accountable, prot_numa);
  264. } while (pgd++, addr = next, addr != end);
  265. /* Only flush the TLB if we actually modified any entries: */
  266. if (pages)
  267. flush_tlb_range(vma, start, end);
  268. dec_tlb_flush_pending(mm);
  269. return pages;
  270. }
  271. unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
  272. unsigned long end, pgprot_t newprot,
  273. int dirty_accountable, int prot_numa)
  274. {
  275. unsigned long pages;
  276. if (is_vm_hugetlb_page(vma))
  277. pages = hugetlb_change_protection(vma, start, end, newprot);
  278. else
  279. pages = change_protection_range(vma, start, end, newprot, dirty_accountable, prot_numa);
  280. return pages;
  281. }
  282. static int prot_none_pte_entry(pte_t *pte, unsigned long addr,
  283. unsigned long next, struct mm_walk *walk)
  284. {
  285. return pfn_modify_allowed(pte_pfn(*pte), *(pgprot_t *)(walk->private)) ?
  286. 0 : -EACCES;
  287. }
  288. static int prot_none_hugetlb_entry(pte_t *pte, unsigned long hmask,
  289. unsigned long addr, unsigned long next,
  290. struct mm_walk *walk)
  291. {
  292. return pfn_modify_allowed(pte_pfn(*pte), *(pgprot_t *)(walk->private)) ?
  293. 0 : -EACCES;
  294. }
  295. static int prot_none_test(unsigned long addr, unsigned long next,
  296. struct mm_walk *walk)
  297. {
  298. return 0;
  299. }
  300. static int prot_none_walk(struct vm_area_struct *vma, unsigned long start,
  301. unsigned long end, unsigned long newflags)
  302. {
  303. pgprot_t new_pgprot = vm_get_page_prot(newflags);
  304. struct mm_walk prot_none_walk = {
  305. .pte_entry = prot_none_pte_entry,
  306. .hugetlb_entry = prot_none_hugetlb_entry,
  307. .test_walk = prot_none_test,
  308. .mm = current->mm,
  309. .private = &new_pgprot,
  310. };
  311. return walk_page_range(start, end, &prot_none_walk);
  312. }
  313. int
  314. mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
  315. unsigned long start, unsigned long end, unsigned long newflags)
  316. {
  317. struct mm_struct *mm = vma->vm_mm;
  318. unsigned long oldflags = vma->vm_flags;
  319. long nrpages = (end - start) >> PAGE_SHIFT;
  320. unsigned long charged = 0;
  321. pgoff_t pgoff;
  322. int error;
  323. int dirty_accountable = 0;
  324. if (newflags == oldflags) {
  325. *pprev = vma;
  326. return 0;
  327. }
  328. /*
  329. * Do PROT_NONE PFN permission checks here when we can still
  330. * bail out without undoing a lot of state. This is a rather
  331. * uncommon case, so doesn't need to be very optimized.
  332. */
  333. if (arch_has_pfn_modify_check() &&
  334. (vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) &&
  335. (newflags & (VM_READ|VM_WRITE|VM_EXEC)) == 0) {
  336. error = prot_none_walk(vma, start, end, newflags);
  337. if (error)
  338. return error;
  339. }
  340. /*
  341. * If we make a private mapping writable we increase our commit;
  342. * but (without finer accounting) cannot reduce our commit if we
  343. * make it unwritable again. hugetlb mapping were accounted for
  344. * even if read-only so there is no need to account for them here
  345. */
  346. if (newflags & VM_WRITE) {
  347. /* Check space limits when area turns into data. */
  348. if (!may_expand_vm(mm, newflags, nrpages) &&
  349. may_expand_vm(mm, oldflags, nrpages))
  350. return -ENOMEM;
  351. if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB|
  352. VM_SHARED|VM_NORESERVE))) {
  353. charged = nrpages;
  354. if (security_vm_enough_memory_mm(mm, charged))
  355. return -ENOMEM;
  356. newflags |= VM_ACCOUNT;
  357. }
  358. }
  359. /*
  360. * First try to merge with previous and/or next vma.
  361. */
  362. pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT);
  363. *pprev = vma_merge(mm, *pprev, start, end, newflags,
  364. vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma),
  365. vma->vm_userfaultfd_ctx, vma_get_anon_name(vma));
  366. if (*pprev) {
  367. vma = *pprev;
  368. VM_WARN_ON((vma->vm_flags ^ newflags) & ~VM_SOFTDIRTY);
  369. goto success;
  370. }
  371. *pprev = vma;
  372. if (start != vma->vm_start) {
  373. error = split_vma(mm, vma, start, 1);
  374. if (error)
  375. goto fail;
  376. }
  377. if (end != vma->vm_end) {
  378. error = split_vma(mm, vma, end, 0);
  379. if (error)
  380. goto fail;
  381. }
  382. success:
  383. /*
  384. * vm_flags and vm_page_prot are protected by the mmap_sem
  385. * held in write mode.
  386. */
  387. vm_write_begin(vma);
  388. WRITE_ONCE(vma->vm_flags, newflags);
  389. dirty_accountable = vma_wants_writenotify(vma, vma->vm_page_prot);
  390. vma_set_page_prot(vma);
  391. change_protection(vma, start, end, vma->vm_page_prot,
  392. dirty_accountable, 0);
  393. vm_write_end(vma);
  394. /*
  395. * Private VM_LOCKED VMA becoming writable: trigger COW to avoid major
  396. * fault on access.
  397. */
  398. if ((oldflags & (VM_WRITE | VM_SHARED | VM_LOCKED)) == VM_LOCKED &&
  399. (newflags & VM_WRITE)) {
  400. populate_vma_page_range(vma, start, end, NULL);
  401. }
  402. vm_stat_account(mm, oldflags, -nrpages);
  403. vm_stat_account(mm, newflags, nrpages);
  404. perf_event_mmap(vma);
  405. return 0;
  406. fail:
  407. vm_unacct_memory(charged);
  408. return error;
  409. }
  410. /*
  411. * pkey==-1 when doing a legacy mprotect()
  412. */
  413. static int do_mprotect_pkey(unsigned long start, size_t len,
  414. unsigned long prot, int pkey)
  415. {
  416. unsigned long nstart, end, tmp, reqprot;
  417. struct vm_area_struct *vma, *prev;
  418. int error = -EINVAL;
  419. const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
  420. const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
  421. (prot & PROT_READ);
  422. start = untagged_addr(start);
  423. prot &= ~(PROT_GROWSDOWN|PROT_GROWSUP);
  424. if (grows == (PROT_GROWSDOWN|PROT_GROWSUP)) /* can't be both */
  425. return -EINVAL;
  426. if (start & ~PAGE_MASK)
  427. return -EINVAL;
  428. if (!len)
  429. return 0;
  430. len = PAGE_ALIGN(len);
  431. end = start + len;
  432. if (end <= start)
  433. return -ENOMEM;
  434. if (!arch_validate_prot(prot))
  435. return -EINVAL;
  436. reqprot = prot;
  437. if (down_write_killable(&current->mm->mmap_sem))
  438. return -EINTR;
  439. /*
  440. * If userspace did not allocate the pkey, do not let
  441. * them use it here.
  442. */
  443. error = -EINVAL;
  444. if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
  445. goto out;
  446. vma = find_vma(current->mm, start);
  447. error = -ENOMEM;
  448. if (!vma)
  449. goto out;
  450. prev = vma->vm_prev;
  451. if (unlikely(grows & PROT_GROWSDOWN)) {
  452. if (vma->vm_start >= end)
  453. goto out;
  454. start = vma->vm_start;
  455. error = -EINVAL;
  456. if (!(vma->vm_flags & VM_GROWSDOWN))
  457. goto out;
  458. } else {
  459. if (vma->vm_start > start)
  460. goto out;
  461. if (unlikely(grows & PROT_GROWSUP)) {
  462. end = vma->vm_end;
  463. error = -EINVAL;
  464. if (!(vma->vm_flags & VM_GROWSUP))
  465. goto out;
  466. }
  467. }
  468. if (start > vma->vm_start)
  469. prev = vma;
  470. for (nstart = start ; ; ) {
  471. unsigned long mask_off_old_flags;
  472. unsigned long newflags;
  473. int new_vma_pkey;
  474. /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
  475. /* Does the application expect PROT_READ to imply PROT_EXEC */
  476. if (rier && (vma->vm_flags & VM_MAYEXEC))
  477. prot |= PROT_EXEC;
  478. /*
  479. * Each mprotect() call explicitly passes r/w/x permissions.
  480. * If a permission is not passed to mprotect(), it must be
  481. * cleared from the VMA.
  482. */
  483. mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC |
  484. ARCH_VM_PKEY_FLAGS;
  485. new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey);
  486. newflags = calc_vm_prot_bits(prot, new_vma_pkey);
  487. newflags |= (vma->vm_flags & ~mask_off_old_flags);
  488. /* newflags >> 4 shift VM_MAY% in place of VM_% */
  489. if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
  490. error = -EACCES;
  491. goto out;
  492. }
  493. error = security_file_mprotect(vma, reqprot, prot);
  494. if (error)
  495. goto out;
  496. tmp = vma->vm_end;
  497. if (tmp > end)
  498. tmp = end;
  499. error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
  500. if (error)
  501. goto out;
  502. nstart = tmp;
  503. if (nstart < prev->vm_end)
  504. nstart = prev->vm_end;
  505. if (nstart >= end)
  506. goto out;
  507. vma = prev->vm_next;
  508. if (!vma || vma->vm_start != nstart) {
  509. error = -ENOMEM;
  510. goto out;
  511. }
  512. prot = reqprot;
  513. }
  514. out:
  515. up_write(&current->mm->mmap_sem);
  516. return error;
  517. }
  518. SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
  519. unsigned long, prot)
  520. {
  521. return do_mprotect_pkey(start, len, prot, -1);
  522. }
  523. #ifdef CONFIG_ARCH_HAS_PKEYS
  524. SYSCALL_DEFINE4(pkey_mprotect, unsigned long, start, size_t, len,
  525. unsigned long, prot, int, pkey)
  526. {
  527. return do_mprotect_pkey(start, len, prot, pkey);
  528. }
  529. SYSCALL_DEFINE2(pkey_alloc, unsigned long, flags, unsigned long, init_val)
  530. {
  531. int pkey;
  532. int ret;
  533. /* No flags supported yet. */
  534. if (flags)
  535. return -EINVAL;
  536. /* check for unsupported init values */
  537. if (init_val & ~PKEY_ACCESS_MASK)
  538. return -EINVAL;
  539. down_write(&current->mm->mmap_sem);
  540. pkey = mm_pkey_alloc(current->mm);
  541. ret = -ENOSPC;
  542. if (pkey == -1)
  543. goto out;
  544. ret = arch_set_user_pkey_access(current, pkey, init_val);
  545. if (ret) {
  546. mm_pkey_free(current->mm, pkey);
  547. goto out;
  548. }
  549. ret = pkey;
  550. out:
  551. up_write(&current->mm->mmap_sem);
  552. return ret;
  553. }
  554. SYSCALL_DEFINE1(pkey_free, int, pkey)
  555. {
  556. int ret;
  557. down_write(&current->mm->mmap_sem);
  558. ret = mm_pkey_free(current->mm, pkey);
  559. up_write(&current->mm->mmap_sem);
  560. /*
  561. * We could provie warnings or errors if any VMA still
  562. * has the pkey set here.
  563. */
  564. return ret;
  565. }
  566. #endif /* CONFIG_ARCH_HAS_PKEYS */