All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarod Wilson <jarod@redhat.com>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Miklos Szeredi <miklos@szeredi.hu>, Zefan Li <lizefan@huawei.com>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [PATCH try #3] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline
Date: Fri, 10 Apr 2015 14:01:32 -0400	[thread overview]
Message-ID: <20150410180132.GB13391@redhat.com> (raw)
In-Reply-To: <20150410141329.GB27200@p183.telecom.by>

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.

-- 
Jarod Wilson
jarod@redhat.com


  reply	other threads:[~2015-04-10 18:01 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-10  3:59 [PATCH] fs/proc: allow larger /proc/<pid>/cmdline output Jarod Wilson
2015-04-10  4:12 ` Andrew Morton
2015-04-10 12:18   ` Jarod Wilson
2015-04-10 14:11     ` Alexey Dobriyan
2015-04-10 14:13       ` [PATCH try #3] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline Alexey Dobriyan
2015-04-10 18:01         ` Jarod Wilson [this message]
2015-04-10 22:09           ` Alexey Dobriyan
2015-04-13 18:28             ` Jarod Wilson
2015-04-13 20:23               ` Andrew Morton
2015-04-10 20:45       ` [PATCH] fs/proc: allow larger /proc/<pid>/cmdline output Andrew Morton
2015-04-13 18:24         ` Jarod Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150410180132.GB13391@redhat.com \
    --to=jarod@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=miklos@szeredi.hu \
    --cc=oleg@redhat.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.