Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1268321pxb; Sun, 22 Aug 2021 11:08:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/0zhlcAnl5Kfs90tfVKW52q70S960LIsP/KDgrLyUo2pBf7fyWMur5qVrnoSlSlO56qxU X-Received: by 2002:a05:6402:214:: with SMTP id t20mr13165205edv.386.1629655681734; Sun, 22 Aug 2021 11:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629655681; cv=none; d=google.com; s=arc-20160816; b=d9TNWmSX4Er3xLdE4Ymh1V8ZyT2ittBQxetOZshniKOrBiStMaACfXn9yTCAcpFgG5 C3sePn/FTI6vBLTmglyR1KN9pGhSEH2BB17zIvDtMMtB0X/qWP2IrB2+Ca5Q2brxn0mj d/F1emFhQaBx6n2Lne1A/G4oP8pcppUSLzJh9zkeGG2Rj+4Zz6+/Odf+SvfnpgJzXypO 7G4//y60tkEdV8Uk0RFxiU18dm229omIphk2SPMgfz4tSF0wDV37iFNrBff+v3pV7qTI Aw7VK6FA5Xd+GEq7UPGBS/MW7gfAo+6AKY8ZQObvsawK1jMoH/NX+JpJRYhLZGwULfKE Ojjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FdFxYhd+eeTvCDoJF+ykQd/hvB6y5cUN0QY2l3gJKV8=; b=iE8MGgxkiwttwYGxkHzKi4ELicdx+VpEJGEyhQCHkztFri7Gqe1gxcaiH+bBGI/Roi XkDoXpJ6xxL/A1m5JCeYj1ozdD6/RS/L4bdomE2xd5o0B84tdaITuxcn7BDjH+O+uzwd WdmJIoV+i0Wjrn2KpPiFZreZDbJHYS+Q5p3rKlF+4ljaWU6BK21gNmsQ81CxkrL2Heyp ZcBlvKhOXatSJYkVsJHCLRbQyM1pvPvTxe/x0ySlj4PXC1mRoLT45lvh30dXjA/C1lpx o2ft8ESUe2uDJcAk5FU7SRV60B+9KdgVcENMFXGpwgC5zJKDE4PUsegZ6F0WeS0gIp1h 7iag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=au92NbSi; 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 w10si14554002ejv.754.2021.08.22.11.07.38; Sun, 22 Aug 2021 11:08: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=au92NbSi; 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 S231984AbhHVSFC (ORCPT + 99 others); Sun, 22 Aug 2021 14:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230245AbhHVSFB (ORCPT ); Sun, 22 Aug 2021 14:05:01 -0400 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87EEDC061575 for ; Sun, 22 Aug 2021 11:04:19 -0700 (PDT) Received: by mail-lj1-x230.google.com with SMTP id s12so1902267ljg.0 for ; Sun, 22 Aug 2021 11:04:19 -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=FdFxYhd+eeTvCDoJF+ykQd/hvB6y5cUN0QY2l3gJKV8=; b=au92NbSisRvXy93M+NrgnvN1ZFxFpdCvErKBfMKVIqPkcLDsmlc4H8IlkBaoDTokon +3bncuuUd0fsd3z1HifoTs0zMQn06fmz518jwP3j+xMbPOi2iWMFEHBiOt1QHwW5pDC9 gQ87hYhnRnXoLWW0aQEtDFTGVTYDaIQIFcmIA= 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=FdFxYhd+eeTvCDoJF+ykQd/hvB6y5cUN0QY2l3gJKV8=; b=IeevaPoE7WjiXuBuC7/WxS7fb1Q9HsIScY2U1Lr57vB4jQPXPejsAlVBxJqgkBA1uC MAwtRVrqk1EosYG/+YwdNDn4huzVN/XQNS0biud+GBjlUxynFl5MLCn8If8i46Zqrgqn t1jWR9Cuunxq8Pxy7BRckhbpaoghfdbGrraIN3Uw8KhpszXpJOFEsL0gd/t8QfNazaDQ sESBhnOT91YHSlTOKWpa0qQ1bJfovhHlgGnH6aYqnFXWcKr3z0UNdC7Tq5ilMWmPjkSo H8255ssPholzH4fAn7kvlExt3Pxn/TBLPAdDWhDplD1aLOtlDSQGbR/Lcr8a1wpWM4yE sLXg== X-Gm-Message-State: AOAM5305gfUg1P1O2RoCHzaKL/cAe2qhlIbuAydSSFThqj7CfoPiTI49 v6zbFlR3J1pzaCDxxOANmTjRFFNwnce+4biZ0j4= X-Received: by 2002:a05:651c:490:: with SMTP id s16mr24274134ljc.214.1629655457699; Sun, 22 Aug 2021 11:04:17 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id b16sm826261lfv.26.2021.08.22.11.04.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 11:04:17 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id x27so32868921lfu.5 for ; Sun, 22 Aug 2021 11:04:17 -0700 (PDT) X-Received: by 2002:a2e:81c2:: with SMTP id s2mr23439411ljg.48.1629655124814; Sun, 22 Aug 2021 10:58:44 -0700 (PDT) MIME-Version: 1.0 References: <20210816194840.42769-1-david@redhat.com> <20210816194840.42769-3-david@redhat.com> <87o89srxnn.fsf@disp2133> In-Reply-To: <87o89srxnn.fsf@disp2133> From: Linus Torvalds Date: Sun, 22 Aug 2021 10:58:28 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/7] kernel/fork: factor out replacing the current MM exe_file To: "Eric W. Biederman" Cc: David Hildenbrand , Linux Kernel Mailing List , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Alexander Viro , Alexey Dobriyan , Steven Rostedt , Peter Zijlstra , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Petr Mladek , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Kees Cook , Greg Ungerer , Geert Uytterhoeven , Mike Rapoport , Vlastimil Babka , Vincenzo Frascino , Chinwen Chang , Catalin Marinas , "Matthew Wilcox (Oracle)" , Huang Ying , Jann Horn , Feng Tang , Kevin Brodsky , Michael Ellerman , Shawn Anastasio , Steven Price , Nicholas Piggin , Christian Brauner , Jens Axboe , Gabriel Krisman Bertazi , Peter Xu , Suren Baghdasaryan , Shakeel Butt , Marco Elver , Daniel Jordan , Nicolas Viennot , Thomas Cedeno , Michal Hocko , Miklos Szeredi , Chengguang Xu , =?UTF-8?Q?Christian_K=C3=B6nig?= , Florian Weimer , David Laight , linux-unionfs@vger.kernel.org, Linux API , "the arch/x86 maintainers" , linux-fsdevel , Linux-MM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 20, 2021 at 7:36 AM Eric W. Biederman wrote: > > I think this check is there to keep from changing /proc/self/exe > arbitrarily. Well, you pretty much can already. You just have to jump through a few hoops. > Maybe it is all completely silly and we should not care about the code > that thinks /proc/self/exe is a reliable measure of anything, but short > of that I think we should either keep the code or put in some careful > thought as to which restrictions make sense when changing > /proc/self/exe. I think the important ones are already there: checking that it is (a) an executable and (b) that we have execute permission to it. I also think the code is actually racy - while we are checking "did the old mm_exe file have any mappings", there's nothing that keeps another thread from changing the exe file to another one that _does_ have mappings, and then we'll happily replace it with yet another file because we checked the old one, not the new one it was replaced by in the meantime. Of course, that "race" doesn't really matter - exactly because this isn't about security, it's just a random "let's test that immaterial thing, and we don't actually care about corner cases". So I'm not saying that race needs to be fixed - I'm just pointing it out as an example of how nonsensical the test really is. It's not fundamental to anything, it's just a random "let's test this odd condition". That said, I don't care _that_ much. I'm happy with David's series, I just think that once we don't do this at a mmap level any more, the "go look for mappings" code makes little sense. So we can leave it, and remove it later if people agree. Linus