Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751936AbdF3OWX (ORCPT ); Fri, 30 Jun 2017 10:22:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:44181 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751560AbdF3OWW (ORCPT ); Fri, 30 Jun 2017 10:22:22 -0400 Date: Fri, 30 Jun 2017 16:22:18 +0200 From: Michal Hocko To: Anshuman Khandual Cc: Linux Kernel Mailing List , Ingo Molnar , Alexander Viro Subject: Re: Question regarding MAX_ARG_STRLEN with execve() Message-ID: <20170630142218.GB22923@dhcp22.suse.cz> References: <8138c533-dae2-6a6a-fabd-d090b72d4d99@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8138c533-dae2-6a6a-fabd-d090b72d4d99@linux.vnet.ibm.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 Content-Length: 1137 Lines: 36 On Fri 30-06-17 11:59:37, Anshuman Khandual wrote: > Hello, > > execve() system call should support argument length of > MAX_ARG_STRLEN (PAGE_SIZE * 32). On 64K page size systems, we > are not able to pass 32 * PAGE_SIZE arguments into the execve() > system call because of the following reasons. > > * struct linux_binprm's vma starts with a size of PAGE_SIZE > > vma->vm_end = STACK_TOP_MAX; > vma->vm_start = vma->vm_end - PAGE_SIZE; > > * The VMA expands as much depending upon the argument size. So > for 32 * PAGE_SIZE argument, it becomes 33 * PAGE_SIZE. > > * 33 * PAGE_SIZE with 64K pages fails the following test in > get_arg_page() function. 33 * PAGE_SIZE is more than 2MB > (8 MB /4) with 64K page size. > > if (size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur) / 4) > > * Right now RLIMIT_STACK is hard coded 8MB which does not take > PAGE_SIZE into account. > > Wondering what should be the solution for this problem ? > > * Change the default stack size from 8MB ? just increase the ulimit if you want to use such a large arguments. > * Change the ratio test from 1/4th ? -- Michal Hocko SUSE Labs