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] [day] [month] [year] [list]
Message-ID: <87o9qrqnyz.fsf@yhuang-dev.intel.com>
Date:   Mon, 04 Sep 2017 08:58:12 +0800
From:   "Huang\, Ying" <ying.huang@...el.com>
To:     David Rientjes <rientjes@...gle.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        "Darrick J. Wong" <darrick.wong@...cle.com>,
        <ying.huang@...el.com>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm: kvfree the swap cluster info if the swap file is unsatisfactory

David Rientjes <rientjes@...gle.com> writes:

> On Thu, 31 Aug 2017, Darrick J. Wong wrote:
>
>> If initializing a small swap file fails because the swap file has a
>> problem (holes, etc.) then we need to free the cluster info as part of
>> cleanup.  Unfortunately a previous patch changed the code to use
>> kvzalloc but did not change all the vfree calls to use kvfree.
>> 
>
> Hopefully this can make it into 4.13.
>
> Fixes: 54f180d3c181 ("mm, swap: use kvzalloc to allocate some swap data structures")
> Cc: stable@...r.kernel.org [4.12]
>
>> Found by running generic/357 from xfstests.
>> 
>> Signed-off-by: Darrick J. Wong <darrick.wong@...cle.com>
>
> Acked-by: David Rientjes <rientjes@...gle.com>
>
> But I think there's also a memory leak and we need this on top of your 
> fix:
>
>
> mm, swapfile: fix swapon frontswap_map memory leak on error 
>
> Free frontswap_map if an error is encountered before enable_swap_info().
>
> Signed-off-by: David Rientjes <rientjes@...gle.com>
> ---
>  mm/swapfile.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -3053,6 +3053,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
>  	spin_unlock(&swap_lock);
>  	vfree(swap_map);
>  	kvfree(cluster_info);
> +	kvfree(frontswap_map);
>  	if (swap_file) {
>  		if (inode && S_ISREG(inode->i_mode)) {
>  			inode_unlock(inode);

Yes.  There is a memory leak.

Reviewed-by: "Huang, Ying" <ying.huang@...el.com>

Best Regards,
Huang, Ying

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ