lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 28 Feb 2024 10:08:37 -0500
From: Waiman Long <longman@...hat.com>
To: Mirsad Todorovac <mirsad.todorovac@....hr>, Tejun Heo <tj@...nel.org>,
 Zefan Li <lizefan.x@...edance.com>, Johannes Weiner <hannes@...xchg.org>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: Fix a memory leak in
 update_exclusive_cpumask()


On 2/28/24 08:56, Mirsad Todorovac wrote:
> Hi,
>
> On 2/28/2024 1:58 AM, Waiman Long wrote:
>> Fix a possible memory leak in update_exclusive_cpumask() by moving the
>> alloc_cpumasks() down after the validate_change() check which can fail
>> and still before the temporary cpumasks are needed.
>>
>> Fixes: e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2")
>> Reported-by: Mirsad Todorovac <mirsad.todorovac@....hr>
>> Closes: 
>> https://lore.kernel.org/lkml/14915689-27a3-4cd8-80d2-9c30d0c768b6@alu.unizg.hr
>> Signed-off-by: Waiman Long <longman@...hat.com>
>> ---
>>   kernel/cgroup/cpuset.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index ba36c073304a..7260f095802a 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -2598,9 +2598,6 @@ static int update_exclusive_cpumask(struct 
>> cpuset *cs, struct cpuset *trialcs,
>>       if (cpumask_equal(cs->exclusive_cpus, trialcs->exclusive_cpus))
>>           return 0;
>>   -    if (alloc_cpumasks(NULL, &tmp))
>> -        return -ENOMEM;
>> -
>>       if (*buf)
>>           compute_effective_exclusive_cpumask(trialcs, NULL);
>>   @@ -2615,6 +2612,9 @@ static int update_exclusive_cpumask(struct 
>> cpuset *cs, struct cpuset *trialcs,
>>       if (retval)
>>           return retval;
>>   +    if (alloc_cpumasks(NULL, &tmp))
>> +        return -ENOMEM;
>> +
>>       if (old_prs) {
>>           if (cpumask_empty(trialcs->effective_xcpus)) {
>>               invalidate = true;Great work at such a short notice! (I 
>> failed to find the culprit myself.)
>
> The leak is no longer present.
>
> Please feel free to add:
>
> Tested-by: Mirsad Todorovac <mtodorov@....unizg.hr>
>
> Best regards, Mirsad Todorovac
>
> P.S. APologies for the previous email accidentally sent as HTML.

Thanks for verifying the fix.

Cheers,
Longman


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ