Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm/mseal: small cleanups

Drop the wholly unnecessary set_vma_sealed() helper(), which is used only
once, and place VMA_ITERATOR() declarations in the correct place.

Retain vma_is_sealed(), and use it instead of the confusingly named
can_modify_vma(), so it's abundantly clear what's being tested, rather
then a nebulous sense of 'can the VMA be modified'.

No functional change intended.

Link: https://lkml.kernel.org/r/98cf28d04583d632a6eb698e9ad23733bb6af26b.1753431105.git.lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: Jeff Xu <jeffxu@chromium.org>
Cc: Jann Horn <jannh@google.com>
Cc: Kees Cook <kees@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Lorenzo Stoakes and committed by
Andrew Morton
8b291416 d0b47a68

+8 -31
+1 -1
mm/madvise.c
··· 1287 1287 struct vm_area_struct *vma = madv_behavior->vma; 1288 1288 1289 1289 /* If the VMA isn't sealed we're good. */ 1290 - if (can_modify_vma(vma)) 1290 + if (!vma_is_sealed(vma)) 1291 1291 return true; 1292 1292 1293 1293 /* For a sealed VMA, we only care about discard operations. */
+1 -1
mm/mprotect.c
··· 766 766 unsigned long charged = 0; 767 767 int error; 768 768 769 - if (!can_modify_vma(vma)) 769 + if (vma_is_sealed(vma)) 770 770 return -EPERM; 771 771 772 772 if (newflags == oldflags) {
+1 -1
mm/mremap.c
··· 1651 1651 return -EFAULT; 1652 1652 1653 1653 /* If mseal()'d, mremap() is prohibited. */ 1654 - if (!can_modify_vma(vma)) 1654 + if (vma_is_sealed(vma)) 1655 1655 return -EPERM; 1656 1656 1657 1657 /* Align to hugetlb page size, if required. */
+1 -8
mm/mseal.c
··· 15 15 #include <linux/sched.h> 16 16 #include "internal.h" 17 17 18 - static inline void set_vma_sealed(struct vm_area_struct *vma) 19 - { 20 - vm_flags_set(vma, VM_SEALED); 21 - } 22 - 23 18 static int mseal_fixup(struct vma_iterator *vmi, struct vm_area_struct *vma, 24 19 struct vm_area_struct **prev, unsigned long start, 25 20 unsigned long end, vm_flags_t newflags) ··· 31 36 goto out; 32 37 } 33 38 34 - set_vma_sealed(vma); 39 + vm_flags_set(vma, VM_SEALED); 35 40 out: 36 41 *prev = vma; 37 42 return ret; ··· 48 53 { 49 54 struct vm_area_struct *vma; 50 55 unsigned long nstart = start; 51 - 52 56 VMA_ITERATOR(vmi, current->mm, start); 53 57 54 58 /* going through each vma to check. */ ··· 72 78 { 73 79 unsigned long nstart; 74 80 struct vm_area_struct *vma, *prev; 75 - 76 81 VMA_ITERATOR(vmi, current->mm, start); 77 82 78 83 vma = vma_iter_load(&vmi);
+2 -2
mm/vma.c
··· 1351 1351 } 1352 1352 1353 1353 /* Don't bother splitting the VMA if we can't unmap it anyway */ 1354 - if (!can_modify_vma(vms->vma)) { 1354 + if (vma_is_sealed(vms->vma)) { 1355 1355 error = -EPERM; 1356 1356 goto start_split_failed; 1357 1357 } ··· 1371 1371 for_each_vma_range(*(vms->vmi), next, vms->end) { 1372 1372 long nrpages; 1373 1373 1374 - if (!can_modify_vma(next)) { 1374 + if (vma_is_sealed(next)) { 1375 1375 error = -EPERM; 1376 1376 goto modify_vma_failed; 1377 1377 }
+2 -18
mm/vma.h
··· 559 559 } 560 560 561 561 #ifdef CONFIG_64BIT 562 - 563 562 static inline bool vma_is_sealed(struct vm_area_struct *vma) 564 563 { 565 564 return (vma->vm_flags & VM_SEALED); 566 565 } 567 - 568 - /* 569 - * check if a vma is sealed for modification. 570 - * return true, if modification is allowed. 571 - */ 572 - static inline bool can_modify_vma(struct vm_area_struct *vma) 573 - { 574 - if (unlikely(vma_is_sealed(vma))) 575 - return false; 576 - 577 - return true; 578 - } 579 - 580 566 #else 581 - 582 - static inline bool can_modify_vma(struct vm_area_struct *vma) 567 + static inline bool vma_is_sealed(struct vm_area_struct *vma) 583 568 { 584 - return true; 569 + return false; 585 570 } 586 - 587 571 #endif 588 572 589 573 #if defined(CONFIG_STACK_GROWSUP)