Skip to content

Commit a2b5367

Browse files
heicarstMartin Schwidefsky
authored andcommitted
[S390] kprobes: use probe_kernel_write
Use proble_kernel_write() to patch the kernel. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 88df125 commit a2b5367

1 file changed

Lines changed: 2 additions & 29 deletions

File tree

‎arch/s390/kernel/kprobes.c‎

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include <linux/preempt.h>
2626
#include <linux/stop_machine.h>
2727
#include <linux/kdebug.h>
28+
#include <linux/uaccess.h>
2829
#include <asm/cacheflush.h>
2930
#include <asm/sections.h>
30-
#include <asm/uaccess.h>
3131
#include <linux/module.h>
3232

3333
DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
@@ -155,35 +155,8 @@ void __kprobes get_instruction_type(struct arch_specific_insn *ainsn)
155155
static int __kprobes swap_instruction(void *aref)
156156
{
157157
struct ins_replace_args *args = aref;
158-
u32 *addr;
159-
u32 instr;
160-
int err = -EFAULT;
161158

162-
/*
163-
* Text segment is read-only, hence we use stura to bypass dynamic
164-
* address translation to exchange the instruction. Since stura
165-
* always operates on four bytes, but we only want to exchange two
166-
* bytes do some calculations to get things right. In addition we
167-
* shall not cross any page boundaries (vmalloc area!) when writing
168-
* the new instruction.
169-
*/
170-
addr = (u32 *)((unsigned long)args->ptr & -4UL);
171-
if ((unsigned long)args->ptr & 2)
172-
instr = ((*addr) & 0xffff0000) | args->new;
173-
else
174-
instr = ((*addr) & 0x0000ffff) | args->new << 16;
175-
176-
asm volatile(
177-
" lra %1,0(%1)\n"
178-
"0: stura %2,%1\n"
179-
"1: la %0,0\n"
180-
"2:\n"
181-
EX_TABLE(0b,2b)
182-
: "+d" (err)
183-
: "a" (addr), "d" (instr)
184-
: "memory", "cc");
185-
186-
return err;
159+
return probe_kernel_write(args->ptr, &args->new, sizeof(args->new));
187160
}
188161

189162
void __kprobes arch_arm_kprobe(struct kprobe *p)

0 commit comments

Comments
 (0)