2019-06-04 08:11:33 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2011-07-26 00:12:53 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/mm.h>
|
2015-05-11 22:07:07 +00:00
|
|
|
#include <asm/elf.h>
|
2011-07-26 00:12:53 +00:00
|
|
|
|
|
|
|
static struct vm_area_struct gate_vma;
|
|
|
|
|
|
|
|
static int __init gate_vma_init(void)
|
|
|
|
{
|
|
|
|
if (!FIXADDR_USER_START)
|
|
|
|
return 0;
|
|
|
|
|
2018-07-26 23:37:30 +00:00
|
|
|
vma_init(&gate_vma, NULL);
|
2011-07-26 00:12:53 +00:00
|
|
|
gate_vma.vm_start = FIXADDR_USER_START;
|
|
|
|
gate_vma.vm_end = FIXADDR_USER_END;
|
|
|
|
gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
|
2022-07-11 07:05:58 +00:00
|
|
|
gate_vma.vm_page_prot = PAGE_READONLY;
|
2011-07-26 00:12:53 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
__initcall(gate_vma_init);
|
|
|
|
|
|
|
|
struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
|
|
|
|
{
|
|
|
|
return FIXADDR_USER_START ? &gate_vma : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int in_gate_area_no_mm(unsigned long addr)
|
|
|
|
{
|
|
|
|
if (!FIXADDR_USER_START)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((addr >= FIXADDR_USER_START) && (addr < FIXADDR_USER_END))
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int in_gate_area(struct mm_struct *mm, unsigned long addr)
|
|
|
|
{
|
|
|
|
struct vm_area_struct *vma = get_gate_vma(mm);
|
|
|
|
|
|
|
|
if (!vma)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (addr >= vma->vm_start) && (addr < vma->vm_end);
|
|
|
|
}
|