Skip to contentSkip to conversation

jump_label/static_call/kprobes: *_text_reserved() fixes

PATCH Applied Peter Zijlstra 3 participants 16 messages Jun 28, 2021 – Jul 5, 2021

Subsystems (2)
lore
Share & tools
lore

Peter Zijlstra

author maintainer
#0 lore raw

cover jump_label/static_call/kprobes: *_text_reserved() fixes

Hi,

3 little pigs^Wfixes for kprobes on dynamic text.

author maintainer
#1 lore raw

PATCH 1/3 jump_label: Fix jump_label_text_reserved() vs __init

It turns out that jump_label_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

For a long time, this resulted in, at worst, not being able to kprobe text that happened to land at the re-used address. However a recent commit e7bf1ba97afd ("jump_label, x86: Emit short JMP") made it a fatal mistake because it now needs to read the instruction in order to determine the conflict -- an instruction that's no longer there.

Fixes 4c3ef6d79328 ("jump label: Add jump_label_text_reserved() to reserve jump points")
---
 kernel/jump_label.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/jump_label.c +8 -5
@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_ent
 }
 
 static int __jump_label_text_reserved(struct jump_entry *iter_start,
-		struct jump_entry *iter_stop, void *start, void *end)
+		struct jump_entry *iter_stop, void *start, void *end, bool init)
 {
 	struct jump_entry *iter;
 
 	iter = iter_start;
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !jump_entry_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -561,7 +563,7 @@ static int __jump_label_mod_text_reserve
 
 	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
-				start, end);
+				start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -786,8 +788,9 @@ early_initcall(jump_label_init_module);
  */
 int jump_label_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __jump_label_text_reserved(__start___jump_table,
-			__stop___jump_table, start, end);
+			__stop___jump_table, start, end, init);
 
 	if (ret)
 		return ret;
maintainer Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] jump_label: Fix jump_label_text_reserved() vs __init

Quoted 10 lines · On Mon, 28 Jun 2021 13:24:10 +0200 Peter Zijlstra <[email protected]> wrote:

It turns out that jump_label_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

For a long time, this resulted in, at worst, not being able to kprobe text that happened to land at the re-used address. However a recent commit e7bf1ba97afd ("jump_label, x86: Emit short JMP") made it a fatal mistake because it now needs to read the instruction in order to determine the conflict -- an instruction that's no longer there.

Quoted 3 lines
Fixes 4c3ef6d79328 ("jump label: Add jump_label_text_reserved() to reserve jump points")

Looks good to me.

Thank you,

Quoted 48 lines
---
 kernel/jump_label.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/jump_label.c +8 -5
@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_ent
 }
 
 static int __jump_label_text_reserved(struct jump_entry *iter_start,
-		struct jump_entry *iter_stop, void *start, void *end)
+		struct jump_entry *iter_stop, void *start, void *end, bool init)
 {
 	struct jump_entry *iter;
 
 	iter = iter_start;
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !jump_entry_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -561,7 +563,7 @@ static int __jump_label_mod_text_reserve
 
 	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
-				start, end);
+				start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -786,8 +788,9 @@ early_initcall(jump_label_init_module);
  */
 int jump_label_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __jump_label_text_reserved(__start___jump_table,
-			__stop___jump_table, start, end);
+			__stop___jump_table, start, end, init);
 
 	if (ret)
 		return ret;
Signature · 1 line
Masami Hiramatsu <[email protected]>
merge bot Applied
#3 lore raw

[tip: locking/urgent] jump_label: Fix jump_label_text_reserved() vs __init

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     b1487a958a6dd1f39f6ccd97c915bf132535cd1a
Gitweb:        https://git.kernel.org/tip/b1487a958a6dd1f39f6ccd97c915bf132535cd1a
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:10 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 02 Jul 2021 15:58:26 +02:00

jump_label: Fix jump_label_text_reserved() vs __init

It turns out that jump_label_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

For a long time, this resulted in, at worst, not being able to kprobe text that happened to land at the re-used address. However a recent commit e7bf1ba97afd ("jump_label, x86: Emit short JMP") made it a fatal mistake because it now needs to read the instruction in order to determine the conflict -- an instruction that's no longer there.

Fixes 4c3ef6d79328 ("jump label: Add jump_label_text_reserved() to reserve jump points")
---
 kernel/jump_label.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/jump_label.c +8 -5
index bdb0681..b156e15 100644
@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
 }
 
 static int __jump_label_text_reserved(struct jump_entry *iter_start,
-		struct jump_entry *iter_stop, void *start, void *end)
+		struct jump_entry *iter_stop, void *start, void *end, bool init)
 {
 	struct jump_entry *iter;
 
 	iter = iter_start;
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !jump_entry_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -562,7 +564,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
 
 	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
-				start, end);
+				start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -788,8 +790,9 @@ early_initcall(jump_label_init_module);
  */
 int jump_label_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __jump_label_text_reserved(__start___jump_table,
-			__stop___jump_table, start, end);
+			__stop___jump_table, start, end, init);
 
 	if (ret)
 		return ret;
merge bot Applied
#4 lore raw

[tip: locking/urgent] jump_label: Fix jump_label_text_reserved() vs __init

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     9e667624c291753b8a5128f620f493d0b5226063
Gitweb:        https://git.kernel.org/tip/9e667624c291753b8a5128f620f493d0b5226063
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:10 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Mon, 05 Jul 2021 10:46:20 +02:00

jump_label: Fix jump_label_text_reserved() vs __init

It turns out that jump_label_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

For a long time, this resulted in, at worst, not being able to kprobe text that happened to land at the re-used address. However a recent commit e7bf1ba97afd ("jump_label, x86: Emit short JMP") made it a fatal mistake because it now needs to read the instruction in order to determine the conflict -- an instruction that's no longer there.

Fixes 4c3ef6d79328 ("jump label: Add jump_label_text_reserved() to reserve jump points")
---
 kernel/jump_label.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/jump_label.c +8 -5
index bdb0681..b156e15 100644
@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
 }
 
 static int __jump_label_text_reserved(struct jump_entry *iter_start,
-		struct jump_entry *iter_stop, void *start, void *end)
+		struct jump_entry *iter_stop, void *start, void *end, bool init)
 {
 	struct jump_entry *iter;
 
 	iter = iter_start;
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !jump_entry_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -562,7 +564,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
 
 	ret = __jump_label_text_reserved(mod->jump_entries,
 				mod->jump_entries + mod->num_jump_entries,
-				start, end);
+				start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -788,8 +790,9 @@ early_initcall(jump_label_init_module);
  */
 int jump_label_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __jump_label_text_reserved(__start___jump_table,
-			__stop___jump_table, start, end);
+			__stop___jump_table, start, end, init);
 
 	if (ret)
 		return ret;
author maintainer
#5 lore raw

PATCH 2/3 static_call: Fix static_call_text_reserved() vs __init

In reply to Peter Zijlstra

It turns out that static_call_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")
---
 kernel/static_call.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/static_call.c +8 -5
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_c
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
 				       struct static_call_site *iter_stop,
-				       void *start, void *end)
+				       void *start, void *end, bool init)
 {
 	struct static_call_site *iter = iter_start;
 
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !static_call_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserv
 
 	ret = __static_call_text_reserved(mod->static_call_sites,
 			mod->static_call_sites + mod->num_static_call_sites,
-			start, end);
+			start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text
 
 int static_call_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __static_call_text_reserved(__start_static_call_sites,
-			__stop_static_call_sites, start, end);
+			__stop_static_call_sites, start, end, init);
 
 	if (ret)
 		return ret;
maintainer Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] static_call: Fix static_call_text_reserved() vs __init

Quoted 8 lines · On Mon, 28 Jun 2021 13:24:11 +0200 Peter Zijlstra <[email protected]> wrote:

It turns out that static_call_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")

This looks good to me.

Thank you,

Quoted 47 lines
---
 kernel/static_call.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/static_call.c +8 -5
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_c
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
 				       struct static_call_site *iter_stop,
-				       void *start, void *end)
+				       void *start, void *end, bool init)
 {
 	struct static_call_site *iter = iter_start;
 
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !static_call_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserv
 
 	ret = __static_call_text_reserved(mod->static_call_sites,
 			mod->static_call_sites + mod->num_static_call_sites,
-			start, end);
+			start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text
 
 int static_call_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __static_call_text_reserved(__start_static_call_sites,
-			__stop_static_call_sites, start, end);
+			__stop_static_call_sites, start, end, init);
 
 	if (ret)
 		return ret;
Signature · 1 line
Masami Hiramatsu <[email protected]>
merge bot Applied
#7 lore raw

[tip: locking/urgent] static_call: Fix static_call_text_reserved() vs __init

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     8e62ef8c9922d7deaa2d92dc30a87ba6f81fdee3
Gitweb:        https://git.kernel.org/tip/8e62ef8c9922d7deaa2d92dc30a87ba6f81fdee3
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:11 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 02 Jul 2021 15:58:27 +02:00

static_call: Fix static_call_text_reserved() vs __init

It turns out that static_call_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")
---
 kernel/static_call.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/static_call.c +8 -5
index 723fcc9..43ba0b1 100644
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
 				       struct static_call_site *iter_stop,
-				       void *start, void *end)
+				       void *start, void *end, bool init)
 {
 	struct static_call_site *iter = iter_start;
 
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !static_call_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
 
 	ret = __static_call_text_reserved(mod->static_call_sites,
 			mod->static_call_sites + mod->num_static_call_sites,
-			start, end);
+			start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
 
 int static_call_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __static_call_text_reserved(__start_static_call_sites,
-			__stop_static_call_sites, start, end);
+			__stop_static_call_sites, start, end, init);
 
 	if (ret)
 		return ret;
merge bot Applied
#8 lore raw

[tip: locking/urgent] static_call: Fix static_call_text_reserved() vs __init

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     2bee6d16e4379326b1eea454e68c98b17456769e
Gitweb:        https://git.kernel.org/tip/2bee6d16e4379326b1eea454e68c98b17456769e
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:11 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Mon, 05 Jul 2021 10:46:33 +02:00

static_call: Fix static_call_text_reserved() vs __init

It turns out that static_call_text_reserved() was reporting __init text as being reserved past the time when the __init text was freed and re-used.

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")
---
 kernel/static_call.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
kernel/static_call.c +8 -5
index 723fcc9..43ba0b1 100644
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
 
 static int __static_call_text_reserved(struct static_call_site *iter_start,
 				       struct static_call_site *iter_stop,
-				       void *start, void *end)
+				       void *start, void *end, bool init)
 {
 	struct static_call_site *iter = iter_start;
 
 	while (iter < iter_stop) {
-		if (addr_conflict(iter, start, end))
-			return 1;
+		if (init || !static_call_is_init(iter)) {
+			if (addr_conflict(iter, start, end))
+				return 1;
+		}
 		iter++;
 	}
 
@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
 
 	ret = __static_call_text_reserved(mod->static_call_sites,
 			mod->static_call_sites + mod->num_static_call_sites,
-			start, end);
+			start, end, mod->state == MODULE_STATE_COMING);
 
 	module_put(mod);
 
@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
 
 int static_call_text_reserved(void *start, void *end)
 {
+	bool init = system_state < SYSTEM_RUNNING;
 	int ret = __static_call_text_reserved(__start_static_call_sites,
-			__stop_static_call_sites, start, end);
+			__stop_static_call_sites, start, end, init);
 
 	if (ret)
 		return ret;
author maintainer
#9 lore raw

PATCH 3/3 kprobe/static_call: Restore missing static_call_text_reserved()

In reply to Peter Zijlstra

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")
---
 kernel/kprobes.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/kprobes.c +2 -0
@@ -35,6 +35,7 @@
 #include <linux/ftrace.h>
 #include <linux/cpu.h>
 #include <linux/jump_label.h>
+#include <linux/static_call.h>
 #include <linux/perf_event.h>
 
 #include <asm/sections.h>
@@ -1551,6 +1552,7 @@ static int check_kprobe_address_safe(str
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	    within_kprobe_blacklist((unsigned long) p->addr) ||
 	    jump_label_text_reserved(p->addr, p->addr) ||
+	    static_call_text_reserved(p->addr, p->addr) ||
 	    find_bug((unsigned long)p->addr)) {
 		ret = -EINVAL;
 		goto out;
author maintainer
#10 lore raw

Re: [PATCH 3/3] kprobe/static_call: Restore missing static_call_text_reserved()

Quoted 4 lines · Peter Zijlstra

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

FWIW, it was a royal pain in the arse to find that commit...

maintainer
#11 lore raw

Re: [PATCH 3/3] kprobe/static_call: Restore missing static_call_text_reserved()

Quoted 7 lines · On Mon, 28 Jun 2021 13:34:58 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 4 lines · Peter Zijlstra

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

FWIW, it was a royal pain in the arse to find that commit...

I think if this is a fix, that fixes static_call introduction commit, because anyway kprobes has to check the static_call site as a reserved area for another self code modifying.

Thank you,

Signature · 1 line
Masami Hiramatsu <[email protected]>
author maintainer
#12 lore raw

Re: [PATCH 3/3] kprobe/static_call: Restore missing static_call_text_reserved()

Quoted 7 lines · Masami Hiramatsu
Quoted 4 lines · On Mon, 28 Jun 2021 13:34:58 +0200 Peter Zijlstra <[email protected]> wrote:
Quoted 3 lines · Peter Zijlstra

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

FWIW, it was a royal pain in the arse to find that commit...

I think if this is a fix, that fixes static_call introduction commit, because anyway kprobes has to check the static_call site as a reserved area for another self code modifying.

Yeah, so 6333e8f73b83 has these two hunks, so the initial commit was fine, but the merge commit from the Fixes: tag lost them again for some reason. So this really is a fix for a merge commit afaict.

maintainer Acked-by on v1 3/3
#13 lore raw

Re: [PATCH 3/3] kprobe/static_call: Restore missing static_call_text_reserved()

In reply to Peter Zijlstra
Quoted 5 lines · On Mon, 28 Jun 2021 13:24:12 +0200 Peter Zijlstra <[email protected]> wrote:

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")

This looks good to me.

Thank you!

Quoted 24 lines
---
 kernel/kprobes.c |    2 ++
 1 file changed, 2 insertions(+)
kernel/kprobes.c +2 -0
@@ -35,6 +35,7 @@
 #include <linux/ftrace.h>
 #include <linux/cpu.h>
 #include <linux/jump_label.h>
+#include <linux/static_call.h>
 #include <linux/perf_event.h>
 
 #include <asm/sections.h>
@@ -1551,6 +1552,7 @@ static int check_kprobe_address_safe(str
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	    within_kprobe_blacklist((unsigned long) p->addr) ||
 	    jump_label_text_reserved(p->addr, p->addr) ||
+	    static_call_text_reserved(p->addr, p->addr) ||
 	    find_bug((unsigned long)p->addr)) {
 		ret = -EINVAL;
 		goto out;
Signature · 1 line
Masami Hiramatsu <[email protected]>
merge bot Applied
#14 lore raw

[tip: locking/urgent] kprobe/static_call: Restore missing static_call_text_reserved()

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     1dcba646c86dc86114ac666a1887e84282154515
Gitweb:        https://git.kernel.org/tip/1dcba646c86dc86114ac666a1887e84282154515
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:12 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Fri, 02 Jul 2021 15:58:27 +02:00

kprobe/static_call: Restore missing static_call_text_reserved()

Restore two hunks from commit 6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s") that went walkabout.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")
---
 kernel/kprobes.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/kprobes.c +2 -0
index e41385a..069388d 100644
@@ -35,6 +35,7 @@
 #include <linux/ftrace.h>
 #include <linux/cpu.h>
 #include <linux/jump_label.h>
+#include <linux/static_call.h>
 #include <linux/perf_event.h>
 
 #include <asm/sections.h>
@@ -1551,6 +1552,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	    within_kprobe_blacklist((unsigned long) p->addr) ||
 	    jump_label_text_reserved(p->addr, p->addr) ||
+	    static_call_text_reserved(p->addr, p->addr) ||
 	    find_bug((unsigned long)p->addr)) {
 		ret = -EINVAL;
 		goto out;
merge bot Applied
#15 lore raw

[tip: locking/urgent] kprobe/static_call: Restore missing static_call_text_reserved()

In reply to Peter Zijlstra
The following commit has been merged into the locking/urgent branch of tip:

The following commit has been merged into the locking/urgent branch of tip:

Commit-ID:     fa68bd09fc62240a383c0c601d3349c47db10c34
Gitweb:        https://git.kernel.org/tip/fa68bd09fc62240a383c0c601d3349c47db10c34
Author:        Peter Zijlstra <[email protected]>
AuthorDate:    Mon, 28 Jun 2021 13:24:12 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Mon, 05 Jul 2021 10:47:16 +02:00

kprobe/static_call: Restore missing static_call_text_reserved()

Restore two hunks from commit:

6333e8f73b83 ("static_call: Avoid kprobes on inline static_call()s")

that went walkabout in a Git merge commit.

Fixes 76d4acf22b48 ("Merge tag 'perf-kprobes-2020-12-14' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip")
---
 kernel/kprobes.c | 2 ++
 1 file changed, 2 insertions(+)
kernel/kprobes.c +2 -0
index e41385a..069388d 100644
@@ -35,6 +35,7 @@
 #include <linux/ftrace.h>
 #include <linux/cpu.h>
 #include <linux/jump_label.h>
+#include <linux/static_call.h>
 #include <linux/perf_event.h>
 
 #include <asm/sections.h>
@@ -1551,6 +1552,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
 	if (!kernel_text_address((unsigned long) p->addr) ||
 	    within_kprobe_blacklist((unsigned long) p->addr) ||
 	    jump_label_text_reserved(p->addr, p->addr) ||
+	    static_call_text_reserved(p->addr, p->addr) ||
 	    find_bug((unsigned long)p->addr)) {
 		ret = -EINVAL;
 		goto out;