Skip to content

Commit 83650fd

Browse files
committed
Merge tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull more arm64 updates from Catalin Marinas: - fix W+X page (mark RO) allocated by the arm64 kprobes code - Makefile fix for .i files in out of tree modules * tag 'arm64-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: kprobe: make page to RO mode when allocate it arm64: kdump: fix small typo arm64: makefile fix build of .i file in external module case
2 parents 3308a38 + 9668668 commit 83650fd

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

arch/arm64/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ vdso_install:
134134
archclean:
135135
$(Q)$(MAKE) $(clean)=$(boot)
136136

137+
ifeq ($(KBUILD_EXTMOD),)
137138
# We need to generate vdso-offsets.h before compiling certain files in kernel/.
138139
# In order to do that, we should use the archprepare target, but we can't since
139140
# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
@@ -143,6 +144,7 @@ archclean:
143144
prepare: vdso_prepare
144145
vdso_prepare: prepare0
145146
$(Q)$(MAKE) $(build)=arch/arm64/kernel/vdso include/generated/vdso-offsets.h
147+
endif
146148

147149
define archhelp
148150
echo '* Image.gz - Compressed kernel image (arch/$(ARCH)/boot/Image.gz)'

arch/arm64/kernel/crash_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
5858
/**
5959
* elfcorehdr_read - read from ELF core header
6060
* @buf: buffer where the data is placed
61-
* @csize: number of bytes to read
61+
* @count: number of bytes to read
6262
* @ppos: address in the memory
6363
*
6464
* This function reads @count bytes from elf core header which exists

arch/arm64/kernel/probes/kprobes.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@
2323
#include <linux/slab.h>
2424
#include <linux/stop_machine.h>
2525
#include <linux/sched/debug.h>
26+
#include <linux/set_memory.h>
2627
#include <linux/stringify.h>
28+
#include <linux/vmalloc.h>
2729
#include <asm/traps.h>
2830
#include <asm/ptrace.h>
2931
#include <asm/cacheflush.h>
@@ -42,10 +44,21 @@ DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
4244
static void __kprobes
4345
post_kprobe_handler(struct kprobe_ctlblk *, struct pt_regs *);
4446

47+
static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode)
48+
{
49+
void *addrs[1];
50+
u32 insns[1];
51+
52+
addrs[0] = addr;
53+
insns[0] = opcode;
54+
55+
return aarch64_insn_patch_text(addrs, insns, 1);
56+
}
57+
4558
static void __kprobes arch_prepare_ss_slot(struct kprobe *p)
4659
{
4760
/* prepare insn slot */
48-
p->ainsn.api.insn[0] = cpu_to_le32(p->opcode);
61+
patch_text(p->ainsn.api.insn, p->opcode);
4962

5063
flush_icache_range((uintptr_t) (p->ainsn.api.insn),
5164
(uintptr_t) (p->ainsn.api.insn) +
@@ -118,15 +131,15 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
118131
return 0;
119132
}
120133

121-
static int __kprobes patch_text(kprobe_opcode_t *addr, u32 opcode)
134+
void *alloc_insn_page(void)
122135
{
123-
void *addrs[1];
124-
u32 insns[1];
136+
void *page;
125137

126-
addrs[0] = (void *)addr;
127-
insns[0] = (u32)opcode;
138+
page = vmalloc_exec(PAGE_SIZE);
139+
if (page)
140+
set_memory_ro((unsigned long)page, 1);
128141

129-
return aarch64_insn_patch_text(addrs, insns, 1);
142+
return page;
130143
}
131144

132145
/* arm kprobe: install breakpoint in text */

0 commit comments

Comments
 (0)