Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1159997ybz; Wed, 29 Apr 2020 16:13:02 -0700 (PDT) X-Google-Smtp-Source: APiQypKBG4544py/3nTN/PVrU21iU1Y8kk+LEsl7bFY8BaoGSpcSWvVOi+U5OmsJyqMKuizY3GqH X-Received: by 2002:a17:906:37d0:: with SMTP id o16mr143517ejc.368.1588201981970; Wed, 29 Apr 2020 16:13:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588201981; cv=none; d=google.com; s=arc-20160816; b=LGn0GAJlad7Bz8w6O9xNlBFVVr3gpGXIVf1yboW5gy3gakaE9pxONxpE9p3YfbA1Hg qPZjC5y6zEEeHlV6zFqMdOQd+4uO0c2LKE0Tlf2NFQeKiP3x2VDFPgrv/rEmQqNukBiP Lcu3+LQSLMZonTC6CmCyAM5N+DndUNWReyEaTOGwTu97ngAq9iaXiL53tcPFwsE01u2g hFRTbkMg9LZgRYRP7qYxhGa//uNe90QRQ+pVIAB4qC7whI7Jqd7bZI+yLXZX8nbTKB1c Zz36G4y8DEl1yP0PNuwzSnNU3c7ApjWv3gqc3hhSA/YKv2jDfCLWk0fqnhjm5Vkb7hJZ xVwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ur9jfHYBxvOMHwCSyzgCuO4pNPy1puU85FIa2ankgiI=; b=NBGK7Urz9bHARF89Opjx8TNJDJ8ICP6cMf50jb67C3jaLoCt4WQd5DCQlw3PKLTJLk 5zChIE/1Oh1KCdhdxMh1Mh5J4s8OOD+MNEnkcIBgl8n9nY2Zc7knKrCQjE/jdtZENV8A jZLgjkHNd8sMNOP39HNAbS5Hv+t7YJxGxAyAhs9qW37K3HrABhjOGKc1F+rLh+XAi5C4 2a1TY5oDAlpXrZflewVPZKjCCldeXay1ZahZkU2Jt/w/oqZaB/PIbj+OaSBBoEaNzVfP iiYe+L1q3XoDQqu7GWrhw7xku4pkDyyy3ipdCsMh1prWFfPeQT7VVU5sGYbOFWLGMcSH MzcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=DrKHR3jw; 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 s5si4058743edx.330.2020.04.29.16.12.38; Wed, 29 Apr 2020 16:13:01 -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=@linux-foundation.org header.s=google header.b=DrKHR3jw; 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 S1727078AbgD2XLC (ORCPT + 99 others); Wed, 29 Apr 2020 19:11:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726775AbgD2XLC (ORCPT ); Wed, 29 Apr 2020 19:11:02 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BF1C03C1AE for ; Wed, 29 Apr 2020 16:11:00 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id d16so2970042edv.8 for ; Wed, 29 Apr 2020 16:11:00 -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=H+uthNe2iN4czy89ejofO4bRkmGd3Qkrdrs3a5GAM/ioV8W9Ywbj0JCdm+VY5oWFYr hvJba3OWtmRcM/82UUwUe0I0ExUVRnhKugN3jGjbaxpRloo9CgXcET+kvAXi9NsSLVj0 V1d2D2DeXiIXiRNTbjgFOzpMx48SWfn6QpFUkYJIHOCG+JT/nuc9rOCZU5QSrbZaxsd5 MbffQvV8I9GvJu5hlFMmSsW+fuFljkaSu1R87BoPv+DQxMaRYONfV/vBN301MBZd4Ex7 K/mWQmwPCegf5AFmgMAvOmomZvQBIZ4KbQYLZhoiZL+iRHt/eD/0aeZ9BncPBJnEyBsZ RK/Q== X-Gm-Message-State: AGi0PuZL8JH3ijixmc1eQ0KH+eLTbu/uKl3sgeMSRHvOad6lyqz4KjWd 9ikDuT7DtGkCIE8O/c7xcGQPmbE1dLI= X-Received: by 2002:a05:6402:204b:: with SMTP id bc11mr309661edb.114.1588201858580; Wed, 29 Apr 2020 16:10:58 -0700 (PDT) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com. [209.85.221.46]) by smtp.gmail.com with ESMTPSA id z26sm920236ejb.36.2020.04.29.16.10.58 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 16:10:58 -0700 (PDT) Received: by mail-wr1-f46.google.com with SMTP id k13so4575385wrw.7 for ; Wed, 29 Apr 2020 16:10:58 -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" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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