From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63ED6C47253 for ; Fri, 1 May 2020 19:03:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1620420857 for ; Fri, 1 May 2020 19:03:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=landley-net.20150623.gappssmtp.com header.i=@landley-net.20150623.gappssmtp.com header.b="rZ0wZNpF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1620420857 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=landley.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A59948E0005; Fri, 1 May 2020 15:03:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0A608E0001; Fri, 1 May 2020 15:03:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D2658E0005; Fri, 1 May 2020 15:03:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0143.hostedemail.com [216.40.44.143]) by kanga.kvack.org (Postfix) with ESMTP id 722E28E0001 for ; Fri, 1 May 2020 15:03:55 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3DFCC4405 for ; Fri, 1 May 2020 19:03:55 +0000 (UTC) X-FDA: 76769074830.20.slip00_797f5765b6b16 X-HE-Tag: slip00_797f5765b6b16 X-Filterd-Recvd-Size: 7064 Received: from mail-ot1-f68.google.com (mail-ot1-f68.google.com [209.85.210.68]) by imf43.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 19:03:54 +0000 (UTC) Received: by mail-ot1-f68.google.com with SMTP id e20so3298126otk.12 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=BKr4jW4eGGNwxvSovbq83Y2hPp2c5/4cPyj1hGTHnGsv+bAZsA4kN68OR3jeXW4Snm T3P8GwXGKZsc2b4LthMi0Fo6eSzgjiV2p/39P+T+xqSZzN2xTRUBrEkC6TzSDTIZAdNJ esoYEVNIJZA/Hdj4DXWzCXpmjd6E76+39Np0qhnn68eu0T6B/sqZHp1jRTzWmv9dbSTX vkNMTILZ8wsI5Zs3SEIBWqMAE5Xn7+0EJOu9xb0sSefLo3Nl44wO0ORabWJdLORsB2Cw KE7OEfaS9znmPpXRqgXQl4SZ9IA9qvO+34iItaV9xD9i1H/lU7AYggHkSBJYoLOTVytZ 8YmA== X-Gm-Message-State: AGi0PuZKM8sygDQSFUP9aaxgbbBTSRrQs9qTEER2gO54tZJqjBPlwYau laNEMGH3QHdedEshoLalm6FRIg== X-Google-Smtp-Source: APiQypLpF0Ox0IO/qISGXS4LdidPlSkHRJysHJEBrOjiMzScpLoC5A3dEhhOSPrJ9hvlNYHsOmtChQ== 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.