Skip to contentSkip to conversation

arm64: kprobes: Drop ID map text from kprobes blacklist

PATCH In review Ard Biesheuvel 4 participants 4 messages Feb 4, 2023 – Feb 7, 2023 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: kprobes: Drop ID map text from kprobes blacklist

The ID mapped text region is never accessed via the normal kernel mapping of text, and so it was moved into .rodata instead. This means it is no longer considered as a suitable place for kprobes by default, and the explicit blacklist is unnecessary, and actually results in an error message at boot:

kprobes: Failed to populate blacklist (error -22), kprobes not restricted, be careful using them!

So stop blacklisting the ID map text explicitly.

Fixes af7249b317e4d0b3d ("arm64: kernel: move identity map out of .text mapping")
---
 arch/arm64/kernel/probes/kprobes.c | 4 ----
 1 file changed, 4 deletions(-)
arch/arm64/kernel/probes/kprobes.c +0 -4
index f35d059a9a366fa6..70b91a8c6bb3f358 100644
@@ -387,10 +387,6 @@ int __init arch_populate_kprobe_blacklist(void)
 					(unsigned long)__irqentry_text_end);
 	if (ret)
 		return ret;
-	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
-					(unsigned long)__idmap_text_end);
-	if (ret)
-		return ret;
 	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
 					(unsigned long)__hyp_text_end);
 	if (ret || is_kernel_in_hyp_mode())
Signature · 7 lines
2.39.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Tested-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ard Biesheuvel

The ID mapped text region is never accessed via the normal kernel mapping of text, and so it was moved into .rodata instead. This means it is no longer considered as a suitable place for kprobes by default, and the explicit blacklist is unnecessary, and actually results in an error message at boot:

Quoted 7 lines

kprobes: Failed to populate blacklist (error -22), kprobes not restricted, be careful using them!

So stop blacklisting the ID map text explicitly.

Fixes af7249b317e4d0b3d ("arm64: kernel: move identity map out of .text mapping")

Thank you for the quick fix!

Quoted 22 lines
---
 arch/arm64/kernel/probes/kprobes.c | 4 ----
 1 file changed, 4 deletions(-)
arch/arm64/kernel/probes/kprobes.c +0 -4
index f35d059a9a366fa6..70b91a8c6bb3f358 100644
@@ -387,10 +387,6 @@ int __init arch_populate_kprobe_blacklist(void)
 					(unsigned long)__irqentry_text_end);
 	if (ret)
 		return ret;
-	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
-					(unsigned long)__idmap_text_end);
-	if (ret)
-		return ret;
 	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
 					(unsigned long)__hyp_text_end);
 	if (ret || is_kernel_in_hyp_mode())
Signature · 1 line
2.39.1

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

reviewer Acked-by on v1 1/1
#2 lore raw
In reply to Ard Biesheuvel
Quoted 6 lines · Ard Biesheuvel

The ID mapped text region is never accessed via the normal kernel mapping of text, and so it was moved into .rodata instead. This means it is no longer considered as a suitable place for kprobes by default, and the explicit blacklist is unnecessary, and actually results in an error message at boot:

Quoted 7 lines

kprobes: Failed to populate blacklist (error -22), kprobes not restricted, be careful using them!

So stop blacklisting the ID map text explicitly.

Fixes af7249b317e4d0b3d ("arm64: kernel: move identity map out of .text mapping")

Mark.

Quoted 27 lines
---
 arch/arm64/kernel/probes/kprobes.c | 4 ----
 1 file changed, 4 deletions(-)
arch/arm64/kernel/probes/kprobes.c +0 -4
index f35d059a9a366fa6..70b91a8c6bb3f358 100644
@@ -387,10 +387,6 @@ int __init arch_populate_kprobe_blacklist(void)
 					(unsigned long)__irqentry_text_end);
 	if (ret)
 		return ret;
-	ret = kprobe_add_area_blacklist((unsigned long)__idmap_text_start,
-					(unsigned long)__idmap_text_end);
-	if (ret)
-		return ret;
 	ret = kprobe_add_area_blacklist((unsigned long)__hyp_text_start,
 					(unsigned long)__hyp_text_end);
 	if (ret || is_kernel_in_hyp_mode())
Signature · 7 lines
2.39.1


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

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

maintainer
#3 lore raw
In reply to Ard Biesheuvel
Quoted 9 lines · Ard Biesheuvel

The ID mapped text region is never accessed via the normal kernel mapping of text, and so it was moved into .rodata instead. This means it is no longer considered as a suitable place for kprobes by default, and the explicit blacklist is unnecessary, and actually results in an error message at boot:

kprobes: Failed to populate blacklist (error -22), kprobes not restricted, be careful using them!

[...]

Applied to arm64 (for-next/efi-boot-mmu-on), thanks!

[1/1] arm64: kprobes: Drop ID map text from kprobes blacklist

      https://git.kernel.org/arm64/c/a088cf8eee12
Signature · 7 lines
Catalin


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