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:	Thu, 12 Jun 2014 19:09:53 +0800
From:	Ian Kent <raven@...maw.net>
To:	David Rientjes <rientjes@...gle.com>
Cc:	Heiko Carstens <heiko.carstens@...ibm.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Christoph Hellwig <hch@...radead.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	Andrea Righi <andrea@...terlinux.com>,
	Eric Dumazet <eric.dumazet@...il.com>,
	linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
	Hendrik Brueckner <brueckner@...ux.vnet.ibm.com>,
	Thorsten Diehl <thorsten.diehl@...ibm.com>,
	"Elliott, Robert (Server Storage)" <Elliott@...com>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH 2/2] fs: proc/stat: use usual seq_file ops rather than
 single_open

On Wed, 2014-06-11 at 23:52 -0700, David Rientjes wrote:
> On Thu, 12 Jun 2014, Ian Kent wrote:
> 
> > > > diff --git a/fs/seq_file.c b/fs/seq_file.c
> > > > index 1d641bb108d2..fca78a04c0d1 100644
> > > > --- a/fs/seq_file.c
> > > > +++ b/fs/seq_file.c
> > > > @@ -8,8 +8,10 @@
> > > >  #include <linux/fs.h>
> > > >  #include <linux/export.h>
> > > >  #include <linux/seq_file.h>
> > > > +#include <linux/vmalloc.h>
> > > >  #include <linux/slab.h>
> > > >  #include <linux/cred.h>
> > > > +#include <linux/mm.h>
> > > >  
> > > >  #include <asm/uaccess.h>
> > > >  #include <asm/page.h>
> > > > @@ -82,6 +84,31 @@ int seq_open(struct file *file, const struct seq_operations *op)
> > > >  }
> > > >  EXPORT_SYMBOL(seq_open);
> > > >  
> > > > +static void seq_alloc(struct seq_file *m)
> > > > +{
> > > > +	m->size = PAGE_SIZE;
> > > > +	m->buf = kmalloc(m->size, GFP_KERNEL | __GFP_NOWARN);
> > > > +	if (!m->buf)
> > > > +		m->buf = vmalloc(m->size);
> > > > +}
> > > > +
> > > 
> > > If m->size is unconditionally PAGE_SIZE, then how is vmalloc() going to 
> > > allocate this if kmalloc() fails?
> > 
> > This is just the initial allocation.
> > If it runs out of room the allocation size doubles.
> > 
> > I think 2*PAGE_SIZE is probably better here since that's closer to what
> > the original heuristic allocation requested and is likely to avoid
> > reallocations in most cases.
> > 
> > The issue of kmalloc() failing for larger allocations on low speced
> > hardware with fragmented memory might succeed when vmalloc() is used
> > since it doesn't require contiguous memory chunks. But I guess the added
> > pressure on the page table might still be a problem, nevertheless it's
> > probably worth trying before bailing out. 
> > 
> 
> I'm not quarreling about using vmalloc() for allocations that are 
> high-order, I'm referring to the rather obvious fact that m->size is set 
> to PAGE_SIZE unconditionally above and thus vmalloc() isn't going to help 
> in the slightest.

LOL, yeah, if kmalloc() can't allocate a single page then we're in much
bigger trouble!

Ian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ