hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/arm/kernel/swp_emulate.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/kernel/swp_emulate.c
34 *
45 * Copyright (C) 2009 ARM Limited
56 * __user_* functions adapted from include/asm/uaccess.h
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 *
118 * Implements emulation of the SWP/SWPB instructions using load-exclusive and
129 * store-exclusive for processors that have them disabled (or future ones that
....@@ -98,22 +95,20 @@
9895 */
9996 static void set_segfault(struct pt_regs *regs, unsigned long addr)
10097 {
101
- siginfo_t info;
98
+ int si_code;
10299
103
- clear_siginfo(&info);
104
- down_read(&current->mm->mmap_sem);
100
+ mmap_read_lock(current->mm);
105101 if (find_vma(current->mm, addr) == NULL)
106
- info.si_code = SEGV_MAPERR;
102
+ si_code = SEGV_MAPERR;
107103 else
108
- info.si_code = SEGV_ACCERR;
109
- up_read(&current->mm->mmap_sem);
110
-
111
- info.si_signo = SIGSEGV;
112
- info.si_errno = 0;
113
- info.si_addr = (void *) instruction_pointer(regs);
104
+ si_code = SEGV_ACCERR;
105
+ mmap_read_unlock(current->mm);
114106
115107 pr_debug("SWP{B} emulation: access caused memory abort!\n");
116
- arm_notify_die("Illegal memory access", regs, &info, 0, 0);
108
+ arm_notify_die("Illegal memory access", regs,
109
+ SIGSEGV, si_code,
110
+ (void __user *)instruction_pointer(regs),
111
+ 0, 0);
117112
118113 abtcounter++;
119114 }
....@@ -200,7 +195,7 @@
200195 destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);
201196
202197 /* Check access in reasonable access range for both SWP and SWPB */
203
- if (!access_ok(VERIFY_WRITE, (address & ~3), 4)) {
198
+ if (!access_ok((void __user *)(address & ~3), 4)) {
204199 pr_debug("SWP{B} emulation: access to %p not allowed!\n",
205200 (void *)address);
206201 res = -EFAULT;