From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16092 invoked from network); 25 Sep 2020 20:34:43 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 25 Sep 2020 20:34:43 -0000 Received: (qmail 30169 invoked by uid 550); 25 Sep 2020 20:34:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 29974 invoked from network); 25 Sep 2020 20:13:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:autocrypt:message-id:date:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=a07YBiGWQky4l0OdHRnTzR6GCPGBHHTcrHOByJSTwkU=; b=j4k5SjmO7KUZu9f3Itv+Njy5Y9oySgKhIPEDBYdOpOVWUSaR4PozfXyPtUFf5Oqntd E7DUWDwRCTwUzVUMruVY+zPNsk3wUagHr8OQJ7mvR+AtYMkTkovmEj80EGPRJX6GlN2w SkxnKeU6nnJYreGoynErAJtN/YH/f/xfBuv9WqLiaEy+WaHI/gm716xSqpz21ZBO6JZ3 fkl+ZR6rytj/v4kku9K1Dw783MnJPmwOY3Gf0pZuQOqSWrmozyvbpKkLsieg2TGcMOAQ SFyzqAaMchxeWXCu2sTFS2j44a+dvpJ2wRWffNj4p2tpkBGY7XoeNVv56pt6JjASwxzn OpDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:autocrypt:message-id :date:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=a07YBiGWQky4l0OdHRnTzR6GCPGBHHTcrHOByJSTwkU=; b=py+HZss9q2g348xBS5HtOEZ43Pz8m+ZwfodfvJi35ZBSzA/d87PwBkZBdFTIYtSZFz N8hvk7i/yTIz7mMMfmVrxG6m8PEfeU5JtjNGW/l/XL1fa+rLEyDYnkVldDCtPcfXOnX6 SkUlZVeKnO+xPhSc0Hmj15G6JajfX/wmTHOaubGkugi5BoMaVZe/xTgBN1J+3JAyxoxM iCToa7+/3rj2ukfvQIBNPOLSAEdTPa/RdVnWDND9DtLibH+AHpZ89ZRvFyABdbDt/LvB ExAXpxaxFw7IfFRUdZsW29LJSbVF3uluKCL2j9xKqouVUHqFmYRCYJ0kXLjd1+6iF1Q2 hpwQ== X-Gm-Message-State: AOAM530FttspHQpPo4muoeJLXbJI9kTnpx1vbicrsJNpyeY1dOy8dbua goTP+IiUw9lV/8ESnZSWA49tdOQFJoK29w== X-Google-Smtp-Source: ABdhPJzOAOClT0bTQi4Oi/WLTAt8wLJyGE9VNNyNnVTk768dlRXRe9FSE+V1HeC8wkVIorvyRTz9dQ== X-Received: by 2002:ac8:24b9:: with SMTP id s54mr1490665qts.138.1601064787738; Fri, 25 Sep 2020 13:13:07 -0700 (PDT) To: musl@lists.openwall.com References: <20200925093733.GJ2947641@port70.net> From: Dominic Chen Autocrypt: addr=d.c.ddcc@gmail.com; prefer-encrypt=mutual; keydata= mQENBFbtu7sBCAC7ru9QmXnDTLz717MCDXn7pFPCFAEFsA7ryeU6CkztMi10bd910sHIIOkn Vr/qWNywDIZ/PO1bGQ+muVYXuT7XN3NQ3ei1+jIn/+VWkCSyVqDrwfF4E0egPqvrnYG20KIC sRkNrQQ+Sa64K2a0VVI2oamLWOsnAz7R9M7+ftpWYU4S7288ZNOVxFc8vxXUxPvnyVQ1NRRC hHZO1oVm73wAnxT0V2d7NHEIji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Q8HgJBKe5xjNEiXNwWgf+KmpCWQfcgiOah59Mk6x8dzv/2EWX18pN/EykwNxL 2uIOlG6LDK177xHSDV/04vb/ZwE24o6Lk0AhdPn2xh49CuJUeBzxF5KlH4ti1bzK3AWlzhs9 91YXcN7kZo+I3Uu3rw0nrynPuV4lRc7rSAc9akRPRDuMNJduAgDJKItZ7w1J0T4fHH0XN8Gf DTDxh/mc/qWFOsEJwe6CpiAZRhVXKzKPp7YuPKzj8XmaWaKf8dgQLYduFxMrSGLNRZP4OHoD CSatCSZbMTQW/P6vFKuCeHpkriI75pCa9YYB1m9Za33D5iMstqJ+j8J/5evaL4Pz7krTGowD SP1d4L0/7aR4qw== Message-ID: <7318ee2c-17f5-99a9-12e4-622fe94cbfe2@gmail.com> Date: Fri, 25 Sep 2020 16:13:19 -0400 MIME-Version: 1.0 In-Reply-To: <20200925093733.GJ2947641@port70.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Subject: Re: [musl] SIGSEGV with TEXTREL On 9/25/2020 2:58 PM, Rich Felker wrote: > On the other hand, there's no compelling reason to support textrels in > the main program since the main program can just be linked as non-PIE > if you have object files (e.g. due to asm source files or static > libraries you don't have source to) that are not PIC-compatible. I'm actually comparing the overheads of various security mechanisms, so I need to build with PIC and RELRO/BIND_NOW for ASLR. On 9/25/2020 5:37 AM, Szabolcs Nagy wrote: > there are no existing libcs that fully support textrels > (since for that not just dynamic relocs but static relocs > need to be supported too). I only need TEXTREL support for dynamic relocations, so static relocations aren't an issue. > glibc only supports a small set of textrels and of course > it has to mark the code executable+writable which means > (1) the code cannot be shared across processes, it will > actually use physical memory where the modified code is > stored per process which is not ideal when you work with > large code model, (2) all security policies have to be > turned off that prevent exec+write mappings for this to > work at all which is not acceptable in many environments. I don't see how (2) applies. Both glibc and the previous patch only remap text segments writable during relocation processing, and then remap them back read-only immediately afterwards. If you're referring to W^X, text segments don't need to be executable during relocation processing either, so that can be avoided. > for these reasons it is considered to be a bug to create > binaries with textrels. i think large code model should > not need textrel on x86_64: there should be a way to > create >4G pc relative offset in code that does not need > any relocs. (or do you have some example where that fails?) Before D47211 (Clang/LLVM 7.0.0), PIC with the medium or large code models is unsupported, and the compiler will silently ignore the PIC flag. > dynamic linker failure diagnostic is something musl could > improve i think. How about something along the lines of the following? > >> diff --git a/ldso/dynlink.c b/ldso/dynlink.c >> index d7726118..c7449df2 100644 >> --- a/ldso/dynlink.c >> +++ b/ldso/dynlink.c >> @@ -1326,10 +1326,32 @@ static void do_mips_relocs(struct dso *p, size_t *got) >> >> static void reloc_all(struct dso *p) >> { >> size_t dyn[DYN_CNT]; >> for (; p; p=p->next) { >> if (p->relocated) continue; >> decode_vec(p->dynv, dyn, DYN_CNT); >> + >> + if ((dyn[0] & 1<> + error("Warning: TEXTREL not supported!", >> + >> if (NEED_MIPS_GOT_RELOCS) >> do_mips_relocs(p, laddr(p, dyn[DT_PLTGOT])); >> do_relocs(p, laddr(p, dyn[DT_JMPREL]), dyn[DT_PLTRELSZ], >>