From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932925AbbDJSBh (ORCPT ); Fri, 10 Apr 2015 14:01:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55603 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932592AbbDJSBe (ORCPT ); Fri, 10 Apr 2015 14:01:34 -0400 Date: Fri, 10 Apr 2015 14:01:32 -0400 From: Jarod Wilson To: Alexey Dobriyan Cc: Andrew Morton , linux-kernel@vger.kernel.org, "Eric W. Biederman" , Al Viro , Miklos Szeredi , Zefan Li , Oleg Nesterov Subject: Re: [PATCH try #3] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline Message-ID: <20150410180132.GB13391@redhat.com> References: <1428638342-6782-1-git-send-email-jarod@redhat.com> <20150409211200.78b8631e.akpm@linux-foundation.org> <20150410121838.GA13391@redhat.com> <20150410141140.GA27200@p183.telecom.by> <20150410141329.GB27200@p183.telecom.by> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150410141329.GB27200@p183.telecom.by> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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