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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200726230657.GT2005@dread.disaster.area>
Date:   Mon, 27 Jul 2020 09:06:57 +1000
From:   Dave Chinner <david@...morbit.com>
To:     "Matthew Wilcox (Oracle)" <willy@...radead.org>
Cc:     Christoph Hellwig <hch@...radead.org>,
        "Darrick J. Wong" <darrick.wong@...cle.com>,
        linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        Brian Foster <bfoster@...hat.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iomap: Ensure iop->uptodate matches PageUptodate

On Sun, Jul 26, 2020 at 10:10:52AM +0100, Matthew Wilcox (Oracle) wrote:
> If the filesystem has block size < page size and we end up calling
> iomap_page_create() in iomap_page_mkwrite_actor(), the uptodate bits
> would be zero, which causes us to skip writeback of blocks which are
> !uptodate in iomap_writepage_map().  This can lead to user data loss.

I'm still unclear on what condition gets us to
iomap_page_mkwrite_actor() without already having initialised the
page correctly. i.e. via a read() or write() call, or the read fault
prior to ->page_mkwrite() which would have marked the page uptodate
- that operation should have called iomap_page_create() and
iomap_set_range_uptodate() on the page....

i.e. you've described the symptom, but not the cause of the issue
you are addressing.

> Found using generic/127 with the THP patches.  I don't think this can be
> reproduced on mainline using that test (the THP code causes iomap_pages
> to be discarded more frequently), but inspection shows it can happen
> with an appropriate series of operations.

That sequence of operations would be? 

> Fixes: 9dc55f1389f9 ("iomap: add support for sub-pagesize buffered I/O without buffer heads")
> Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> ---
>  fs/iomap/buffered-io.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index a2b3b5455219..f0c5027bf33f 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -53,7 +53,10 @@ iomap_page_create(struct inode *inode, struct page *page)
>  	atomic_set(&iop->read_count, 0);
>  	atomic_set(&iop->write_count, 0);
>  	spin_lock_init(&iop->uptodate_lock);
> -	bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
> +	if (PageUptodate(page))
> +		bitmap_fill(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);
> +	else
> +		bitmap_zero(iop->uptodate, PAGE_SIZE / SECTOR_SIZE);

I suspect this bitmap_fill call belongs in the iomap_page_mkwrite()
code as is the only code that can call iomap_page_create() with an
uptodate page. Then iomap_page_create() could just use kzalloc() and
drop the atomic_set() and bitmap_zero() calls altogether,

Cheers,

Dave.
-- 
Dave Chinner
david@...morbit.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ