Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\events\uprobes.c Create Date:2022-07-28 13:45:00
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:NOTE:* Expect the breakpoint instruction to be the smallest size instruction for* the architecture

Proto:int uprobe_write_opcode(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long vaddr, uprobe_opcode_t opcode)

Type:int

Parameter:

TypeParameterName
struct arch_uprobe *auprobe
struct mm_struct *mm
unsigned longvaddr
uprobe_opcode_topcode
475  ref_ctr_updated = 0
476  bool orig_page_huge = false
477  gup_flags = get_user_pages read/write w/o permission
479  is_register = s_swbp_insn - check if instruction is breakpoint instruction.*@insn: instruction to be checked.* Default implementation of is_swbp_insn* Returns true if @insn is a breakpoint instruction.
480  uprobe = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(auprobe, structuprobe, arch)
482  retry :
483  If is_register Then gup_flags |= split huge pmd before returning
486  ret = get_user_pages_remote(NULL, mm, vaddr, 1, gup_flags, & old_page, & vma, NULL)
488  If ret <= 0 Then Return ret
491  ret = verify_opcode(old_page, vaddr, & opcode)
492  If ret <= 0 Then Go to put_old
495  If WARN(!is_register && PageCompound(old_page), "uprobe unregister should never work on compound page\n") Then
497  ret = -EINVAL
498  Go to put_old
502  If Not ref_ctr_updated && ref_ctr_offset Then
503  ret = update_ref_ctr(uprobe, mm, is_register ? 1 : - 1)
504  If ret Then Go to put_old
507  ref_ctr_updated = 1
510  ret = 0
511  If Not is_register && Not PageAnon(old_page) Then Go to put_old
514  ret = anon_vma_prepare(vma)
515  If ret Then Go to put_old
518  ret = -ENOMEM
519  new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, vaddr)
520  If Not new_page Then Go to put_old
523  __SetPageUptodate(new_page)
524  copy_highpage(new_page, old_page)
525  copy_to_page(new_page, vaddr, & opcode, UPROBE_SWBP_INSN_SIZE)
527  If Not is_register Then
531  VM_BUG_ON_PAGE(!PageAnon(old_page), old_page)
533  index = vaddr_to_offset(vma, vaddr & PAGE_MASK) >> PAGE_SHIFT determines the page size
534  orig_page = d_get_page - find and get a page reference*@mapping: the address_space to search*@offset: the page index* Looks up the page cache slot at @mapping & @offset. If there is a* page cache page, it is returned with an increased refcount.
537  If orig_page Then
542  new_page = NULL
544  If PageCompound(orig_page) Then orig_page_huge = true
551  ret = __replace_page - replace page in vma by new page
552  If new_page Then put_page(new_page)
554  put_old :
555  put_page(old_page)
557  If Value for the false possibility is greater at compile time(ret == - EAGAIN) Then Go to retry
561  If ret && is_register && ref_ctr_updated Then update_ref_ctr(uprobe, mm, - 1)
565  If Not ret && orig_page_huge Then collapse_pte_mapped_thp(mm, vaddr)
568  Return ret
Caller
NameDescribe
set_swbpset_swbp - store breakpoint at a given address.*@auprobe: arch specific probepoint information.*@mm: the probed process address space.*@vaddr: the virtual address to insert the opcode.* For mm @mm, store the breakpoint instruction at @vaddr.
set_orig_insnset_orig_insn - Restore the original instruction.*@mm: the probed process address space.*@auprobe: arch specific probepoint information.*@vaddr: the virtual address to insert the opcode.* For mm @mm, restore the original opcode (opcode) at @vaddr.