From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751830AbbEZVYb (ORCPT ); Tue, 26 May 2015 17:24:31 -0400 Received: from mail-wi0-f173.google.com ([209.85.212.173]:34654 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbbEZVY2 (ORCPT ); Tue, 26 May 2015 17:24:28 -0400 Date: Wed, 27 May 2015 00:24:23 +0300 From: Alexey Dobriyan To: Jarod Wilson Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH try #4] proc: fix PAGE_SIZE limit of /proc/$PID/cmdline Message-ID: <20150526212422.GA6637@p183.telecom.by> References: <20150508122805.GA27370@p183.telecom.by> <5564DABC.50400@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5564DABC.50400@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 26, 2015 at 04:42:36PM -0400, Jarod Wilson wrote: > On 5/8/2015 8:28 AM, 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 ask 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. > > > > There should be real setproctitle(2) or something. > > > > Signed-off-by: Alexey Dobriyan > > Tested-by: Jarod Wilson > > Acked-by: Jarod Wilson > > Should have tested on more than just x86, it appears. We've started > hammering on this internally across all arches, and its exploded > multiple times on ppc64 now: > > [ 2717.074699] ------------[ cut here ]------------ > [ 2717.074787] kernel BUG at fs/proc/base.c:244! > OE-------------- 3.10.0-255.el7.ppc64.debug #1 Which BUG_ON is this? BUG_ON(*pos < 0); BUG_ON(arg_start > arg_end); BUG_ON(env_start > env_end);