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]
Date: Tue, 27 Feb 2024 13:09:27 +0100
From: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: linux-xfs@...r.kernel.org, linux-fsdevel@...r.kernel.org, 
	linux-kernel@...r.kernel.org, david@...morbit.com, chandan.babu@...cle.com, 
	akpm@...ux-foundation.org, mcgrof@...nel.org, ziy@...dia.com, hare@...e.de, 
	djwong@...nel.org, gost.dev@...sung.com, linux-mm@...ck.org, 
	Pankaj Raghav <p.raghav@...sung.com>
Subject: Re: [PATCH 04/13] filemap: use mapping_min_order while allocating
 folios

On Mon, Feb 26, 2024 at 02:47:33PM +0000, Matthew Wilcox wrote:
> On Mon, Feb 26, 2024 at 10:49:27AM +0100, Pankaj Raghav (Samsung) wrote:
> > Add some additional VM_BUG_ON() in page_cache_delete[batch] and
> > __filemap_add_folio to catch errors where we delete or add folios that
> > has order less than min_order.
> 
> I don't understand why we need these checks in the deletion path.  The
> add path, yes, absolutely.  But the delete path?
I think we initially added it to check if some split happened which
might mess up the page cache with min order support. But I think it is
not super critical anymore because of the changes in the split_folio
path. I will remove the checks.

> 
> > @@ -896,6 +900,8 @@ noinline int __filemap_add_folio(struct address_space *mapping,
> >  			}
> >  		}
> >  
> > +		VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_folio_order(mapping),
> > +				folio);
> 
> But I don't understand why you put it here, while we're holding the
> xa_lock.  That seems designed to cause maximum disruption.  Why not put
> it at the beginning of the function with all the other VM_BUG_ON_FOLIO?

Yeah. That makes sense as the folio itself is not changing.

> 
> > @@ -1847,6 +1853,9 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> >  		fgf_t fgp_flags, gfp_t gfp)
> >  {
> >  	struct folio *folio;
> > +	unsigned int min_order = mapping_min_folio_order(mapping);
> > +
> > +	index = mapping_align_start_index(mapping, index);
> 
> I would not do this here.
> 
> >  repeat:
> >  	folio = filemap_get_entry(mapping, index);
> > @@ -1886,7 +1895,7 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> >  		folio_wait_stable(folio);
> >  no_page:
> >  	if (!folio && (fgp_flags & FGP_CREAT)) {
> > -		unsigned order = FGF_GET_ORDER(fgp_flags);
> > +		unsigned int order = max(min_order, FGF_GET_ORDER(fgp_flags));
> >  		int err;
> 
> Put it here instead.
> 
> >  		if ((fgp_flags & FGP_WRITE) && mapping_can_writeback(mapping))
> > @@ -1912,8 +1921,13 @@ struct folio *__filemap_get_folio(struct address_space *mapping, pgoff_t index,
> >  			gfp_t alloc_gfp = gfp;
> >  
> >  			err = -ENOMEM;
> > +			if (order < min_order)
> > +				order = min_order;
> >  			if (order > 0)
> >  				alloc_gfp |= __GFP_NORETRY | __GFP_NOWARN;
> > +
> > +			VM_BUG_ON(index & ((1UL << order) - 1));
> 
> Then you don't need this BUG_ON because it's obvious you just did it.
> And the one in filemap_add_folio() would catch it anyway.

I agree. I will change it in the next revision.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ