[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <177cc1f5-3b11-cde1-5769-f18e87890083@redhat.com>
Date: Mon, 5 Jun 2023 10:51:50 -0400
From: Waiman Long <longman@...hat.com>
To: Zou Cao <zoucaox@...il.com>, linux-kernel@...r.kernel.org,
tj@...nel.org
Cc: cgroups@...r.kernel.org, lizefan.x@...edance.com,
hannes@...xchg.org, brauner@...nel.org,
Zou Cao <zoucao@...ishou.com>
Subject: Re: [PATCH] cgroup: fixed the cset refcnt leak when fork() failed
On 6/5/23 10:12, Waiman Long wrote:
>> kernel/cgroup/cgroup.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
>> index d18c2ef..5ecd706 100644
>> --- a/kernel/cgroup/cgroup.c
>> +++ b/kernel/cgroup/cgroup.c
>> @@ -6284,6 +6284,11 @@ void cgroup_cancel_fork(struct task_struct
>> *child,
>> if (ss->cancel_fork)
>> ss->cancel_fork(child, kargs->cset);
>> + if (!(kargs->flags & CLONE_INTO_CGROUP) &&
>> + kargs->cset) {
>> + put_css_set(kargs->cset);
>> + }
>> +
> I believe the out_revert error path of cgroup_can_fork() has a similar
> issue. Perhaps you may want to put the put_css_set() call in
> cgroup_css_set_put_fork().
Sorry, it should not be done in cgroup_css_set_put_fork(). As the
increase in reference is properly matched in css_post_fork(). That means
similar change will be needed in cgroup_can_fork().
Cheers,
Longman
Powered by blists - more mailing lists