Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
0004  */
0005 
0006 #include <linux/mm.h>
0007 #include <asm/elf.h>
0008 
0009 static struct vm_area_struct gate_vma;
0010 
0011 static int __init gate_vma_init(void)
0012 {
0013     if (!FIXADDR_USER_START)
0014         return 0;
0015 
0016     vma_init(&gate_vma, NULL);
0017     gate_vma.vm_start = FIXADDR_USER_START;
0018     gate_vma.vm_end = FIXADDR_USER_END;
0019     gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
0020     gate_vma.vm_page_prot = PAGE_READONLY;
0021 
0022     return 0;
0023 }
0024 __initcall(gate_vma_init);
0025 
0026 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
0027 {
0028     return FIXADDR_USER_START ? &gate_vma : NULL;
0029 }
0030 
0031 int in_gate_area_no_mm(unsigned long addr)
0032 {
0033     if (!FIXADDR_USER_START)
0034         return 0;
0035 
0036     if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
0037         return 1;
0038 
0039     return 0;
0040 }
0041 
0042 int in_gate_area(struct mm_struct *mm, unsigned long addr)
0043 {
0044     struct vm_area_struct *vma = get_gate_vma(mm);
0045 
0046     if (!vma)
0047         return 0;
0048 
0049     return (addr >= vma->vm_start) && (addr < vma->vm_end);
0050 }