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: <97ba80061354fef89349a70e1cb8eb34dd7730f3.camel@surriel.com>
Date: Fri, 30 Aug 2024 09:11:32 -0400
From: Rik van Riel <riel@...riel.com>
To: "Darrick J. Wong" <djwong@...nel.org>
Cc: Hugh Dickins <hughd@...gle.com>, kernel-team@...a.com, Andrew Morton
 <akpm@...ux-foundation.org>, linux-mm@...ck.org,
 linux-kernel@...r.kernel.org,  Dave Chinner <dchinner@...hat.com>,
 Vlastimil Babka <vbabka@...e.cz>
Subject: Re: [PATCH] mm,tmpfs: consider end of file write in shmem_is_huge

On Thu, 2024-08-29 at 22:52 -0700, Darrick J. Wong wrote:
> On Thu, Aug 29, 2024 at 11:54:15PM -0400, Rik van Riel wrote:
> > 
> > @@ -196,7 +196,7 @@ xfile_store(
> >  		unsigned int	len;
> >  		unsigned int	offset;
> >  
> > -		if (shmem_get_folio(inode, pos >> PAGE_SHIFT,
> > &folio,
> > +		if (shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > &folio,
> 
> Technically speaking, the "0" here could be (pos + count), though for
> the current xfile users this isn't likely to make much difference
> because online fsck's index building only appends small amounts of
> data
> (i.e. not larger than a PAGE_SIZE) at a time.
> 
> >  				SGP_CACHE) < 0)

With SGP_CACHE, won't shmem_get_folio simply refuse to allocate
any pages beyond the end of the inode?

        if (sgp <= SGP_CACHE &&
            ((loff_t)index << PAGE_SHIFT) >= i_size_read(inode))
                return -EINVAL;

> >  			break;
> >  		if (filemap_check_wb_err(inode->i_mapping, 0)) {
> > @@ -267,7 +267,7 @@ xfile_get_folio(
> >  		i_size_write(inode, pos + len);
> >  
> >  	pflags = memalloc_nofs_save();
> > -	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio,
> > +	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > &folio,
> 
> This 0 could be pos + len, since the only caller is xfarray_sort,
> which
> runs much faster when it can heapsort a large folio's worth of data
> at a
> time.
> 
> >  			(flags & XFILE_ALLOC) ? SGP_CACHE :
> > SGP_READ);

The same applies here.

> >  	memalloc_nofs_restore(pflags);
> >  	if (error)
> > diff --git a/fs/xfs/xfs_buf_mem.c b/fs/xfs/xfs_buf_mem.c
> > index 9bb2d24de709..07bebbfb16ee 100644
> > --- a/fs/xfs/xfs_buf_mem.c
> > +++ b/fs/xfs/xfs_buf_mem.c
> > @@ -149,7 +149,7 @@ xmbuf_map_page(
> >  		return -ENOMEM;
> >  	}
> >  
> > -	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, &folio,
> > SGP_CACHE);
> > +	error = shmem_get_folio(inode, pos >> PAGE_SHIFT, 0,
> > &folio, SGP_CACHE);
> 
> The "0" here could be (pos + BBTOB(bp->length)) since we're likely
> going
> to write there soon.  Granted, no current user of xmbufs actually
> uses a
> blocksize larger than PAGE_SIZE, but in theory we could someday turn
> that on.
> 
> Everything below here looks sane enough to me, but I'm not that much
> of
> an expert on mm/ things outside of the pagecache and shmem.c.

... and here.

XFS is no using an SGP flag that allows shmem_get_folio to allocate
a page beyond the end of the i_size.

-- 
All Rights Reversed.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ