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=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 3668AC83000 for ; Wed, 29 Apr 2020 23:03:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E3C50206D9 for ; Wed, 29 Apr 2020 23:03:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="DrKHR3jw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E3C50206D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 93C1F8E0005; Wed, 29 Apr 2020 19:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EC8C8E0001; Wed, 29 Apr 2020 19:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 829A38E0005; Wed, 29 Apr 2020 19:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id 6B8108E0001 for ; Wed, 29 Apr 2020 19:03:51 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1D6A5181AC1F5 for ; Wed, 29 Apr 2020 23:03:51 +0000 (UTC) X-FDA: 76762421862.11.roof97_3ea0f4991841a X-HE-Tag: roof97_3ea0f4991841a X-Filterd-Recvd-Size: 6237 Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 29 Apr 2020 23:03:50 +0000 (UTC) Received: by mail-lf1-f67.google.com with SMTP id r17so3145467lff.2 for ; Wed, 29 Apr 2020 16:03:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ur9jfHYBxvOMHwCSyzgCuO4pNPy1puU85FIa2ankgiI=; b=DrKHR3jwpIzSm+/wrDYjisbgySATaGLQu0oa0TojG2F2InX9rTKCVNl6/HZqurU3pj UJIyVXdxk5hO/DdTXuKDLWUrdoodxV3U8YTqMXkuAyOg5qLHqAdR8oZRRYrFIzlXyC4k sCR1zfwZ36sLzjhZCni2LVoS/XzTKFMv0dEak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ur9jfHYBxvOMHwCSyzgCuO4pNPy1puU85FIa2ankgiI=; b=dBuc9SaCBnzdViAZwWs4lfTP2slOjAl9U8bJGNHGkCEdsTemm+Y4kaCw9E3tREJ2dK QoZlZpMmVVfSuZTQR/TY8kIdok2RYCgtf6Xs2gpdJp0DSDlIgSXuF/bOjYVdW/XL+w7X 449gZdb2gJ5m0G/sFJLoFNJhiuu8Yr2Gbk54XUA9/Wp6YEdyIYYV+S0Tu9LzEwy38vLM xAScyO8NZNcgHxFNrYCNRICcst7EE1/Au2NLXltDEUTxUOPJuXkmdxW7UTFp9/Zt2TDL tTr1jd5hoNFzW1Q99qFL6twf/nmVzz5rWiBEJBGP6MOaT/nalWpPI+K0o4zbQpNGzaOS dZmQ== X-Gm-Message-State: AGi0Pua8LgPhHSyt6zt9A3r7CJLjFoBcEV4JbjlUEAxYQ/HcydJcNyeW 508iUp481lqTNJIhUjqv/cpRjF9PwIM= X-Google-Smtp-Source: APiQypKVuvY3sCdj4gikFnuSsSJCOemqOQykg62guhWUpwD58GU5YYk9HPOo7MhoiPSZaGQFUqomjg== X-Received: by 2002:ac2:4257:: with SMTP id m23mr85975lfl.141.1588201427476; Wed, 29 Apr 2020 16:03:47 -0700 (PDT) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id q16sm2999209ljj.23.2020.04.29.16.03.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 16:03:46 -0700 (PDT) Received: by mail-lf1-f48.google.com with SMTP id b24so2517808lfp.7 for ; Wed, 29 Apr 2020 16:03:45 -0700 (PDT) X-Received: by 2002:a19:240a:: with SMTP id k10mr119932lfk.30.1588201425482; Wed, 29 Apr 2020 16:03:45 -0700 (PDT) MIME-Version: 1.0 References: <20200429214954.44866-1-jannh@google.com> <20200429215620.GM1551@shell.armlinux.org.uk> In-Reply-To: <20200429215620.GM1551@shell.armlinux.org.uk> From: Linus Torvalds Date: Wed, 29 Apr 2020 16:03:29 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 0/5] Fix ELF / FDPIC ELF core dumping, and use mmap_sem properly in there To: Russell King - ARM Linux admin , Greg Ungerer Cc: 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 , Rich Felker , Linux-sh list Content-Type: text/plain; charset="UTF-8" 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 Wed, Apr 29, 2020 at 2:57 PM Russell King - ARM Linux admin wrote: > > I've never had any reason to use FDPIC, and I don't have any binaries > that would use it. Nicolas Pitre added ARM support, so I guess he > would be the one to talk to about it. (Added Nicolas.) While we're at it, is there anybody who knows binfmt_flat? It might be Nicolas too. binfmt_flat doesn't do core-dumping, but it has some other oddities. In particular, I'd like to bring sanity to the installation of the new creds, and all the _normal_ binfmt cases do it largely close together with setup_new_exec(). binfmt_flat is doing odd things. It's doing this: /* Flush all traces of the currently running executable */ if (id == 0) { ret = flush_old_exec(bprm); if (ret) goto err; /* OK, This is the point of no return */ set_personality(PER_LINUX_32BIT); setup_new_exec(bprm); } in load_flat_file() - which is also used to loading _libraries_. Where it makes no sense at all. It does the install_exec_creds(bprm); in load_flat_binary() (which makes more sense: that is only for actual binary loading, no library case). I would _like_ for every binfmt loader to do /* Flush all traces of the currently running executable */ retval = flush_old_exec(bprm); if (retval) return retval; .. possibly set up personalities here .. setup_new_exec(bprm); install_exec_creds(bprm); all together, and at least merge 'setup_new_exec()' with 'install_exec_creds()'. And I think all the binfmt handlers would be ok with that, but the flat one in particular is really oddly set up. *Particularly* with that flush_old_exec/setup_new_exec() being done by the same routine that is also loading libraries (and called from 'calc_reloc()' from binary loading too). Adding Greg Ungerer for m68knommu. Can somebody sort out why that flush_old_exec/setup_new_exec() isn't in load_flat_binary() like install_exec_creds() is? Most of that file goes back to pre-git days. And most of the commits since are not so much about binfmt_flat, as they are about cleanups or changes elsewhere where binfmt_flat was just a victim. Linus