bpf: Cleanup ftrace hash in bpf_trampoline_put
Jiri Olsa
reviewerPATCH 1/1 bpf: Cleanup ftrace hash in bpf_trampoline_put
We need to release possible hash from trampoline fops object before removing it, otherwise we leak it.
Fixes 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)")
Signed-off-by Jiri Olsa <[email protected]>
--- kernel/bpf/trampoline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/bpf/trampoline.c +4 -1
@@ -841,7 +841,10 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)* multiple rcu callbacks. */ hlist_del (&tr->hlist); -kfree (tr->fops); +if (tr->fops) { +ftrace_free_filter (tr->fops); +kfree (tr->fops); + }kfree (tr); out:mutex_unlock (&trampoline_mutex);
Signature · 1 line
2.37.1
Quoted 6 lines · Jiri Olsa
We need to release possible hash from trampoline fops object before removing it, otherwise we leak it.
Fixes 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)")Signed-off-by Jiri Olsa <[email protected]>
Great catch! Thanks!
Acked-by Song Liu <[email protected]>
Quoted 23 lines
--- kernel/bpf/trampoline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)kernel/bpf/trampoline.c +4
-2@@ -841,7 +841,10 @@ void bpf_trampoline_put(struct bpf_trampoline *tr)* multiple rcu callbacks. */ hlist_del (&tr->hlist); -kfree (tr->fops); +if (tr->fops) { +ftrace_free_filter (tr->fops); +kfree (tr->fops); + }kfree (tr); out:mutex_unlock (&trampoline_mutex); --2.37.1
This patch was applied to bpf/bpf.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Andrii Nakryiko <[email protected]>:
Quoted 8 lines · On Tue, 2 Aug 2022 15:56:51 +0200 you wrote:
We need to release possible hash from trampoline fops object before removing it, otherwise we leak it.
Fixes 00963a2e75a8 ("bpf: Support bpf_trampoline on functions with IPMODIFY (e.g. livepatch)")Signed-off-by Jiri Olsa <[email protected]>--- kernel/bpf/trampoline.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Here is the summary with links:
- [bpf] bpf: Cleanup ftrace hash in bpf_trampoline_put
https://git.kernel.org/bpf/bpf/c/62d468e5e100
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html