From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward500c.mail.yandex.net (forward500c.mail.yandex.net [178.154.239.208]) by sourceware.org (Postfix) with ESMTPS id 1AEFA3858D1E for ; Wed, 29 Mar 2023 18:46:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1AEFA3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:25a4:0:640:2ec9:0]) by forward500c.mail.yandex.net (Yandex) with ESMTP id 2E26E5F054; Wed, 29 Mar 2023 21:46:44 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id gkN9oW5WwKo0-tpJB3BH7; Wed, 29 Mar 2023 21:46:43 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680115603; bh=ys7nUUav1P9Q0+gJ0yLfRW2OFBj5I1xdr8ZAW8Wiyy0=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=c25+x0jnuF6RrxgmRdm7gA2f4i2xf/mYNkX+CIK6zhWPnEw81y6yro8dLrNMDSd+Y O5YJq1wT65OsbG203mzKiE5uHyeOvTfQQytURtNWp11cMjVavnJJOvzgaJ9XMouLeg JMqAv4JcHGDqJiHx+DErHRYKN9MYOIsTjAkFWcuA= Authentication-Results: mail-nwsmtp-smtp-production-main-78.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <7c3c1d76-578b-4e9d-65fe-f53220fe0640@yandex.ru> Date: Wed, 29 Mar 2023 23:46:41 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH 02/13] elf: switch _dl_map_segment() to anonymous mapping Content-Language: en-US To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20230318165110.3672749-1-stsp2@yandex.ru> <20230318165110.3672749-3-stsp2@yandex.ru> <0ecd46af-74d2-a1ea-cd3f-88c7c9886c21@linaro.org> From: stsp In-Reply-To: <0ecd46af-74d2-a1ea-cd3f-88c7c9886c21@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 29.03.2023 23:29, Adhemerval Zanella Netto пишет: > On 29/03/23 15:00, stsp wrote: >> But its not ignored in glibc, see >> >> sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h >> >> Without that flag PREFER_MAP_32BIT_EXEC >> test fails. > Because elf/dl-load.h already defines MAP_COPY that handles it, so why > not use it instead? Would MAP_COPY be a good choice for explicitly anonymous mapping? If so - can change. >>> So basically it would add another mmap on program loading.  For instance, loading >>> a simple empty main programs: >> Yes, that's true. >> Is this a problem? >> >> > Yes, Linux limits a maximum mmap both per process [1]. This code increase both > the total mapping requires and runtime cost to setup a new shared library. > > [1] https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/vm.rst#max_map_count This talks about the map areas. I don't think map areas number changed. Extra syscall - yes. Extra map area - no. So I don't think my patch is a subject of the aforementioned system limit. >>> And it also slight change the mapping, using the same program: >>> >>> * Before: >>> >>>        0x7ffff7dc2000     0x7ffff7de8000    0x26000        0x0  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7de8000     0x7ffff7f54000   0x16c000    0x26000  r-xp   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7f54000     0x7ffff7faa000    0x56000   0x192000  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7faa000     0x7ffff7fab000     0x1000   0x1e8000  ---p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7fab000     0x7ffff7faf000     0x4000   0x1e8000  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7faf000     0x7ffff7fb1000     0x2000   0x1ec000  rw-p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>> >>> * With this patch: >>> >>>        0x7ffff7dc1000     0x7ffff7de7000    0x26000        0x0  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7de7000     0x7ffff7f53000   0x16c000    0x26000  r-xp   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7f53000     0x7ffff7fa9000    0x56000   0x192000  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7fa9000     0x7ffff7faa000     0x1000        0x0  ---p >>>        0x7ffff7faa000     0x7ffff7fae000     0x4000   0x1e8000  r--p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >>>        0x7ffff7fae000     0x7ffff7fb0000     0x2000   0x1ec000  rw-p   /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so >> Mm, was staring on this for a while, >> and file offsets and perms looks the >> same. What differences do you mean >> exactly? > The PROT_NONE mapping now does not have a file associated: > > 0x7ffff7fa9000 0x7ffff7faa000 0x1000 0x0 ---p > > This is not a problem itself, but again this change decrease the information > that some tools might use to analyze the memory mapping. Ah, that seems to be a "hole" are between segments. I actually think my handling is much better. Without my patch, such holes are filled with actually the _random_ page from the original file mapping. Just whatever page happened to have that offset. Do you think the random page from the file is a good idea for tooling/debugging?