Skip to contentSkip to conversation

arm64: kprobes: Update blacklist checking on arm64

PATCH Superseded Masami Hiramatsu 5 participants 16 messages Jan 15, 2019 – Feb 12, 2019 arm64

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm64: kprobes: Update blacklist checking on arm64

Hello,

Here is the v2 series of update of the kprobe blacklist checking on arm64.

I found that some blacklist checking code were mis-placed in arch_prepare_kprobe() and arch_within_kprobe_blacklist(). Since the blacklist just filters by symbol, smaller than the symbol, like extable must be checked in arch_prepare_kprobe(). Also, all function (symbol) level check must be done by blacklist.

For arm64, it checks the extable entry address in blacklist and exception/irqentry function in arch_prepare_kprobe(). And, RODATA check is unneeded since kernel/kprobes.c already ensures the probe address is in kernel-text area.

In v2, I updated [1/4]'s description and added James' Reviewed-by. Also, in this version, I added a patch which uses arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that user can see the full list of blacklisted symbols under the debugfs.

Changes in v2:
- [1/4] change description so that it make clear and add James' Reviewed-by.
- [4/4] new patch.

Thank you,

---

Masami Hiramatsu (4):
arm64: kprobes: Move extable address check into arch_prepare_kprobe()
arm64: kprobes: Remove unneeded RODATA check
arm64: kprobes: Move exception_text check in blacklist
arm64: kprobes: Use arch_populate_kprobe_blacklist()

 arch/arm64/kernel/probes/kprobes.c |   49 ++++++++++++++++++------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

--
Masami Hiramatsu (Linaro) <[email protected]>

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#1 lore raw

PATCH v2 1/4 arm64: kprobes: Move extable address check into arch_prepare_kprobe()

Move extable address check into arch_prepare_kprobe() from arch_within_kprobe_blacklist().
The blacklist is exposed via debugfs as a list of symbols. The extable entries are smaller, so must be filtered out by arch_prepare_kprobe().

---
Update in v2:
- Update commit message.
- Add Reviewed-by from James.

---
 arch/arm64/kernel/probes/kprobes.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
arch/arm64/kernel/probes/kprobes.c +5 -2
index 2a5b338b2542..b2d4b7428ebc 100644
@@ -102,6 +102,10 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 
 	if (in_exception_text(probe_addr))
 		return -EINVAL;
+
+	if (search_exception_tables(probe_addr))
+		return -EINVAL;
+
 	if (probe_addr >= (unsigned long) __start_rodata &&
 	    probe_addr <= (unsigned long) __end_rodata)
 		return -EINVAL;
@@ -477,8 +481,7 @@ bool arch_within_kprobe_blacklist(unsigned long addr)
 	    (addr >= (unsigned long)__entry_text_start &&
 	    addr < (unsigned long)__entry_text_end) ||
 	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
-	    !!search_exception_tables(addr))
+	    addr < (unsigned long)__idmap_text_end))
 		return true;
 
 	if (!is_kernel_in_hyp_mode()) {
#2 lore raw

PATCH v2 2/4 arm64: kprobes: Remove unneeded RODATA check

In reply to Masami Hiramatsu

Remove unneeded RODATA check from arch_prepare_kprobe().

Since check_kprobe_address_safe() already ensured that the probe address is in kernel text, we don't need to check whether the address in RODATA or not. That must be always false.

---
 arch/arm64/kernel/probes/kprobes.c |    6 ------
 1 file changed, 6 deletions(-)
arch/arm64/kernel/probes/kprobes.c +0 -6
index b2d4b7428ebc..1dae500d0a81 100644
@@ -91,8 +91,6 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
 	unsigned long probe_addr = (unsigned long)p->addr;
-	extern char __start_rodata[];
-	extern char __end_rodata[];
 
 	if (probe_addr & 0x3)
 		return -EINVAL;
@@ -106,10 +104,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	if (search_exception_tables(probe_addr))
 		return -EINVAL;
 
-	if (probe_addr >= (unsigned long) __start_rodata &&
-	    probe_addr <= (unsigned long) __end_rodata)
-		return -EINVAL;
-
 	/* decode instruction */
 	switch (arm_kprobe_decode_insn(p->addr, &p->ainsn)) {
 	case INSN_REJECTED:	/* insn not supported */
#4 lore raw

PATCH v2 3/4 arm64: kprobes: Move exception_text check in blacklist

In reply to Masami Hiramatsu

Move exception/irqentry text address check in blacklist, since those are symbol based rejection.

If we prohibit probing on the symbols in exception_text, those should be blacklisted.

---
 arch/arm64/kernel/probes/kprobes.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm64/kernel/probes/kprobes.c +2 -4
index 1dae500d0a81..b9e9758b6534 100644
@@ -98,9 +98,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	/* copy instruction */
 	p->opcode = le32_to_cpu(*p->addr);
 
-	if (in_exception_text(probe_addr))
-		return -EINVAL;
-
 	if (search_exception_tables(probe_addr))
 		return -EINVAL;
 
@@ -475,7 +472,8 @@ bool arch_within_kprobe_blacklist(unsigned long addr)
 	    (addr >= (unsigned long)__entry_text_start &&
 	    addr < (unsigned long)__entry_text_end) ||
 	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end))
+	    addr < (unsigned long)__idmap_text_end) ||
+	    in_exception_text(addr))
 		return true;
 
 	if (!is_kernel_in_hyp_mode()) {
#6 lore raw

PATCH v2 4/4 arm64: kprobes: Use arch_populate_kprobe_blacklist()

In reply to Masami Hiramatsu

Use arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that we can see the full blacklisted symbols under the debugfs.

---
 arch/arm64/kernel/probes/kprobes.c |   42 ++++++++++++++++++++----------------
 1 file changed, 23 insertions(+), 19 deletions(-)
arch/arm64/kernel/probes/kprobes.c +23 -19
index b9e9758b6534..6c066c34c8a4 100644
@@ -465,26 +465,30 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
 	return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)
+int __init arch_populate_kprobe_blacklist(void)
 {
-	if ((addr >= (unsigned long)__kprobes_text_start &&
-	    addr < (unsigned long)__kprobes_text_end) ||
-	    (addr >= (unsigned long)__entry_text_start &&
-	    addr < (unsigned long)__entry_text_end) ||
-	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
-	    in_exception_text(addr))
-		return true;
-
-	if (!is_kernel_in_hyp_mode()) {
-		if ((addr >= (unsigned long)__hyp_text_start &&
-		    addr < (unsigned long)__hyp_text_end) ||
-		    (addr >= (unsigned long)__hyp_idmap_text_start &&
-		    addr < (unsigned long)__hyp_idmap_text_end))
-			return true;
-	}
-
-	return false;
+	int ret;
+
+	ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
+					(unsigned long)__kprobes_text_end);
+	if (ret)
+		return ret;
+	ret = kprobe_add_area_blacklist((unsigned long)__entry_text_start,
+					(unsigned long)__entry_text_end);
+	if (ret)
+		return ret;
+	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
+					(unsigned long)__idmap_text_end);
+	if (ret || is_kernel_in_hyp_mode())
+		return ret;
+
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
+					(unsigned long)__hyp_text_end);
+	if (ret)
+		return ret;
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_idmap_text_start,
+					(unsigned long)__hyp_idmap_text_end);
+	return ret;
 }
 
 void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
reviewer Reviewed-by on v2 2/4
#3 lore raw

Re: [PATCH v2 2/4] arm64: kprobes: Remove unneeded RODATA check

In reply to Masami Hiramatsu
Quoted 8 lines · Masami Hiramatsu

Remove unneeded RODATA check from arch_prepare_kprobe().

Since check_kprobe_address_safe() already ensured that the probe address is in kernel text, we don't need to check whether the address in RODATA or not. That must be always false.

Mark.

Quoted 29 lines
---
 arch/arm64/kernel/probes/kprobes.c |    6 ------
 1 file changed, 6 deletions(-)
arch/arm64/kernel/probes/kprobes.c +0 -6
index b2d4b7428ebc..1dae500d0a81 100644
@@ -91,8 +91,6 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
 int __kprobes arch_prepare_kprobe(struct kprobe *p)
 {
 	unsigned long probe_addr = (unsigned long)p->addr;
-	extern char __start_rodata[];
-	extern char __end_rodata[];
 
 	if (probe_addr & 0x3)
 		return -EINVAL;
@@ -106,10 +104,6 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
 	if (search_exception_tables(probe_addr))
 		return -EINVAL;
 
-	if (probe_addr >= (unsigned long) __start_rodata &&
-	    probe_addr <= (unsigned long) __end_rodata)
-		return -EINVAL;
-
 	/* decode instruction */
 	switch (arm_kprobe_decode_insn(p->addr, &p->ainsn)) {
 	case INSN_REJECTED:	/* insn not supported */
#14 lore raw
In reply to Masami Hiramatsu

Hi Masami,

Quoted 16 lines · Masami Hiramatsu

Hello,

Here is the v2 series of update of the kprobe blacklist checking on arm64.

I found that some blacklist checking code were mis-placed in arch_prepare_kprobe() and arch_within_kprobe_blacklist(). Since the blacklist just filters by symbol, smaller than the symbol, like extable must be checked in arch_prepare_kprobe(). Also, all function (symbol) level check must be done by blacklist.

For arm64, it checks the extable entry address in blacklist and exception/irqentry function in arch_prepare_kprobe(). And, RODATA check is unneeded since kernel/kprobes.c already ensures the probe address is in kernel-text area.

Quoted 5 lines

In v2, I updated [1/4]'s description and added James' Reviewed-by. Also, in this version, I added a patch which uses arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that user can see the full list of blacklisted symbols under the debugfs.

Assuming these are targetting the arm64 tree, are you intending to get them merged for 5.0?

Will

#15 lore raw

Hi Will,

Quoted 19 lines · On Wed, 16 Jan 2019 13:40:07 +0000 Will Deacon <[email protected]> wrote:

Hi Masami,

Quoted 16 lines · Masami Hiramatsu

Hello,

Here is the v2 series of update of the kprobe blacklist checking on arm64.

I found that some blacklist checking code were mis-placed in arch_prepare_kprobe() and arch_within_kprobe_blacklist(). Since the blacklist just filters by symbol, smaller than the symbol, like extable must be checked in arch_prepare_kprobe(). Also, all function (symbol) level check must be done by blacklist.

For arm64, it checks the extable entry address in blacklist and exception/irqentry function in arch_prepare_kprobe(). And, RODATA check is unneeded since kernel/kprobes.c already ensures the probe address is in kernel-text area.

Quoted 8 lines
Quoted 5 lines

In v2, I updated [1/4]'s description and added James' Reviewed-by. Also, in this version, I added a patch which uses arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that user can see the full list of blacklisted symbols under the debugfs.

Assuming these are targetting the arm64 tree, are you intending to get them merged for 5.0?

No, I don't rush it, since these are not bugfix but just enhancements. (User can see the blacklisted symbols precisely) If you think you are easy to pick this to arm64/next, it is OK to me.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
Reviewed-by on v2 3/4
#5 lore raw

Re: [PATCH v2 3/4] arm64: kprobes: Move exception_text check in blacklist

In reply to Masami Hiramatsu

Hi,

Quoted 5 lines · Masami Hiramatsu

Move exception/irqentry text address check in blacklist, since those are symbol based rejection.

If we prohibit probing on the symbols in exception_text, those should be blacklisted.

We need to blacklist this as its where do_debug_exception() lives, which kprobes depends on for single-stepping.

Thanks!

James

#7 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

In reply to Masami Hiramatsu

Hello,

Quoted 12 lines · Masami Hiramatsu

Use arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that we can see the full blacklisted symbols under the debugfs.

arch/arm64/kernel/probes/kprobes.c +0 -1
index b9e9758b6534..6c066c34c8a4 100644
@@ -465,26 +465,30 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
 	return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 477

Quoted 10 lines
arch/arm64/kernel/probes/kprobes.c +1 -7
+int __init arch_populate_kprobe_blacklist(void)
 {
-	if ((addr >= (unsigned long)__kprobes_text_start &&
-	    addr < (unsigned long)__kprobes_text_end) ||
-	    (addr >= (unsigned long)__entry_text_start &&
-	    addr < (unsigned long)__entry_text_end) ||
-	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
 
-	    in_exception_text(addr))

You added this one in the previous patch, but it disappears here.

Quoted 8 lines
arch/arm64/kernel/probes/kprobes.c +0 -8
-		return true;
-
-	if (!is_kernel_in_hyp_mode()) {
-		if ((addr >= (unsigned long)__hyp_text_start &&
-		    addr < (unsigned long)__hyp_text_end) ||
-		    (addr >= (unsigned long)__hyp_idmap_text_start &&
-		    addr < (unsigned long)__hyp_idmap_text_end))
-			return true;

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)

Quoted 10 lines
arch/arm64/kernel/probes/kprobes.c +5 -3
-	}
-
-	return false;
+	int ret;
 
 
+	ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
+					(unsigned long)__kprobes_text_end);
+	if (ret)
+		return ret;

Now that we have arch_populate_kprobe_blacklist(), does the arch-code need to blacklist the kprobes section itself?

The weak arch_within_kprobe_blacklist() will test it at kprobe-load time, and populate_kprobe_blacklist() adds it to the list before it calls arch_populate_kprobe_blacklist().

Won't this result in duplicate entries?

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)

Quoted 10 lines
arch/arm64/kernel/probes/kprobes.c +8 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__entry_text_start,
+					(unsigned long)__entry_text_end);
+	if (ret)
+		return ret;
 
+	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
+					(unsigned long)__idmap_text_end);
 
+	if (ret || is_kernel_in_hyp_mode())
+		return ret;

Hmmm, I think we have a bug here today.

This is saying we can kprobe KVM when we have VHE, because all of KVMs code runs at the same exception-level as the kernel. Which is true...
But KVM switches VBAR_EL1, so if we run over one of kprobes BRK instructions, we're going to hyp-panic, because KVM doesn't handle synchronous exceptions from EL2.

The __hyp_text also contains the guest entry/exit code, which we mustn't probe, even on VHE.

I think we should always blacklist the __hyp_text, and KVM should mark its vhe-only functions with __kprobes. I'll post patches for this.

Thanks,

James

Quoted 11 lines
arch/arm64/kernel/probes/kprobes.c +7 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
+					(unsigned long)__hyp_text_end);
+	if (ret)
+		return ret;
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_idmap_text_start,
+					(unsigned long)__hyp_idmap_text_end);
+	return ret;
 }
 
 void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
#8 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

Quoted 24 lines · On Mon, 21 Jan 2019 12:20:07 +0000 James Morse <[email protected]> wrote:

Hello,

Quoted 20 lines · Masami Hiramatsu

Use arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that we can see the full blacklisted symbols under the debugfs.

arch/arm64/kernel/probes/kprobes.c +1 -7
index b9e9758b6534..6c066c34c8a4 100644
@@ -465,26 +465,30 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
 	return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)
+int __init arch_populate_kprobe_blacklist(void)
 {
-	if ((addr >= (unsigned long)__kprobes_text_start &&
-	    addr < (unsigned long)__kprobes_text_end) ||
-	    (addr >= (unsigned long)__entry_text_start &&
-	    addr < (unsigned long)__entry_text_end) ||
-	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
Quoted 3 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 476

Quoted 1 line
arch/arm64/kernel/probes/kprobes.c +0 -1
-	    in_exception_text(addr))

You added this one in the previous patch, but it disappears here.

Yes, it is easy to explain how we transcribe from arch_within_kprobe_blacklist() to arch_populate_kprobe_blacklist().

Quoted 16 lines
Quoted 14 lines
arch/arm64/kernel/probes/kprobes.c +1 -11
-		return true;
-
-	if (!is_kernel_in_hyp_mode()) {
-		if ((addr >= (unsigned long)__hyp_text_start &&
-		    addr < (unsigned long)__hyp_text_end) ||
-		    (addr >= (unsigned long)__hyp_idmap_text_start &&
-		    addr < (unsigned long)__hyp_idmap_text_end))
-			return true;
-	}
-
-	return false;
+	int ret;
Quoted 7 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 475

Quoted 4 lines
arch/arm64/kernel/probes/kprobes.c +4 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
+					(unsigned long)__kprobes_text_end);
+	if (ret)
+		return ret;

Now that we have arch_populate_kprobe_blacklist(), does the arch-code need to blacklist the kprobes section itself?

Ah, good catch! No, we don't need it here. Sorry I worked on older patch. I'll update it.

Quoted 5 lines

The weak arch_within_kprobe_blacklist() will test it at kprobe-load time, and populate_kprobe_blacklist() adds it to the list before it calls arch_populate_kprobe_blacklist().

Won't this result in duplicate entries?

yes, so it should not.

Quoted 7 lines
Quoted 6 lines
arch/arm64/kernel/probes/kprobes.c +4 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__entry_text_start,
+					(unsigned long)__entry_text_end);
+	if (ret)
+		return ret;
Quoted 8 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)

Quoted 5 lines
arch/arm64/kernel/probes/kprobes.c +4 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
+					(unsigned long)__idmap_text_end);
 
+	if (ret || is_kernel_in_hyp_mode())
+		return ret;

Hmmm, I think we have a bug here today.

OK.

Quoted 9 lines

This is saying we can kprobe KVM when we have VHE, because all of KVMs code runs at the same exception-level as the kernel. Which is true...
But KVM switches VBAR_EL1, so if we run over one of kprobes BRK instructions, we're going to hyp-panic, because KVM doesn't handle synchronous exceptions from EL2.

The __hyp_text also contains the guest entry/exit code, which we mustn't probe, even on VHE.

Hmm, I'm not sure when the original code decided this. But it sounds reasonable.

Quoted 3 lines

I think we should always blacklist the __hyp_text, and KVM should mark its vhe-only functions with __kprobes. I'll post patches for this.

OK, then I should wait for that, because this series is a kind of improvement. But your's is a bugfix, that should be backported to stable.

Thank you,

Quoted 19 lines

Thanks,

James

Quoted 11 lines
arch/arm64/kernel/probes/kprobes.c +7 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
+					(unsigned long)__hyp_text_end);
+	if (ret)
+		return ret;
+	ret = kprobe_add_area_blacklist((unsigned long)__hyp_idmap_text_start,
+					(unsigned long)__hyp_idmap_text_end);
+	return ret;
 }
 
 void __kprobes __used *trampoline_probe_handler(struct pt_regs *regs)
Signature · 1 line
Masami Hiramatsu <[email protected]>
#9 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

Hi Masami,

Quoted 55 lines · Masami Hiramatsu
Quoted 22 lines · On Mon, 21 Jan 2019 12:20:07 +0000 James Morse <[email protected]> wrote:
Quoted 20 lines · Masami Hiramatsu

Use arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that we can see the full blacklisted symbols under the debugfs.

arch/arm64/kernel/probes/kprobes.c +1 -7
index b9e9758b6534..6c066c34c8a4 100644
@@ -465,26 +465,30 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
 	return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)
+int __init arch_populate_kprobe_blacklist(void)
 {
-	if ((addr >= (unsigned long)__kprobes_text_start &&
-	    addr < (unsigned long)__kprobes_text_end) ||
-	    (addr >= (unsigned long)__entry_text_start &&
-	    addr < (unsigned long)__entry_text_end) ||
-	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
Quoted 3 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 476

Quoted 1 line
arch/arm64/kernel/probes/kprobes.c +0 -1
-	    in_exception_text(addr))

You added this one in the previous patch, but it disappears here.

Yes, it is easy to explain how we transcribe from arch_within_kprobe_blacklist() to arch_populate_kprobe_blacklist().

Quoted 16 lines
Quoted 14 lines
arch/arm64/kernel/probes/kprobes.c +1 -11
-		return true;
-
-	if (!is_kernel_in_hyp_mode()) {
-		if ((addr >= (unsigned long)__hyp_text_start &&
-		    addr < (unsigned long)__hyp_text_end) ||
-		    (addr >= (unsigned long)__hyp_idmap_text_start &&
-		    addr < (unsigned long)__hyp_idmap_text_end))
-			return true;
-	}
-
-	return false;
+	int ret;
Quoted 7 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 475

Quoted 4 lines
arch/arm64/kernel/probes/kprobes.c +4 -0
+	ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
+					(unsigned long)__kprobes_text_end);
+	if (ret)
+		return ret;

Now that we have arch_populate_kprobe_blacklist(), does the arch-code need to blacklist the kprobes section itself?

Quoted 2 lines

Ah, good catch! No, we don't need it here. Sorry I worked on older patch. I'll update it.

Did you send a new version of this series? I can't seem to spot it in my inbox.

Cheers,

Will

#10 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

Quoted 58 lines · On Fri, 8 Feb 2019 09:15:19 +0000 Will Deacon <[email protected]> wrote:

Hi Masami,

Quoted 55 lines · Masami Hiramatsu
Quoted 22 lines · On Mon, 21 Jan 2019 12:20:07 +0000 James Morse <[email protected]> wrote:
Quoted 20 lines · Masami Hiramatsu

Use arch_populate_kprobe_blacklist() instead of arch_within_kprobe_blacklist() so that we can see the full blacklisted symbols under the debugfs.

arch/arm64/kernel/probes/kprobes.c +1 -7
index b9e9758b6534..6c066c34c8a4 100644
@@ -465,26 +465,30 @@ kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)
 	return DBG_HOOK_HANDLED;
 }
 
-bool arch_within_kprobe_blacklist(unsigned long addr)
+int __init arch_populate_kprobe_blacklist(void)
 {
-	if ((addr >= (unsigned long)__kprobes_text_start &&
-	    addr < (unsigned long)__kprobes_text_end) ||
-	    (addr >= (unsigned long)__entry_text_start &&
-	    addr < (unsigned long)__entry_text_end) ||
-	    (addr >= (unsigned long)__idmap_text_start &&
-	    addr < (unsigned long)__idmap_text_end) ||
Quoted 3 lines

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr) · line 476

Quoted 1 line
arch/arm64/kernel/probes/kprobes.c +0 -1
-	    in_exception_text(addr))

You added this one in the previous patch, but it disappears here.

Yes, it is easy to explain how we transcribe from arch_within_kprobe_blacklist() to arch_populate_kprobe_blacklist().

Quoted 23 lines
Quoted 10 lines
arch/arm64/kernel/probes/kprobes.c +0 -8
-		return true;
-
-	if (!is_kernel_in_hyp_mode()) {
-		if ((addr >= (unsigned long)__hyp_text_start &&
-		    addr < (unsigned long)__hyp_text_end) ||
-		    (addr >= (unsigned long)__hyp_idmap_text_start &&
-		    addr < (unsigned long)__hyp_idmap_text_end))
-			return true;

arch/arm64/kernel/probes/kprobes.c kprobe_breakpoint_handler(struct pt_regs *regs, unsigned int esr)

Quoted 10 lines
arch/arm64/kernel/probes/kprobes.c +5 -3
-	}
-
-	return false;
+	int ret;
 
 
+	ret = kprobe_add_area_blacklist((unsigned long)__kprobes_text_start,
+					(unsigned long)__kprobes_text_end);
+	if (ret)
+		return ret;

Now that we have arch_populate_kprobe_blacklist(), does the arch-code need to blacklist the kprobes section itself?

Quoted 5 lines
Quoted 2 lines

Ah, good catch! No, we don't need it here. Sorry I worked on older patch. I'll update it.

Did you send a new version of this series? I can't seem to spot it in my inbox.

Ah, OK. I just waited for James' patch series,

https://patchwork.kernel.org/cover/10779489/

Are those merged? I'd like to move this series on that.

Thank you for ping! :)

Signature · 1 line
Masami Hiramatsu <[email protected]>
#11 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

[+Marc]

Quoted 10 lines · Masami Hiramatsu
Quoted 2 lines · On Fri, 8 Feb 2019 09:15:19 +0000 Will Deacon <[email protected]> wrote:

Did you send a new version of this series? I can't seem to spot it in my inbox.

Ah, OK. I just waited for James' patch series,

https://patchwork.kernel.org/cover/10779489/

Are those merged? I'd like to move this series on that.

Patches 2-4 are in mainline:

f7daa9c8fd19 arm64: hibernate: Clean the __hyp_text to PoC after resume 8fac5cbdfe0f arm64: hyp-stub: Forbid kprobing of the hyp-stub f2b3d8566d81 arm64: kprobe: Always blacklist the KVM world-switch code

Patch 1 is queued via kvm-arm (also for 5.0) but it doesn't seem to have landed yet.

Will

#12 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

Quoted 14 lines · Will Deacon

[+Marc]

Quoted 10 lines · Masami Hiramatsu
Quoted 2 lines · On Fri, 8 Feb 2019 09:15:19 +0000 Will Deacon <[email protected]> wrote:

Did you send a new version of this series? I can't seem to spot it in my inbox.

Ah, OK. I just waited for James' patch series,

https://patchwork.kernel.org/cover/10779489/

Are those merged? I'd like to move this series on that.

Quoted 8 lines

Patches 2-4 are in mainline:

f7daa9c8fd19 arm64: hibernate: Clean the __hyp_text to PoC after resume 8fac5cbdfe0f arm64: hyp-stub: Forbid kprobing of the hyp-stub f2b3d8566d81 arm64: kprobe: Always blacklist the KVM world-switch code

Patch 1 is queued via kvm-arm (also for 5.0) but it doesn't seem to have landed yet.

It was part of the pull request sent on Thursday[1], but Paolo hasn't pulled it yet.

Hopefully soon...

	M.

[1] https://patchwork.kernel.org/patch/10801151/

Signature · 6 lines
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#13 lore raw

Re: [PATCH v2 4/4] arm64: kprobes: Use arch_populate_kprobe_blacklist()

Quoted 21 lines · On Mon, 11 Feb 2019 16:05:17 +0000 Marc Zyngier <[email protected]> wrote:
Quoted 20 lines · Will Deacon

[+Marc]

Quoted 10 lines · Masami Hiramatsu
Quoted 2 lines · On Fri, 8 Feb 2019 09:15:19 +0000 Will Deacon <[email protected]> wrote:

Did you send a new version of this series? I can't seem to spot it in my inbox.

Ah, OK. I just waited for James' patch series,

https://patchwork.kernel.org/cover/10779489/

Are those merged? I'd like to move this series on that.

Patches 2-4 are in mainline:

f7daa9c8fd19 arm64: hibernate: Clean the __hyp_text to PoC after resume 8fac5cbdfe0f arm64: hyp-stub: Forbid kprobing of the hyp-stub f2b3d8566d81 arm64: kprobe: Always blacklist the KVM world-switch code

Quoted 7 lines
Quoted 2 lines

Patch 1 is queued via kvm-arm (also for 5.0) but it doesn't seem to have landed yet.

It was part of the pull request sent on Thursday[1], but Paolo hasn't pulled it yet.

Hopefully soon...

OK, then I'll send updated series since Patch1 is independent from this series.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>