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>] [day] [month] [year] [list]
Message-ID: <ec3b5661-e99-fb46-b678-66a7daf43d82@google.com>
Date:   Tue, 21 Feb 2023 14:41:21 -0800 (PST)
From:   Hugh Dickins <hughd@...gle.com>
To:     David Howells <dhowells@...hat.com>
cc:     Matthew Wilcox <willy@...radead.org>,
        Hugh Dickins <hughd@...gle.com>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        "Vishal Moola (Oracle)" <vishal.moola@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Steve French <smfrench@...il.com>,
        Steve French <stfrench@...rosoft.com>,
        Shyam Prasad N <nspmangalore@...il.com>,
        Rohith Surabattula <rohiths.msft@...il.com>,
        Tom Talpey <tom@...pey.com>, Paulo Alcantara <pc@....nz>,
        Jeff Layton <jlayton@...nel.org>, linux-cifs@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-next@...r.kernel.org
Subject: Re: Obsolete comment on page swizzling (written by Hugh)?

On Tue, 21 Feb 2023, David Howells wrote:
> David Howells <dhowells@...hat.com> wrote:
> 
> > > > +			/* At this point we hold neither the i_pages lock nor the
> > > > +			 * page lock: the page may be truncated or invalidated
> > > > +			 * (changing page->mapping to NULL), or even swizzled
> > > > +			 * back from swapper_space to tmpfs file mapping
> > > 
> > > Where does this comment come from?  This is cifs, not tmpfs.  You'll
> > > never be asked to writeback a page from the swap cache.  Dirty pages
> > > can be truncated, so the first half of the comment is still accurate.
> > > I'd rather it moved down to below the folio lock, and was rephrased
> > > so it described why we're checking everything again.
> > 
> > Actually, it's in v6.2 cifs and I just move it in the patch where I copy the
> > afs writepages implementation into cifs.  afs got it in 2007 when I added
> > write support[1] and I suspect I copied it from cifs.  cifs got it in 2005
> > when Steve added writepages support[2].  I think he must've got it from
> > fs/mpage.c and the comment there is prehistoric.
> 
> The ultimate source is Hugh Dickins, it would seem:
> 
> 	commit 820ef9df32856bb54fe5bc995153feb276420e15
> 	Author: Andrew Morton <akpm@...eo.com>
> 	Date:   Fri Nov 15 18:52:38 2002 -0800
> 
> 	[PATCH] handle pages which alter their ->mapping
> 
> 	Patch from Hugh Dickins <hugh@...itas.com>
> 
> 	tmpfs failed fsx+swapout tests after many hours, a page found zeroed.
> 	Not a truncate problem, but mirror image of earlier truncate problems:
> 	swap goes through mpage_writepages, which must therefore allow for a
> 	sudden swizzle back to file identity.
> 
> 	Second time this caught us, so I've audited the tree for other places
> 	which might be surprised by such swizzling.  The only others I found
> 	were (perhaps) in the parisc and sparc64 flush_dcache_page called
> 	from do_generic_mapping_read on a looped tmpfs file which is also
> 	mmapped; but that's a very marginal case, I wanted to understand it
> 	better before making any edit, and now realize that hch's sendfile
> 	in loop eliminates it (now go through do_shmem_file_read instead:
> 	similar but crucially this locks the page when raising its count,
> 	which is enough to keep vmscan from interfering).
> 
> Maybe we should delete or amend the comment now?

Yes, that comment does not belong in afs or btrfs or cifs - though it
does explain why we have sometimes chosen to compare folio_mapping(folio)
with expected mapping, rather than against NULL.

But "now" is not the moment to amend it: it looks like these sources
are in flux at present.  And truncate_cleanup_folio() has a "swizzles"
comment without even a mapping to compare with.

Hugh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ