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: <20240206022409.202536-1-sj@kernel.org>
Date: Mon,  5 Feb 2024 18:24:09 -0800
From: SeongJae Park <sj@...nel.org>
To: Kairui Song <ryncsn@...il.com>
Cc: linux-mm@...ck.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	"Huang, Ying" <ying.huang@...el.com>,
	Chris Li <chrisl@...nel.org>,
	Minchan Kim <minchan@...nel.org>,
	Hugh Dickins <hughd@...gle.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Matthew Wilcox <willy@...radead.org>,
	Michal Hocko <mhocko@...e.com>,
	Yosry Ahmed <yosryahmed@...gle.com>,
	David Hildenbrand <david@...hat.com>,
	Yu Zhao <yuzhao@...gle.com>,
	linux-kernel@...r.kernel.org,
	Kairui Song <kasong@...cent.com>
Subject: Re: [PATCH] mm/swap: fix race condition in direct swapin path

Hi Kairui,

On Mon,  5 Feb 2024 19:09:59 +0800 Kairui Song <ryncsn@...il.com> wrote:

[...]
>  mm/memory.c   | 19 +++++++++++++++++++
>  mm/swap.h     |  5 +++++
>  mm/swapfile.c | 16 ++++++++++++++++
>  3 files changed, 40 insertions(+)
> 
> diff --git a/mm/memory.c b/mm/memory.c
> index 7e1f4849463a..fd7c55a292f1 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -3867,6 +3867,20 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
>  	if (!folio) {
>  		if (data_race(si->flags & SWP_SYNCHRONOUS_IO) &&
>  		    __swap_count(entry) == 1) {
> +			/*
> +			 * With swap count == 1, after we read the entry,
> +			 * other threads could finish swapin first, free
> +			 * the entry, then swapout the modified page using
> +			 * the same entry. Now the content we just read is
> +			 * stalled, and it's undetectable as pte_same()
> +			 * returns true due to entry reuse.
> +			 *
> +			 * So pin the swap entry using the cache flag even
> +			 * cache is not used.
> +			 */
> +			if (swapcache_prepare(entry))
> +				goto out;
> +

I'm getting below build error after this patch.  I guess maybe the code need to
take care of CONFIG_SWAP unset case?

    .../mm/memory.c: In function 'do_swap_page':
    .../mm/memory.c:4004:8: error: implicit declaration of function 'swapcache_prepare'; did you mean 'swapcache_clear'? [-Werror=implicit-function-declaration]
     4004 |    if (swapcache_prepare(entry))
          |        ^~~~~~~~~~~~~~~~~
          |        swapcache_clear


Thanks,
SJ

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ