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]
Date:   Sun, 25 Oct 2020 17:14:11 -0700
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Miaohe Lin <linmiaohe@...wei.com>
Cc:     <linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
        Hugh Dickins <hughd@...gle.com>
Subject: Re: [PATCH] mm: swap: Use memset to fill the swap_map with
 SWAP_HAS_CACHE

On Mon, 21 Sep 2020 08:22:24 -0400 Miaohe Lin <linmiaohe@...wei.com> wrote:

> We could use helper memset to fill the swap_map with SWAP_HAS_CACHE instead
> of a direct loop here to simplify the code. Also we can remove the local
> variable i and map this way.
> 
> ...
>
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -975,8 +975,7 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_entry_t *slot)
>  {
>  	unsigned long idx;
>  	struct swap_cluster_info *ci;
> -	unsigned long offset, i;
> -	unsigned char *map;
> +	unsigned long offset;
>  
>  	/*
>  	 * Should not even be attempting cluster allocations when huge
> @@ -996,9 +995,7 @@ static int swap_alloc_cluster(struct swap_info_struct *si, swp_entry_t *slot)
>  	alloc_cluster(si, idx);
>  	cluster_set_count_flag(ci, SWAPFILE_CLUSTER, CLUSTER_FLAG_HUGE);
>  
> -	map = si->swap_map + offset;
> -	for (i = 0; i < SWAPFILE_CLUSTER; i++)
> -		map[i] = SWAP_HAS_CACHE;
> +	memset(si->swap_map + offset, SWAP_HAS_CACHE, SWAPFILE_CLUSTER);
>  	unlock_cluster(ci);
>  	swap_range_alloc(si, offset, SWAPFILE_CLUSTER);
>  	*slot = swp_entry(si->type, offset);

I suppose so.  But it does assume that the ->swapmap array has the type
char.  If we ever change that, breakage will ensue.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ