mprotect.c (63bef48fd6c9d3f1ba4f0e23b4da1e007db6a3c0) | mprotect.c (6cb4d9a2870d2062e34c93bfef4d52fca3fe42d1) |
---|---|
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> --- 405 unchanged lines hidden (view full) --- 414 415 /* 416 * Do PROT_NONE PFN permission checks here when we can still 417 * bail out without undoing a lot of state. This is a rather 418 * uncommon case, so doesn't need to be very optimized. 419 */ 420 if (arch_has_pfn_modify_check() && 421 (vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && | 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> --- 405 unchanged lines hidden (view full) --- 414 415 /* 416 * Do PROT_NONE PFN permission checks here when we can still 417 * bail out without undoing a lot of state. This is a rather 418 * uncommon case, so doesn't need to be very optimized. 419 */ 420 if (arch_has_pfn_modify_check() && 421 (vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) && |
422 (newflags & (VM_READ|VM_WRITE|VM_EXEC)) == 0) { | 422 (newflags & VM_ACCESS_FLAGS) == 0) { |
423 pgprot_t new_pgprot = vm_get_page_prot(newflags); 424 425 error = walk_page_range(current->mm, start, end, 426 &prot_none_walk_ops, &new_pgprot); 427 if (error) 428 return error; 429 } 430 --- 162 unchanged lines hidden (view full) --- 593 mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC | 594 VM_FLAGS_CLEAR; 595 596 new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey); 597 newflags = calc_vm_prot_bits(prot, new_vma_pkey); 598 newflags |= (vma->vm_flags & ~mask_off_old_flags); 599 600 /* newflags >> 4 shift VM_MAY% in place of VM_% */ | 423 pgprot_t new_pgprot = vm_get_page_prot(newflags); 424 425 error = walk_page_range(current->mm, start, end, 426 &prot_none_walk_ops, &new_pgprot); 427 if (error) 428 return error; 429 } 430 --- 162 unchanged lines hidden (view full) --- 593 mask_off_old_flags = VM_READ | VM_WRITE | VM_EXEC | 594 VM_FLAGS_CLEAR; 595 596 new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey); 597 newflags = calc_vm_prot_bits(prot, new_vma_pkey); 598 newflags |= (vma->vm_flags & ~mask_off_old_flags); 599 600 /* newflags >> 4 shift VM_MAY% in place of VM_% */ |
601 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) { | 601 if ((newflags & ~(newflags >> 4)) & VM_ACCESS_FLAGS) { |
602 error = -EACCES; 603 goto out; 604 } 605 606 error = security_file_mprotect(vma, reqprot, prot); 607 if (error) 608 goto out; 609 --- 85 unchanged lines hidden --- | 602 error = -EACCES; 603 goto out; 604 } 605 606 error = security_file_mprotect(vma, reqprot, prot); 607 if (error) 608 goto out; 609 --- 85 unchanged lines hidden --- |