From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10380 Path: news.gmane.org!.POSTED!not-for-mail From: Alexander Monakov Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: sysconf(_SC_ARG_MAX) broken in musl. Date: Mon, 15 Aug 2016 01:11:23 +0300 (MSK) Message-ID: References: <20160810203602.GA15995@brightrain.aerifal.cx> <1524ba55-d337-e8a2-070a-ac554328fdf0@landley.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1471212716 23530 195.159.176.226 (14 Aug 2016 22:11:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 14 Aug 2016 22:11:56 +0000 (UTC) User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) Cc: Rich Felker , musl@lists.openwall.com To: Rob Landley Original-X-From: musl-return-10393-gllmg-musl=m.gmane.org@lists.openwall.com Mon Aug 15 00:11:53 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1bZ3dI-0005gy-Dd for gllmg-musl@m.gmane.org; Mon, 15 Aug 2016 00:11:52 +0200 Original-Received: (qmail 28024 invoked by uid 550); 14 Aug 2016 22:11:46 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28003 invoked from network); 14 Aug 2016 22:11:46 -0000 In-Reply-To: <1524ba55-d337-e8a2-070a-ac554328fdf0@landley.net> Xref: news.gmane.org gmane.linux.lib.musl.general:10380 Archived-At: On Sun, 14 Aug 2016, Rob Landley wrote: > What happens if your stack size is smaller than 131072? (Not > stacksize/4, but stacksize total?) I haven't tried, but a quick glance > looks like Bad Things. And on nommu systems, that may actually come up. >From reading the kernel source, I'm not sure what happens on nommu, but on mmu, from what I see, what's left for the program is rlimit, minus argv/env/auxv size, minus variable amount lost due to stack base randomization. In particular, yes, if rlimit_stack is below 128K and cumulative argv size is high, execve can fail. So is the concern that the reported sysconf(_SC_ARG_MAX) value is not useful when stack limit is low? But to know how many arguments you can pass in this highly constrained situation, you'd have to get rlimit, subtract environment size (and not even the current environment size, but the environment you're passing via execve), subtract the worst-case randomization loss, and finally subtract the amount of stack the invoked program is going to need. Alexander