fault.c (16217dc79dbc599b110dda26d0421df47904bba4) fault.c (0edfa8391664a4f795c67d0e07480fbe801a0e1d)
1/*
2 * Based on arch/arm/mm/fault.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Copyright (C) 1995-2004 Russell King
6 * Copyright (C) 2012 ARM Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 4 unchanged lines hidden (view full) ---

13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1/*
2 * Based on arch/arm/mm/fault.c
3 *
4 * Copyright (C) 1995 Linus Torvalds
5 * Copyright (C) 1995-2004 Russell King
6 * Copyright (C) 2012 ARM Ltd.
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 4 unchanged lines hidden (view full) ---

13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <linux/module.h>
21#include <linux/extable.h>
22#include <linux/signal.h>
23#include <linux/mm.h>
24#include <linux/hardirq.h>
25#include <linux/init.h>
26#include <linux/kprobes.h>
27#include <linux/uaccess.h>
28#include <linux/page-flags.h>
29#include <linux/sched.h>

--- 216 unchanged lines hidden (view full) ---

246
247 /*
248 * Ok, we have a good vm_area for this memory access, so we can handle
249 * it.
250 */
251good_area:
252 /*
253 * Check that the permissions on the VMA allow for the fault which
22#include <linux/signal.h>
23#include <linux/mm.h>
24#include <linux/hardirq.h>
25#include <linux/init.h>
26#include <linux/kprobes.h>
27#include <linux/uaccess.h>
28#include <linux/page-flags.h>
29#include <linux/sched.h>

--- 216 unchanged lines hidden (view full) ---

246
247 /*
248 * Ok, we have a good vm_area for this memory access, so we can handle
249 * it.
250 */
251good_area:
252 /*
253 * Check that the permissions on the VMA allow for the fault which
254 * occurred. If we encountered a write or exec fault, we must have
255 * appropriate permissions, otherwise we allow any permission.
254 * occurred.
256 */
257 if (!(vma->vm_flags & vm_flags)) {
258 fault = VM_FAULT_BADACCESS;
259 goto out;
260 }
261
262 return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
263

--- 19 unchanged lines hidden (view full) ---

283}
284
285static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
286 struct pt_regs *regs)
287{
288 struct task_struct *tsk;
289 struct mm_struct *mm;
290 int fault, sig, code;
255 */
256 if (!(vma->vm_flags & vm_flags)) {
257 fault = VM_FAULT_BADACCESS;
258 goto out;
259 }
260
261 return handle_mm_fault(vma, addr & PAGE_MASK, mm_flags);
262

--- 19 unchanged lines hidden (view full) ---

282}
283
284static int __kprobes do_page_fault(unsigned long addr, unsigned int esr,
285 struct pt_regs *regs)
286{
287 struct task_struct *tsk;
288 struct mm_struct *mm;
289 int fault, sig, code;
291 unsigned long vm_flags = VM_READ | VM_WRITE | VM_EXEC;
290 unsigned long vm_flags = VM_READ | VM_WRITE;
292 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
293
294 if (notify_page_fault(regs, esr))
295 return 0;
296
297 tsk = current;
298 mm = tsk->mm;
299

--- 392 unchanged lines hidden ---
291 unsigned int mm_flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
292
293 if (notify_page_fault(regs, esr))
294 return 0;
295
296 tsk = current;
297 mm = tsk->mm;
298

--- 392 unchanged lines hidden ---