Skip to contentSkip to conversation

ftrace: Use rcu_assign_pointer() for tmp_ops filter hash

PATCH In review Leon Hwang 2 participants 2 messages Sep 11 – Sep 13

Subsystems (2)
lore
Share & tools
lore

Leon Hwang

author
#0 lore raw

PATCH 1/1 ftrace: Use rcu_assign_pointer() for tmp_ops filter hash

tmp_ops.func_hash->filter_hash is annotated __rcu, but update_ftrace_direct_mod() assigns hash to it directly. Sparse reports an address-space mismatch.

Use rcu_assign_pointer() for the assignment.

Fixes 50b35c9e50a8 ("ftrace: Use hash argument for tmp_ops in update_ftrace_direct_mod")
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index 53d5db60bfa5..673a54fdf392 100644
@@ -6675,7 +6675,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b
 
 	/* Enable the tmp_ops to have the same functions as the hash object. */
 	ftrace_ops_init(&tmp_ops);
-	tmp_ops.func_hash->filter_hash = hash;
+	rcu_assign_pointer(tmp_ops.func_hash->filter_hash, hash);
 
 	err = register_ftrace_function_nolock(&tmp_ops);
 	if (err)
Signature · 1 line
2.55.0
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Leon Hwang

tmp_ops.func_hash->filter_hash is annotated __rcu, but update_ftrace_direct_mod() assigns hash to it directly. Sparse reports an address-space mismatch.

Use rcu_assign_pointer() for the assignment.

Fixes 50b35c9e50a8 ("ftrace: Use hash argument for tmp_ops in update_ftrace_direct_mod")

thanks,
jirka

Quoted 20 lines
---
 kernel/trace/ftrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/ftrace.c +1 -1
index 53d5db60bfa5..673a54fdf392 100644
@@ -6675,7 +6675,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b
 
 	/* Enable the tmp_ops to have the same functions as the hash object. */
 	ftrace_ops_init(&tmp_ops);
-	tmp_ops.func_hash->filter_hash = hash;
+	rcu_assign_pointer(tmp_ops.func_hash->filter_hash, hash);
 
 	err = register_ftrace_function_nolock(&tmp_ops);
 	if (err)
Signature · 1 line
2.55.0