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: <20150413182848.GE36803@redhat.com>
Date:	Mon, 13 Apr 2015 14:28:49 -0400
From:	Jarod Wilson <jarod@...hat.com>
To:	Alexey Dobriyan <adobriyan@...il.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Al Viro <viro@...iv.linux.org.uk>,
	Miklos Szeredi <miklos@...redi.hu>,
	Zefan Li <lizefan@...wei.com>, Oleg Nesterov <oleg@...hat.com>
Subject: Re: [PATCH try #3] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline

On Sat, Apr 11, 2015 at 01:09:06AM +0300, Alexey Dobriyan wrote:
> On Fri, Apr 10, 2015 at 02:01:32PM -0400, Jarod Wilson wrote:
> > On Fri, Apr 10, 2015 at 05:13:29PM +0300, Alexey Dobriyan wrote:
> > > /proc/$PID/cmdline truncates output at PAGE_SIZE. It is easy to see with
> > > 
> > > 	$ cat /proc/self/cmdline $(seq 1037) 2>/dev/null
> > > 
> > > However, command line size was never limited to PAGE_SIZE but to 128 KB and
> > > relatively recently limitation was removed altogether.
> > > 
> > > People noticed and are asking questions:
> > > http://stackoverflow.com/questions/199130/how-do-i-increase-the-proc-pid-cmdline-4096-byte-limit
> > > 
> > > seq file interface is not OK, because it kmalloc's for whole output and
> > > open + read(, 1) + sleep will pin arbitrary amounts of kernel memory.
> > > To not do that, limit must be imposed which is incompatible with
> > > arbitrary sized command lines.
> > > 
> > > I apologize for hairy code, but this it direct consequence of command line
> > > layout in memory and hacks to support things like "init [3]".
> > > 
> > > The loops are "unrolled" otherwise it is either macros which hide
> > > control flow or functions with 7-8 arguments with equal line count.
> > 
> > That definitely qualifies as hairy. How big of a problem is it really in
> > practice if we continued using seq_file though? This only happens when
> > someone actually accesses /proc/$PID/cmdline, no? And if they're doing
> > that, they probably want that info, so is it so terrible if memory is held
> > on to for a bit? We're only talking about a few kB. That said, properly
> > walking the entire cmdline without having to specify an arbitrary limit
> > ahead of time does sound slightly more end-user-friendly. I'll give this
> > patch a spin here.
> 
> Well, it's 8 MB at least because of kmalloc and more when it starts
> to vmalloc, so either you increase but keep the limit, or allow
> to pin semi-arbitrary amount of kernel memory IF you want to stay
> with seqfile. My patch requires just 1 page plus whatever g_u_p
> requires.

Okay, I've tested this out some. Its definitely more user-friendly than
having to require a boot param, and as a bonus, its even more
memory-efficient. Yes, its a bit fugly, but such is life sometimes...

Though I do wonder if this should perhaps be a helper in mm/util.c like
get_cmdline, maybe replacing get_cmdline or adding an alternative that
gives you everything, rather than an arbitrarily limited length. I only
see one other place actually using get_cmdline so far.

Tested-by: Jarod Wilson <jarod@...hat.com>
Acked-by: Jarod Wilson <jarod@...hat.com>

-- 
Jarod Wilson
jarod@...hat.com

--
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