Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:mm\mprotect.c Create Date:2022-07-28 14:52:24
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:pkey==-1 when doing a legacy mprotect()

Proto:static int do_mprotect_pkey(unsigned long start, size_t len, unsigned long prot, int pkey)

Type:int

Parameter:

TypeParameterName
unsigned longstart
size_tlen
unsigned longprot
intpkey
491  error = -EINVAL
492  grows = prot & (mprotect flag: extend change to start of growsdown vma | mprotect flag: extend change to end of growsup vma )
493  rier = personality & READ_IMPLIES_EXEC && prot & page can be read
496  start = Architectures that support memory tagging (assigning tags to memory regions,* embedding these tags into addresses that point to these memory regions, and* checking that the memory and the pointer tags match on memory accesses)(start)
498  prot &= ~(mprotect flag: extend change to start of growsdown vma | mprotect flag: extend change to end of growsup vma )
499  If grows == (mprotect flag: extend change to start of growsdown vma | mprotect flag: extend change to end of growsup vma ) Then Return -EINVAL
502  If start & ~PAGE_MASK Then Return -EINVAL
504  If Not len Then Return 0
506  len = align the pointer to the (next) page boundary (len)
507  end = start + len
508  If end <= start Then Return -ENOMEM
510  If Not This is called from mprotect(). PROT_GROWSDOWN and PROT_GROWSUP have* already been masked out.* Returns true if the prot flags are valid Then Return -EINVAL
513  reqprot = prot
515  If lock for writing Then Return -EINTR
522  error = -EINVAL
523  If pkey != -1 && Not mm_pkey_is_allocated(mm, pkey) Then Go to out
526  vma = Look up the first VMA which satisfies addr < vm_end, NULL if none.
527  error = -ENOMEM
528  If Not vma Then Go to out
530  prev = linked list of VM areas per task, sorted by address
531  If Value for the false possibility is greater at compile time(grows & mprotect flag: extend change to start of growsdown vma ) Then
532  If Our start address within vm_mm. >= end Then Go to out
534  start = Our start address within vm_mm.
535  error = -EINVAL
536  If Not (Flags, see mm.h. & general info on the segment ) Then Go to out
538  Else
539  If Our start address within vm_mm. > start Then Go to out
543  error = -EINVAL
544  If Not (Flags, see mm.h. & VM_GROWSUP) Then Go to out
548  If start > Our start address within vm_mm. Then prev = vma
551  cycle
559  If rier && Flags, see mm.h. & VM_MAYEXEC Then prot |= page can be executed
567  mask_off_old_flags = currently active flags | VM_WRITE | VM_EXEC | VM_FLAGS_CLEAR
570  new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey)
571  newflags = Combine the mmap "prot" argument into "vm_flags" used internally.
572  newflags |= Flags, see mm.h. & ~mask_off_old_flags
575  If newflags & ~(newflags >> 4) & ( currently active flags | VM_WRITE | VM_EXEC) Then
576  error = -EACCES
577  Go to out
580  error = security_file_mprotect(vma, reqprot, prot)
581  If error Then Go to out
584  tmp = The first byte after our end addresswithin vm_mm.
585  If tmp > end Then tmp = end
587  error = mprotect_fixup(vma, & prev, nstart, tmp, newflags)
588  If error Then Go to out
590  nstart = tmp
592  If nstart < The first byte after our end addresswithin vm_mm. Then nstart = The first byte after our end addresswithin vm_mm.
594  If nstart >= end Then Go to out
597  vma = linked list of VM areas per task, sorted by address
599  error = -ENOMEM
600  Go to out
602  prot = reqprot
604  out :
605  lease a write lock
606  Return error
Caller
NameDescribe
SYSCALL_DEFINE3