Received: by 10.223.164.202 with SMTP id h10csp1331150wrb; Wed, 15 Nov 2017 18:01:40 -0800 (PST) X-Google-Smtp-Source: AGs4zMaDTa6dkEugqEgYhpjYrsCmX6h7V4V/3D/uKAocJa/suYCb09kcM2vJ0rMwj9SOx6tgmeu2 X-Received: by 10.98.70.132 with SMTP id o4mr98962pfi.102.1510797700008; Wed, 15 Nov 2017 18:01:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510797699; cv=none; d=google.com; s=arc-20160816; b=vF+K1+o93ayVYm9zRSs/Bx0MkYOLF5VrHMPL//YOFwGbuLbuDPBGXdnyYxeH4RQfsz /d37Qt/TNxpdUjMaLZMgthf/DtpFNJ5K5v7IF0C84FPK7sqlZijQ3idTx72YuTcpKBDs WSGn7MoU+sQ0tbgDeyVOIBBVH3nVjYTMyiyHvur9I6k3pCFa7WyWehybvsj/gPgp2oCl mC81JsIq84Dc6x9xejIJdHqo2yyjNVtpWoU+8pm1r06SicmVmMUEuhS2h5W/aQaNdAIA srQZ8Fbmqz5YtqUYVeMsNhc+KJC3Q0BoJywF84n3UzpZ4F4X67tGmfU8twIlqIZVBnqU QWGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=WuKJtUVBRjN2y0L6xnyCy9xLkeCKbj9++7Ytpxi0XJw=; b=HDQvjjpk84PojKBshPzX5iZSBXcJOuTLrRWpXZyW7m1AUumf25+9w0WJdY+oCc1a66 1YvOu7PALjVHei+dkAoDOwbfdFJAM0HFkGdKueehChgSwwkmhFsrrQIZgZ7hfLPdNEtF 7gStughU6DQ5hPWXlCCZ4atJABlPTZatIVlDqGIj64veHypPScr7k0hC4pn71/rdSENQ rTecT6toNLmj+YwmavksnZNW024QpFcVQ0njSGFwWxscRjsJ7uIwhO4S1yrcfbgMVdqx ALJymQ/exgK3Q5xSdb48V4fazfeBn07l/0PC3zaXNwxMR7ZHCf22b7wtgrOIwTDc2CQA Zipw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UUT8XVQC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p3si6147pld.546.2017.11.15.18.01.23; Wed, 15 Nov 2017 18:01:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UUT8XVQC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757422AbdKOWKq (ORCPT + 89 others); Wed, 15 Nov 2017 17:10:46 -0500 Received: from mail-ot0-f180.google.com ([74.125.82.180]:52154 "EHLO mail-ot0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752585AbdKOWKj (ORCPT ); Wed, 15 Nov 2017 17:10:39 -0500 Received: by mail-ot0-f180.google.com with SMTP id b54so8784082otd.8 for ; Wed, 15 Nov 2017 14:10:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=WuKJtUVBRjN2y0L6xnyCy9xLkeCKbj9++7Ytpxi0XJw=; b=UUT8XVQChDr4I6GpkV2Bst89ncjk9DiJSlLVFG3Rhnza1S0ySsGof6KtXkKELqw0lc Khr/I7PcH9v+tElkNGter1VN+esGJxxUkLRkus8CwpXO5XiPkMhiVQS7+N8609SCT5d/ tOrTGsPwjdWkGsLtzClWYhD4ZXLQTqKmrMd8LpNePX9sj/alFxhOR7ln5jqhPcycyoQ2 8s3AJCQ6CCez9NR9ab34ZPhNTBhpxAwf9CX9VCAATzvTGkZxAEGYRL486PAVgqA3MDcz GfpYPF1BD+4Vo0zEdR7EJhMZt1or2lE0ZigK2AUtS7+jlhCavGLtjsjZiwFMkeUfehCq tIIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=WuKJtUVBRjN2y0L6xnyCy9xLkeCKbj9++7Ytpxi0XJw=; b=t0jhyBBRSaXaF8bjk9LRVU7OaCtO+em9hHi5ibp3YWF4JGsdWAkuXzYg02WL5he/4f hQQdmfFLu6UA9oMzoXXxZUridL1LCAfHgIC1dnb+Db+m3giz8vrBVV+b6gvrr+fOnKMi 7qO95iD06dN72sp6QPN2Fd8DNag8xwkNHjfn28mBqFWNYvR9PubbXx3u7EE/egUYlEqi 9BjsE5ktxMHNKNkMCtAgOttIkk7rcJ5KZnoUAavD2yO7tPuUuniTBOsRkLVQJcgDgg/R 6AI3BI63+9UUvIJUuEEaRNmWK7wb9XEj4g0c8n0sjiQFBK6xZVqG1/lj+z3UhvO0vqA7 pj+A== X-Gm-Message-State: AJaThX4sPTPvl/RxvzGlUhLW9WNN7K1yc4cprOD9znN2TOmkJN+Vnv+w zu2SxNUa2yhyQdvKfCX0H20tzZWMp5huk6pkMjMZ6A== X-Received: by 10.157.46.214 with SMTP id w80mr10507948ota.6.1510783838420; Wed, 15 Nov 2017 14:10:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.192.26 with HTTP; Wed, 15 Nov 2017 14:10:17 -0800 (PST) In-Reply-To: References: <0b3a9bd0-3046-cdab-cfee-0ca45ee64e8d@landley.net> <59f9380b-fc9b-c6a5-998a-a603ef828d1d@landley.net> From: enh Date: Wed, 15 Nov 2017 14:10:17 -0800 Message-ID: Subject: Re: Regression: commit da029c11e6b1 broke toybox xargs. To: Linus Torvalds Cc: Rob Landley , Kees Cook , Linux Kernel Mailing List , toybox@lists.landley.net Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 5, 2017 at 12:46 PM, Linus Torvalds wrote: > On Sat, Nov 4, 2017 at 5:39 PM, Rob Landley wrote: >> On 11/03/2017 08:07 PM, Linus Torvalds wrote: >>>> >>>> But it boils down to "got the limit wrong, the exec failed after the >>>> fork(), dynamic recovery from which is awkward so I'm trying to figure >>>> out the right limit". >> >> Sounds later like dynamic recovery is what you recommend. (Awkward >> doesn't mean I can't do it.) > > So my preferred solution would certainly be for xargs to realize that > _SC_ARG_MAX is at most an "informed guess" rather than some absolute > value. > > Or, alternatively, simply use a _SC_ARG_MAX that is small enough that > we can say "yes, that's what we've always supported". That, in > practice, is the 128kB value. > > It's probably also big enough that nobody cares any more. Sure, you > *could* feed bigger arguments, and we do end up basically supporting > it because people who don't write proper scripts will simply do > > grep some-value $(find . -name '*.c') > > and that works pretty well if your code-base isn't humongous. > > It still works for the kernel, for example, but there's no question > that it's still not something we *guarantee* works. > > It doesn't work if you don't limit it to *.c files: > > [torvalds@i7 linux]$ grep some-value $(find .) > -bash: /usr/bin/grep: Argument list too long > > so when the kernel expanded the argument list from the traditional > 128kB, it was for _convenience_, it was not meant for people who do > proper scripting and use xargs. > > See the difference? > >>> What _is_ the stack limit when using toybox? Is it just entirely unlimited? >> >> Answer to second question on ubuntu 14.04: >> >> landley@driftwood:~/linux/linux/fs$ ulimit -s 999999999 >> landley@driftwood:~/linux/linux/fs$ ulimit -s >> 999999999 > > Oh, I can do that on Fedora too. > > But the thing is, nobody actually seems to do that. > > And our regression rule has never been "behavior doesn't change". > That would mean that we could never make any changes at all. > > For example, we do things like add new error handling etc all the > time, which we then sometimes even add tests for in our kselftest > directory. > > So clearly behavior changes all the time and we don't consider that a > regression per se. > > The rule for a regression for the kernel is that some real user > workflow breaks. Not some test. Not a "look, I used to be able to do > X, now I can't". > > So that's why this whole "is this a test or a real workload" question > is important to me, and what odd RLIMIT_STACK people actually use. Android's default RLIMIT_STACK is 8192. the specific bug report was from an interactive shell user. i'm not aware of any part of the platform itself that relies on this, nor any third-party app. > I'm not interested in "can you reproduce it", because that's simply > not the issue for us from a regression standpoint. > > That said, I tried this under Fedora: > > ulimit -s unlimited > find / -print0 2> /dev/null | xargs -0 /usr/bin/echo | wc > > and it reported 991 lines. That would match just using 128kB as the > breaking point for xargs. > > So apparently at least Fedora doesn't seem to use that "stack limit / > 4" thing, but the traditional 128kB value. > > I don't know if that is because of 'xargs', or because of library > differences - I didn't check. > > And I have a hard time judging whether the regression report is a > "look, this behavior changed", or a "we actually have a real > regression visible to actual users". > > See above why that matters to me. > >> It sounds like "probe and recover" is my best option. > > I actually suspect "just use 128kB" is the actual best option in practice. for libc's sysconf(_SC_ARG_MAX) too? i'm fine changing bionic back to reporting 128KiB if there's an lkml "Linus says" mail that i can link to in the comment. it certainly seems like an overly-conservative choice is better than the current situation... > Sure, "probe and recover" is the best option in theory, but it's a lot > more complex, and there doesn't actually seem to be a lot of upside. > > So to take my silly example of piping "find /" to xargs: I can't > imagine that anybody sane should care really whether it results in > 900+ execve's (for that 128kB limit) or just 20 (for some "optimal" > 6MB limit). > > And there is actually a somewhat real fear with the > "probe-and-recover" model: the already mentioned nasty case "sometimes > we don't return E2BIG, we might just succeed the execve, but then kill > the process very early due to some _other_ limit being triggered". > > That nasty case really shouldn't happen, but it was the case we > considered (and rejected) for suid binaries. > > So that's the real reason the kernel behavior changed: we had a > security issue with the "we allow basically unlimited stack growth" > where a huge argv/envp could be used to grow the stack into some other > segment. > > Realistically, it was only a security issue with suid binaries, but as > mentioned in this thread, the problem is that we do the argument > copying even before we've decided whether the execve is going to be a > suid execve. > > So then - exactly so that we do *not* have that nasty case of "execve > succeeds, but we kill the process immediately if it turns into a > potential security issue", we do that "limit the stack growth for > everybody". > > Linus -- Elliott Hughes - http://who/enh - http://jessies.org/~enh/ Android native code/tools questions? Mail me/drop by/add me as a reviewer. From 1584179073465989296@xxx Thu Nov 16 00:08:14 +0000 2017 X-GM-THRID: 1582908659593594930 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread