Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp980873ybz; Fri, 1 May 2020 12:05:50 -0700 (PDT) X-Google-Smtp-Source: APiQypKB6ZFyHi6MDgkSc3+VRZ8CuVJ16UUi+fWFUZZVdORUqPbx4jUX8p8GjBhSEF7tQCPOpCWa X-Received: by 2002:a17:906:2b89:: with SMTP id m9mr4482107ejg.302.1588359950455; Fri, 01 May 2020 12:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588359950; cv=none; d=google.com; s=arc-20160816; b=mplv3+e1WoYHO4XqScJMYUUa/K5AQ9RsK/5jFqxnZHPLrqU2j+165CCKLNigsFumWx IJ+goEYeydGlpowIKA6UUJREDU+QpCAe+/jFaLppqK/3ZCSLFUOMIEcDRl3K/Hx9lccS PLaF7+WWHcvwECcdyFeFhwo8j6xQed28OJVq2hOmoXU4MNL+V6c9SX8WFLQPWugRMFmI YcZlF5JMeV+fHsdKCI+M5qPgLTZ6PtK5Qu26IbAiOxBtHfYE7VVW/KwDXdEVboj8xt61 Uzx0ovf2Z9C0JXJR6AS8m2BDjhTB+XS1CKjPdXkvpgxok4hnGm2qsFMO5zMER07h3dHR C6pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=dV5C6Mdo+d2z1U4ixXFwa14iL+t03v6nPukDTsNC/Pw=; b=Cfy1+nxi5FtczWZvd0w1+FRF623XHCsoaVWXCSKyjTkPUWC4WJYio1slwfW2qwGkn8 kDRpVFpwYEy3SXAAlvI4vo0B51a/ceSK99v4CGyCLqafOV8+sjplAuVwcPL05Tqu09Yy 6AAsp8C/1P3icEHMvQ+pDOz8Km/CDtwHKRugTNV3UdViqHw396OFrKlWZjwMbjGrl/iZ yQVekuJ0WVoGi1d+nX+MgomUPl4FNQrgtikan7drdozBtana9GiXD6NAZubWUsxwchE5 oxwvUc30Rdjlv6cNusldb9bA5d6kCcFu7Vh9qBMnIsHJkiJEqqQIRa432C0mAjMfgu7a /GdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=rZ0wZNpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu44si2245763ejb.394.2020.05.01.12.05.27; Fri, 01 May 2020 12:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@landley-net.20150623.gappssmtp.com header.s=20150623 header.b=rZ0wZNpF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730487AbgEATD4 (ORCPT + 99 others); Fri, 1 May 2020 15:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729953AbgEATDy (ORCPT ); Fri, 1 May 2020 15:03:54 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9289C061A0C for ; Fri, 1 May 2020 12:03:54 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id b13so3351949oti.3 for ; Fri, 01 May 2020 12:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=landley-net.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=dV5C6Mdo+d2z1U4ixXFwa14iL+t03v6nPukDTsNC/Pw=; b=rZ0wZNpFKPj00rZsGXQ/OEy65W5RTZI1U2mldKOKzrK3O8YxNmuwVKAmgNGlrMSPJh dQ3h/11zRchfbBtSsQytLXthXnqjbswFFdOTKhvnJz2vylobGQeZ+LFvJofa3n+r2q6h dCWQyfMflvlzhIlaKHECXHUiyMqYb5bOSgYxPZbKUIJ6kUtcquH4lk62KWBOPOZ0l2ly 3GJhN0ZjLbVF5/vkNCtpBlDafYpeOL+d8ft0arZhky+HvLzbqIp0tD5btouJClcvo4hf 7MIo2rkjDqc6lk3WUSAmT2r4xYoI+Vso+T69h2J6g+m95bxiajkPrGm0RbCSU1AKatT5 HKQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=dV5C6Mdo+d2z1U4ixXFwa14iL+t03v6nPukDTsNC/Pw=; b=guOZP1lLJl4fZwHjGw1EiaJ4KS9wEM+3d6b6AmWUArv/Tc1PRRkhDSUP6Djgggibry 8rm0amlTYLCG7MmjwB5djjQeEG82zmJQ9LsIS2l2k1uBabObAiFcY6pFPocHJU1Nss/f PqOvM25/L53SwElGDhWaooPsSgFW3nC7COSUBi1KwTgaZ8aCXZgIqak3SQOpCVUO8lcI /d593qdAc+AGEYAIxbYc9Mz7eaHXnLyJOMocOFAtUMRfq5fsJeXzV6e8JRIgjXLBiRFF lVJLUET20/u3+0XX0UbtDLkzSIQwMW2gLiUiBt5RFHdwdCAO2SubHoLmM+0smjaNeUdj 66fA== X-Gm-Message-State: AGi0Pub9chn63GL++96W+QbbtK4v2gAXQeRzVzKA+kEEs6ydG7GIS/i2 zTL6a6lWMO2SfjdcU3e7CaDNeg== X-Received: by 2002:a05:6830:20d9:: with SMTP id z25mr4236191otq.254.1588359834043; Fri, 01 May 2020 12:03:54 -0700 (PDT) Received: from [192.168.86.21] ([136.62.4.88]) by smtp.gmail.com with ESMTPSA id c26sm1024801otl.49.2020.05.01.12.03.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2020 12:03:53 -0700 (PDT) Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there To: Greg Ungerer , Rich Felker Cc: Linus Torvalds , Russell King - ARM Linux admin , Jann Horn , Nicolas Pitre , Andrew Morton , Christoph Hellwig , Linux Kernel Mailing List , Linux-MM , linux-fsdevel , Alexander Viro , "Eric W . Biederman" , Oleg Nesterov , Linux ARM , Mark Salter , Aurelien Jacquiot , linux-c6x-dev@linux-c6x.org, Yoshinori Sato , Linux-sh list References: <20200429214954.44866-1-jannh@google.com> <20200429215620.GM1551@shell.armlinux.org.uk> <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> <20200430145123.GE21576@brightrain.aerifal.cx> <6dd187b4-1958-fc40-73c4-3de53ed69a1e@linux-m68k.org> From: Rob Landley Message-ID: Date: Fri, 1 May 2020 14:09:56 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <6dd187b4-1958-fc40-73c4-3de53ed69a1e@linux-m68k.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/1/20 1:00 AM, Greg Ungerer wrote: >> This sounds correct. My understanding of FLAT shared library support >> is that it's really bad and based on having preassigned slot indices >> for each library on the system, and a global array per-process to give >> to data base address for each library. Libraries are compiled to know >> their own slot numbers so that they just load from fixed_reg[slot_id] >> to get what's effectively their GOT pointer. fdpic is to elf what binflt is to a.out, and a.out shared libraries were never pretty. Or easy. >> I'm not sure if anybody has actually used this in over a decade. Last >> time I looked the tooling appeared broken, but in this domain lots of >> users have forked private tooling that's not publicly available or at >> least not publicly indexed, so it's hard to say for sure. > > Be at least 12 or 13 years since I last had a working shared library > build for m68knommu. I have not bothered with it since then, not that I > even used it much when it worked. Seemed more pain than it was worth. Shared libraries worked fine with fdpic on sh2 last I checked, it's basically just ELF PIC with the ability to move the 4 segments (text/rodata/bss/data) independently of each other. (4 base pointers, no waiting.) I don't think I've _ever_ used shared binflt libraries. I left myself breadcrumbs back when I was wrestling with that stuff: https://landley.net/notes-2014.html#07-12-2014 But it looks like that last time I touched anything using elf2flt was: https://landley.net/notes-2018.html#08-05-2018 And that was just because arm's fdpic support stayed out of tree for years so I dug up binflt and gave it another go. (It sucked so much I wound up building static pie for cortex-m, taking the efficiency hit, and moving on. Running pie binaries on nommu _works_, it's just incredibly inefficient. Since the writeable and readable segments of the ELF are all relative to the same single base pointer, you can't share the read-only parts of the binaries without address remapping, so if you launch 4 instances of PIE bash on nommu you've loaded 4 instances of the bash text and rodata, and of course none of it can even be demand faulted. In theory shared libraries _do_ help there but I hit some ld.so bug and didn't want to debug a half-assed solution, so big hammer and moved on until arm fdpic got merged and fixed it _properly_...) Rob P.S. The reason for binflt is bare metal hardware engineers who are conceptually uncomfortable with software love them, because it's as close to "objcopy -O binary" as they can get. Meanwhile on j-core we've had an 8k ROM boot loader that loads vmlinux images and does the ELF relocations for 5 years now, and ever since the switch to device tree that's our _only_ way to feed a dtb to the kernel without statically linking it in, so it's ELF all the way down for us.