* [PATCH 1/1] seccomp: release seccomp after killing terminate clone/fork
@ 2021-12-28 5:34 Calvin Liao
2021-12-29 23:53 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Calvin Liao @ 2021-12-28 5:34 UTC (permalink / raw)
To: Matthias Brugger, Eric W . Biederman, Andrew Morton,
Peter Zijlstra, Christian Brauner, Jens Axboe, Alexey Gladkov,
Mike Christie, David Hildenbrand, Rolf Eike Beer
Cc: linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream,
calvin.liao
From: "calvin.liao" <calvin.liao@mediatek.com>
Add to release seccomp after killing terminate clone/fork to avoid
memory leak when enabling CONFIG_SECCOMP.
Signed-off-by: calvin.liao <calvin.liao@mediatek.com>
---
kernel/fork.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/fork.c b/kernel/fork.c
index 403b9dbbfb62..984103967a97 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1698,6 +1698,13 @@ static void copy_seccomp(struct task_struct *p)
#endif
}
+static void release_seccomp(struct task_struct *p)
+{
+#ifdef CONFIG_SECCOMP
+ seccomp_filter_release(p);
+#endif
+}
+
SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr)
{
current->clear_child_tid = tidptr;
@@ -2405,6 +2412,7 @@ static __latent_entropy struct task_struct *copy_process(
return p;
bad_fork_cancel_cgroup:
+ release_seccomp(p);
sched_core_free(p);
spin_unlock(¤t->sighand->siglock);
write_unlock_irq(&tasklist_lock);
--
2.18.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] seccomp: release seccomp after killing terminate clone/fork
2021-12-28 5:34 [PATCH 1/1] seccomp: release seccomp after killing terminate clone/fork Calvin Liao
@ 2021-12-29 23:53 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2021-12-29 23:53 UTC (permalink / raw)
To: Calvin Liao
Cc: Matthias Brugger, Eric W . Biederman, Peter Zijlstra,
Christian Brauner, Jens Axboe, Alexey Gladkov, Mike Christie,
David Hildenbrand, Rolf Eike Beer, linux-kernel,
linux-arm-kernel, linux-mediatek, wsd_upstream, calvin.liao,
Andrea Arcangeli
On Tue, 28 Dec 2021 13:34:21 +0800 Calvin Liao <calvin.liao@gmail.com> wrote:
> From: "calvin.liao" <calvin.liao@mediatek.com>
>
> Add to release seccomp after killing terminate clone/fork to avoid
> memory leak when enabling CONFIG_SECCOMP.
>
Help us out here - where was this filter allocated? Please describe
the code flow which led to this leak. Rather than simply saying "there
is a leak".
> --- a/kernel/fork.c
> +++ b/kernel/fork.c
> @@ -1698,6 +1698,13 @@ static void copy_seccomp(struct task_struct *p)
> #endif
> }
>
> +static void release_seccomp(struct task_struct *p)
> +{
> +#ifdef CONFIG_SECCOMP
> + seccomp_filter_release(p);
> +#endif
ifdefs aren't needed?
> +}
> +
> SYSCALL_DEFINE1(set_tid_address, int __user *, tidptr)
> {
> current->clear_child_tid = tidptr;
> @@ -2405,6 +2412,7 @@ static __latent_entropy struct task_struct *copy_process(
> return p;
>
> bad_fork_cancel_cgroup:
> + release_seccomp(p);
Why not simply call seccomp_filter_release() here, without ifdefs?
> sched_core_free(p);
> spin_unlock(¤t->sighand->siglock);
> write_unlock_irq(&tasklist_lock);
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-12-29 23:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-28 5:34 [PATCH 1/1] seccomp: release seccomp after killing terminate clone/fork Calvin Liao
2021-12-29 23:53 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).