From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 1EC983858C27 for ; Tue, 17 Jan 2023 15:49:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1EC983858C27 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-15085b8a2f7so32390455fac.2 for ; Tue, 17 Jan 2023 07:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zmPseUGx6gpDPi64m2lMS/BGsJ38zqO+NPyW8OLF85Y=; b=NMaThYNnyqnAT4vGMuT9pgyZD/t4mZBMTTnc2XcEEzvNDSstmtXlTKgE68vlmIAzqV S4w6S0nYJJuu+uNtIXt+AtqL2WwTX3W0XaY2qX5XGgdDq1Y7S6SaBdDTQc6NqyPNNGbu nNxFoaaMw0EBZAd8H+wddodYZCk2IbO3ke29d7ip3osnWj6gKmWx5ykfaFGxBl8s3Ugx V08W27xcvA5TvAst4N7YE+pQCrudmAWrnR/qd+rX//q60k2poNUKyOIqJ9J4pnB1BPq/ Naszn8m5tIrEtU1UJ+4DGdNZ0hwQHMtT572+wUB2NLnlD1NjMPZx3Axz/mGmMbcEnXe7 qZ0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zmPseUGx6gpDPi64m2lMS/BGsJ38zqO+NPyW8OLF85Y=; b=F7lgwHPiPCqpYdlGqRcTtyiKd0h4SNtakaBxbIRAVy2iz5T50tsDH687JJFgNSFDkF kxV6QMJbdK9p8PhDySWO9Q+Uv8gTp7h6aJf9JIXrhQwOGewIxe1UhnAxp0ColjLIrQNa l77B3EcsCQTT5cCxxOCmLbWDAxEtwsuia/pxpWPoorJC/R4wZxVxBuq1vB92K9nzYtoj /O/eoFcGVHEbl0dDJmBQI1IxuJE8b6x/6rEetmQxrw5sFFkXfC4bDDq6/aWNEMah+AcM ztGB030jjF6zB13i0ZeEZkddTSac8y1n9evo7vS18Up+t9a9MtSRBOJ9ROfILNDFLPNb 3LJg== X-Gm-Message-State: AFqh2kpfYrSGKUsnH9Hi2w6whRmHsTH0Z9HPyDuSJZzIyHXnqQoqZYgF K2hpwdYm67YvLTl+F8+pHTx8aP2xVlV4m16TXY0NX0+J5xQ= X-Google-Smtp-Source: AMrXdXtTXVO24nfJkVakhEnj8aB8XtoiEh45W2gS+mlSzZSBmpVTfNsv+jQ7a1BY0/txTkeGtKKjdqXcPPXmcFRZaac= X-Received: by 2002:a05:6871:89f:b0:15f:1c32:db99 with SMTP id r31-20020a056871089f00b0015f1c32db99mr323026oaq.266.1673970565145; Tue, 17 Jan 2023 07:49:25 -0800 (PST) MIME-Version: 1.0 References: <87zgah7fv1.fsf@oldenburg.str.redhat.com> <6b782360-131f-df4c-9dc4-6765d0fb8c24@linaro.org> <878ri15jqt.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Tue, 17 Jan 2023 07:48:49 -0800 Message-ID: Subject: Re: Why does _dl_protect_relro align the end address down? To: Adhemerval Zanella Netto Cc: Florian Weimer , Joel Molin via Libc-help , Joel Molin Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3016.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Jan 17, 2023 at 6:30 AM Adhemerval Zanella Netto wrote: > > > > On 17/01/23 11:16, Florian Weimer wrote: > > * Adhemerval Zanella Netto: > > > >> On 17/01/23 04:57, Florian Weimer via Libc-help wrote: > >>> * Joel Molin via Libc-help: > >>> > >>>> Since mprotect will protect entire pages anyway, wouldn't it make a lot > >>>> more sense here to say `end = ALIGN_UP(...)`? Apart from feeling more > >>>> intuitive, it also seems like it would avoid page size inconsistencies > >>>> between runtime and link editing like the one above. > >>> > >>> ALIGN_UP might make memory read-only that should not be. > >>> > >>> There's some discussion about the alignment here: > >>> > >>> PT_GNU_RELRO is somewhat broken > >>> > >>> > >>> I still think this is fairly broken, but there does not seem to be much > >>> desire to fix it. > >> > >> It was not clear to me from that discussion what you think it is still > >> broken with PT_GNU_RELRO. > > > > Using ALIGN_DOWN for the start address can't be right. > > > > Do we have a bug report for this? Because H.J explanation [1] only describes > ld support for the end of the RO segment. > > [1] https://sourceware.org/pipermail/libc-alpha/2022-May/138642.html If the end of the PT_GNU_RELRO segment isn't page aligned, ALIGN_UP may change the executable page to read-only. -- H.J.