[PATCH] linux: sysconf: limit _SC_MAX_ARG to 6 MiB [BZ #25305]
Andreas Schwab
schwab@linux-m68k.org
Tue Apr 13 12:13:19 GMT 2021
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 <adhemerval.zanella@linaro.org>
>>
>>> ---
>>> 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.
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."
More information about the Libc-alpha
mailing list