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=-5.7 required=3.0 tests=BAYES_00,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 7DE57C4338F for ; Sun, 22 Aug 2021 18:04:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 58AC3611C2 for ; Sun, 22 Aug 2021 18:04:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbhHVSFD (ORCPT ); Sun, 22 Aug 2021 14:05:03 -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-Google-Smtp-Source: ABdhPJzGVvI+JL4Gl/vvHQuIio/tiLFpeE8z4w3kJiYvYWNtyUumsCYwlprLK8rQhtCk3ZdmIijc4w== 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