From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 414853858D28 for ; Tue, 14 Dec 2021 15:15:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 414853858D28 Received: by mail-pl1-x636.google.com with SMTP id y8so13783356plg.1 for ; Tue, 14 Dec 2021 07:15:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MriSPQqJT7kJBMY1wo0A+hIGk2PPmE7TSOxmHpq1dzg=; b=OAsYNLlvsvuPV5KQCx8tkrsNNZRJ6gy4bw0PHGBXf0TRfvgm9pOBEDoQgNne3qDBXo dKfHNNdsd6KUwU1UABLS9Dap2XiwragX1QmjbEns2nui7EwG7MEGN9PBBF8DTdFh/vDu ABXKT49G18bxLxRuc9yCneHpnfFeyjd5BiJSH6f1GYoAMEMa54XF4SLS44v4Mz4NLNIe dP9+g2WdT2j4cumCn/7u+axS6/RyQRD3R88/b6+50Lael3j5btHW3Zr5t4Kq7qwNjQUx bJVBG1kvlGHrzrojkQal8kYWaGajrJCPSU1/67exe0Lnmz4wytldgIbzGZ/nY3eNxyml 5J9w== X-Gm-Message-State: AOAM531o8vW/9Utv+iJiGYdTtReFj4+GYnvAoH1fH9cur0Pn5LfPu5zQ LRsewOJsd3KNX5rYHOYOIdtFbk2PhOpHLry6lCM0JEkCQ/Q= X-Google-Smtp-Source: ABdhPJw6Zbfv7oXDVMYjCAEZFRP68egKCSKFQwhowA1gdNbd1vqCCXmU9e/D4F39LnNBCd34/sqs4v9yyHAV4Bg/J1Q= X-Received: by 2002:a17:90b:1e0e:: with SMTP id pg14mr6227066pjb.143.1639494950296; Tue, 14 Dec 2021 07:15:50 -0800 (PST) MIME-Version: 1.0 References: <20211213152057.151438-1-hjl.tools@gmail.com> <3e6b30a4-cf8a-49c9-7382-3f3255c8201a@linux.alibaba.com> <87y24nskgi.fsf@oldenburg.str.redhat.com> <877dc7qn6g.fsf@oldenburg.str.redhat.com> In-Reply-To: <877dc7qn6g.fsf@oldenburg.str.redhat.com> From: "H.J. Lu" Date: Tue, 14 Dec 2021 07:15:14 -0800 Message-ID: Subject: Re: [PATCH] elf: Align argument of __munmap to page size [BZ #28676] To: Florian Weimer Cc: "H.J. Lu via Libc-alpha" , Rongwei Wang Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3028.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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, 14 Dec 2021 15:15:53 -0000 On Tue, Dec 14, 2021 at 6:24 AM Florian Weimer wrote: > > * H. J. Lu: > > > On Mon, Dec 13, 2021 at 11:40 PM Florian Weimer wrote: > >> > >> * H. J. Lu via Libc-alpha: > >> > >> > On Mon, Dec 13, 2021 at 6:49 PM Rongwei Wang > >> > wrote: > >> >> > >> >> Hi, HJ > >> >> > >> >> Thanks for your help to fix this bug. And I just found out that the > >> >> patch "elf: Properly align PT_LOAD segments" had been merged into > >> >> glibc/master. > >> >> > >> >> And I saw Florian's email: > >> >> > >> >> > We should check munmap failure though and rollback everything if > >> >> > necessary. It's possible we can undo the initial PROT_NONE mapping even > >> >> > if future munmap calls fail because unmapping the first mapping does not > >> >> > need to split a mapping. > >> >> > >> >> It seems rollback initial PROT_NONE mapping when munmap fails is good > >> >> idea. Nice to have. Of course, IMO, this your patch is also can fix this > >> >> munmap failure well. what do you think? > >> >> > >> >> When this fix is stable in glibc upstream, I will backport it into our > >> >> internal glibc repo. So, if you have any improve this fix suggestions, I > >> >> will respond immediately. Sorry for my speed is much slower than your. > >> >> > >> >> > >> > > >> > Let's wait for a few days. > >> > >> Can we please fix the regression in some way? It impacts development, > >> particularly at this late stage during the 2.34 cycle. > >> > >> Either revert the change, or at least add the unchecked __munmap, and > >> fix that later. > > > > What is the unchecked __munmap? > > The __munmap at the end: > > diff --git a/elf/dl-map-segments.h b/elf/dl-map-segments.h > index 70a4c40695..54e606aa87 100644 > --- a/elf/dl-map-segments.h > +++ b/elf/dl-map-segments.h > @@ -55,6 +55,7 @@ _dl_map_segment (const struct loadcmd *c, ElfW(Addr) mappref, > if (delta) > __munmap ((void *) map_start, delta); > ElfW(Addr) map_end = map_start_aligned + maplength; > + map_end = ALIGN_UP (map_end, GLRO(dl_pagesize)); > delta = map_start + maplen - map_end; > if (delta) > __munmap ((void *) map_end, delta); > This is https://sourceware.org/pipermail/libc-alpha/2021-December/134097.html I am checking it in now. Thanks. -- H.J.