Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2048659ybz; Thu, 30 Apr 2020 09:57:20 -0700 (PDT) X-Google-Smtp-Source: APiQypLPPfIWixKzLYnKWe+xgarVNSaWPVuot2I1yaM2K83hX8VUXxNew3AncwMCxBOqyatAozGV X-Received: by 2002:aa7:cdcb:: with SMTP id h11mr3410259edw.264.1588265840253; Thu, 30 Apr 2020 09:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588265840; cv=none; d=google.com; s=arc-20160816; b=Drx8jX47KOs5r98VtKR9eCG4Aws7p4OYnWM4ChrEMd5/Flr/ESVl5MAX90wgTCwKmz Iahlxagzqy9tJl4YWpF6vlIZzc3opSXPAm0OxBygB05hz8I7gljza6c85s9aAbv7X3Ux vUZlISH4pWYM2sBx2wdf8XdXFIRR1oRUFTADQJ8kKtDJL2OI5fHdLGkslQltvsrcvwEG PKJ6/peN4iepr+kVqe9Lzc7tsND8uI2hIJB9G8KNWTikmViAEKziO3N9td0Z1uWEPcRO AvN9cUxv0ILh0/hJsDR4H31eyfMVHCuGM1cNG7HaGDQgwoJ35XdUm7WNk2FXoKG9ZoSr adcA== 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=jusIkjp3Dz4is1PZPLtprnCAT5bOhq5lF7YlVU3AWyQ=; b=Gmg4tnWwI9Qp06/Sg8+rXHa3IvOjvF8EBj34YE9P+EW8ztm7xEQ67uD+yrPfUysGm/ iD3Qf7v6idtOgbGp1aY6SFFpfagmn2oTSMubdAMqg+PQi1BxvkBVVB4EBtZlvDmvbJW/ 9cBFP8ii/5xLJuzeBjr3apjMhjlk2w/KetbMQPWflvv4qliMxXYpHQUVsbd7rmPuX1UJ CjrBr0JvA6PPhmhvX/70Ve0SF+lQHjjly9jPjX/L2iXni7iaE5QN9WhHgyDdf2WLAtwI 72vfU/qoyLy6scaBFXA4KgHRKKXP/e14vC2Q4rkFR7ZHJCTR21/Z6T87LZmoFnv95S5h ZC8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="K/L1x2WL"; 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 i25si64532edb.304.2020.04.30.09.56.56; Thu, 30 Apr 2020 09:57:20 -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="K/L1x2WL"; 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 S1726611AbgD3Qyv (ORCPT + 99 others); Thu, 30 Apr 2020 12:54:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726272AbgD3Qyv (ORCPT ); Thu, 30 Apr 2020 12:54:51 -0400 Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A22CDC035494 for ; Thu, 30 Apr 2020 09:54:50 -0700 (PDT) Received: by mail-lj1-x242.google.com with SMTP id a21so40116ljj.11 for ; Thu, 30 Apr 2020 09:54: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=jusIkjp3Dz4is1PZPLtprnCAT5bOhq5lF7YlVU3AWyQ=; b=K/L1x2WLoEDVhKcajWjRfk8di4UnhY9fQ857BctryF99FXnh8lvm/+FMFP7To9VzLC Oeh5Zl2gS6/3rwg+PAIfEpUDm0vFKxb3sBkuIMd/j+tdM33ErRljDKSRox35DyrhVqQy cxTvpJRHT1GSdzAq5WmfU86CiiQNmQ4AcXgOg= 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=jusIkjp3Dz4is1PZPLtprnCAT5bOhq5lF7YlVU3AWyQ=; b=JdjxCR9B3TWfZWtVRiU6rp8SIRyq1H5xV4mfYnA625wjVrgRIaN8kcY/fSrgl1HWuj R329ym6twrBiubGPlBRVbTKErROetNPHXWy3e02GJozlD/n+KGJc2UBpXlSrMIAWfuFH POY8z8IdcT3ZvaMXUm8kwhL+3vhqxo5bFv1+AsvaLZ7Z9x54cOYLfqYjv1g1mTgphEH0 +OJYB4Riym7f68qJ3efvkc85jqohy6SkWzcHlrkbZEVOmCy/JxBdi5o/kh9/Wqo0xu51 X5KpflxbbwVuTnVzXbcJPtQJNtFS566dwVMBLs35R+FLP0c1vy5w69zSmB2rG/Ps5Wue tZNg== X-Gm-Message-State: AGi0PuaFsbQ13X2Pme4XhdZqHHrm5gLbPym3IovFmMLNAdekVVQrWlVw rCIeGGJzBsCZ73imnTmcl9WJHQkh6wI= X-Received: by 2002:a05:651c:39b:: with SMTP id e27mr130566ljp.145.1588265687533; Thu, 30 Apr 2020 09:54:47 -0700 (PDT) Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com. [209.85.167.47]) by smtp.gmail.com with ESMTPSA id g3sm255111ljk.27.2020.04.30.09.54.45 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 09:54:46 -0700 (PDT) Received: by mail-lf1-f47.google.com with SMTP id j14so1813586lfg.9 for ; Thu, 30 Apr 2020 09:54:45 -0700 (PDT) X-Received: by 2002:a05:6512:405:: with SMTP id u5mr2728777lfk.192.1588265685113; Thu, 30 Apr 2020 09:54:45 -0700 (PDT) MIME-Version: 1.0 References: <20200429214954.44866-1-jannh@google.com> <20200429215620.GM1551@shell.armlinux.org.uk> <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> In-Reply-To: <31196268-2ff4-7a1d-e9df-6116e92d2190@linux-m68k.org> From: Linus Torvalds Date: Thu, 30 Apr 2020 09:54:28 -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: Greg Ungerer Cc: 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 , 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 Thu, Apr 30, 2020 at 7:10 AM Greg Ungerer wrote: > > > in load_flat_file() - which is also used to loading _libraries_. Where > > it makes no sense at all. > > I haven't looked at the shared lib support in there for a long time, > but I thought that "id" is only 0 for the actual final program. > Libraries have a slot or id number associated with them. Yes, that was my assumption, but looking at the code, it really isn't obvious that that is the case at all. 'id' gets calculated from fields that very much look like they could be zero (eg by taking the top bits from another random field). > > 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. > > I'll have a look at this. Thanks. > Quick hack test shows moving setup_new_exec(bprm) to be just before > install_exec_creds(bprm) works fine for the static binaries case. > Doing the flush_old_exec(bprm) there too crashed out - I'll need to > dig into that to see why. Just moving setup_new_exec() would at least allow us to then join the two together, and just say "setup_new_exec() does the credential installation too". So to some degree, that's the important one. But that flush_old_exec() does look odd in load_flat_file(). It's not like anything but executing a binary should flush the old exec. Certainly not loading a library, however odd that flat library code is. My _guess_ is that the reason for this is that "load_flat_file()" also does a lot of verification of the file and does that whole "return -ENOEXEC if the file format isn't right". So we don't want to flush the old exec before that is done, but we obviously also don't want to flush the old exec after we've actually loaded the new one into memory.. So the location of flush_old_exec() makes that kind of sense, but it would have made it better if that flat file support had a clear separation of "check the file" from "load the file". Oh well. As mentioned, the whole "at least put setup_new_exec() and install_exec_creds() together" is the bigger thing. But if it's true that nobody really uses the odd flat library support any more and there are no testers, maybe we should consider ripping it out... Linus