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]
Message-ID: <aDkeQFMjzz0frIg/@MiWiFi-R3L-srv>
Date: Fri, 30 May 2025 10:56:00 +0800
From: Baoquan He <bhe@...hat.com>
To: Kemeng Shi <shikemeng@...weicloud.com>
Cc: akpm@...ux-foundation.org, kasong@...cent.com, hannes@...xchg.org,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4] mm: swap: fix potensial buffer overflow in
 setup_clusters()

On 05/22/25 at 08:25pm, Kemeng Shi wrote:
> In setup_swap_map(), we only ensure badpages are in range (0, last_page].
> As maxpages might be < last_page, setup_clusters() will encounter a
> buffer overflow when a badpage is >= maxpages.
> Only call inc_cluster_info_page() for badpage which is < maxpages to
> fix the issue.
> 
> Fixes: b843786b0bd01 ("mm: swapfile: fix SSD detection with swapfile on btrfs")
> Signed-off-by: Kemeng Shi <shikemeng@...weicloud.com>
> ---
>  mm/swapfile.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)

Reviewed-by: Baoquan He <bhe@...hat.com>

> 
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index a82f4ebefca3..63ab9f14b2c6 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -3208,9 +3208,13 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si,
>  	 * and the EOF part of the last cluster.
>  	 */
>  	inc_cluster_info_page(si, cluster_info, 0);
> -	for (i = 0; i < swap_header->info.nr_badpages; i++)
> -		inc_cluster_info_page(si, cluster_info,
> -				      swap_header->info.badpages[i]);
> +	for (i = 0; i < swap_header->info.nr_badpages; i++) {
> +		unsigned int page_nr = swap_header->info.badpages[i];
> +
> +		if (page_nr >= maxpages)
> +			continue;
> +		inc_cluster_info_page(si, cluster_info, page_nr);
> +	}
>  	for (i = maxpages; i < round_up(maxpages, SWAPFILE_CLUSTER); i++)
>  		inc_cluster_info_page(si, cluster_info, i);
>  
> -- 
> 2.30.0
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ