From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by sourceware.org (Postfix) with ESMTPS id 572F43851C0C for ; Tue, 13 Apr 2021 14:41:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 572F43851C0C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=whitebox@nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4FKSwH2DzLz1s8Mv; Tue, 13 Apr 2021 16:41:19 +0200 (CEST) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4FKSwH1bQNz1t6p2; Tue, 13 Apr 2021 16:41:19 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id vfSWlPZKeP0U; Tue, 13 Apr 2021 16:41:18 +0200 (CEST) X-Auth-Info: CX3wu0zlmuvt857ASlgYVevE5qC9sF8DBXR7I+igfoAa5wu+nisnW1Vvtvd4UqHV Received: from igel.home (ppp-46-244-161-206.dynamic.mnet-online.de [46.244.161.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 13 Apr 2021 16:41:18 +0200 (CEST) Received: by igel.home (Postfix, from userid 1000) id D92252C3708; Tue, 13 Apr 2021 16:41:17 +0200 (CEST) From: Andreas Schwab To: Adhemerval Zanella Cc: Michal Nazarewicz , libc-alpha@sourceware.org Subject: Re: [PATCH] linux: sysconf: limit _SC_MAX_ARG to 6 MiB [BZ #25305] References: <20210407151058.1176364-1-mina86@mina86.com> <46c3ea60-7a57-14f7-92f9-e915e3b12dae@linaro.org> <87im4qe61s.fsf@igel.home> X-Yow: Bagels... Date: Tue, 13 Apr 2021 16:41:17 +0200 In-Reply-To: (Adhemerval Zanella's message of "Tue, 13 Apr 2021 10:36:29 -0300") Message-ID: <87eefedz76.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Apr 2021 14:41:23 -0000 On Apr 13 2021, Adhemerval Zanella wrote: > On 13/04/2021 09:13, Andreas Schwab wrote: >> On Apr 12 2021, Michal Nazarewicz wrote: >> >>>> On 07/04/2021 12:10, Michal Nazarewicz wrote: >>>>> Since Linux 4.13, kernel limits the maximum command line arguments >>>>> length to 6 MiB.¹ Normally the limit is still quarter of the maximum >>>>> stack size but if that limit exceeds 6 MiB it’s clamped down. >>> >>> On Mon, Apr 12 2021, Adhemerval Zanella wrote: >>>> Patch look good to me, thanks. >>>> >>>> Reviewed=by: Adhemerval Zanella >>>> >>>>> --- >>>>> sysdeps/unix/sysv/linux/sysconf.c | 5 ++++- >>>>> 1 file changed, 4 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c >>>>> index 366fcef01e..bd711795c7 100644 >>>>> --- a/sysdeps/unix/sysv/linux/sysconf.c >>>>> +++ b/sysdeps/unix/sysv/linux/sysconf.c >>>>> @@ -55,7 +55,10 @@ __sysconf (int name) >>>>> struct rlimit rlimit; >>>>> /* Use getrlimit to get the stack limit. */ >>>>> if (__getrlimit (RLIMIT_STACK, &rlimit) == 0) >>>>> - return MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4); >>>>> + { >>>>> + const long int limit = MAX (legacy_ARG_MAX, rlimit.rlim_cur / 4); >>>>> + return MIN (limit, 6 << 10 << 10); >>>> >>>> I think it a bit easier to read with the value expanded (6291456). >>> >>> I’d rather go with ‘6 * 1024 * 1024’ if shifts aren’t readable. >> >> In addition, I'd give it a symbolic name with a comment. > > What about: > > diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c > index 366fcef01e..aceedfa87c 100644 > --- a/sysdeps/unix/sysv/linux/sysconf.c > +++ b/sysdeps/unix/sysv/linux/sysconf.c > @@ -33,6 +33,9 @@ > actual value varies based on the stack size. */ > #define legacy_ARG_MAX 131072 > > +/* Newer kernels (4.13) limit the maximum command line arguments lengths to > + 6MiB. */ > +#define maximum_ARG_MAX 6291456 I'd still use 6 * 1024 * 1024 here, small numbers are much easier to grok. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."