Skip to contentSkip to conversation

fprobe: Fixes for Sparse and Smatch warnings

PATCH Applied Masami Hiramatsu 2 participants 4 messages Mar 23, 2022 – Mar 29, 2022

Subsystems (3)
lore
Share & tools
lore

Masami Hiramatsu

author maintainer
#0 lore raw

cover fprobe: Fixes for Sparse and Smatch warnings

Hi,

These fprobe patches are for fixing the warnings by Smatch and sparse. This is arch independent part of the fixes.

Thank you,

---

Masami Hiramatsu (2):
fprobe: Fix smatch type mismatch warning
fprobe: Fix sparse warning for acccessing __rcu ftrace_hash

 kernel/trace/fprobe.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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

author maintainer
#1 lore raw

PATCH 1/2 fprobe: Fix smatch type mismatch warning

Fix the type mismatching warning of 'rethook_node vs fprobe_rethook_node' found by Smatch.

---
 kernel/trace/fprobe.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/fprobe.c +3 -3
index 8b2dd5b9dcd1..63b2321b22a0 100644
@@ -150,15 +150,15 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
 
 	fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
 	for (i = 0; i < size; i++) {
-		struct rethook_node *node;
+		struct fprobe_rethook_node *node;
 
-		node = kzalloc(sizeof(struct fprobe_rethook_node), GFP_KERNEL);
+		node = kzalloc(sizeof(*node), GFP_KERNEL);
 		if (!node) {
 			rethook_free(fp->rethook);
 			fp->rethook = NULL;
 			return -ENOMEM;
 		}
-		rethook_add_node(fp->rethook, node);
+		rethook_add_node(fp->rethook, &node->node);
 	}
 	return 0;
 }
author maintainer
#2 lore raw

PATCH 2/2 fprobe: Fix sparse warning for acccessing __rcu ftrace_hash

In reply to Masami Hiramatsu

Since ftrace_ops::local_hash::filter_hash field is an __rcu pointer, we have to use rcu_access_pointer() to access it.

---
 kernel/trace/fprobe.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/fprobe.c +1 -1
index 63b2321b22a0..89d9f994ebb0 100644
@@ -215,7 +215,7 @@ int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter
 	 * correctly calculate the total number of filtered symbols
 	 * from both filter and notfilter.
 	 */
-	hash = fp->ops.local_hash.filter_hash;
+	hash = rcu_access_pointer(fp->ops.local_hash.filter_hash);
 	if (WARN_ON_ONCE(!hash))
 		goto out;
 
#3 lore raw
In reply to Masami Hiramatsu
This series was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This series was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:

Quoted 9 lines · On Wed, 23 Mar 2022 16:35:15 +0900 you wrote:

Hi,

These fprobe patches are for fixing the warnings by Smatch and sparse. This is arch independent part of the fixes.

Thank you,

[...]

Here is the summary with links:
- [bpf-next,1/2] fprobe: Fix smatch type mismatch warning

    https://git.kernel.org/bpf/bpf/c/9052e4e83762
  - [bpf-next,2/2] fprobe: Fix sparse warning for acccessing __rcu ftrace_hash
    https://git.kernel.org/bpf/bpf/c/261608f3105c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html