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 01ED5C4338F for ; Thu, 12 Aug 2021 18:11:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8E18860F91 for ; Thu, 12 Aug 2021 18:11:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8E18860F91 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=kvack.org Received: by kanga.kvack.org (Postfix) id D72AF8D0002; Thu, 12 Aug 2021 14:11:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CF9498D0001; Thu, 12 Aug 2021 14:11:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B99418D0002; Thu, 12 Aug 2021 14:11:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0026.hostedemail.com [216.40.44.26]) by kanga.kvack.org (Postfix) with ESMTP id 9A8C18D0001 for ; Thu, 12 Aug 2021 14:11:00 -0400 (EDT) Received: from smtpin37.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 491B1181DB38C for ; Thu, 12 Aug 2021 18:11:00 +0000 (UTC) X-FDA: 78467219880.37.AA140FE Received: from mail-lj1-f182.google.com (mail-lj1-f182.google.com [209.85.208.182]) by imf01.hostedemail.com (Postfix) with ESMTP id 0D55550481FF for ; Thu, 12 Aug 2021 18:10:59 +0000 (UTC) Received: by mail-lj1-f182.google.com with SMTP id y7so11828450ljp.3 for ; Thu, 12 Aug 2021 11:10:59 -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=kMjoLlvtmb7mlrSdQknNJvuiNoe+cD5cNxWCgcmURzw=; b=fAel4ZlqluiDbK7XT2TN285OpKL/k74SaHM+ukhLXBOh8aUgDoAGzVcLvAOBNcLwL7 LW/VCMiZKL3GYhssOvLPpOPnx2NT/Qr4lb/26QY9QP4lDZrSUO3zX9NqiJlhGgoC6/lS /Ep9k9BaQCUABA+deLmcEAO5Iol8v4ErYRRpM= 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=kMjoLlvtmb7mlrSdQknNJvuiNoe+cD5cNxWCgcmURzw=; b=enI4vVdpYqdBnLKpUMq21Qzv2wAxUqc8w77rLcCOqjLckucTO7Motf9/FkZOharRFA qNGKkqMrvkOMlp3ybc7Y5lJCcoIGDWKRlAfoiHIT/pcK4umywmFjQNYjFTa+K57Uef0Y k88D+6XoQg+YqlqRgKgTIil9foTQdaYbg+gsbYW2F1n65sDoF7p9dtozVSmiz2+GJVgu gyiGFjYJm9A432hcxnxzY4szhaFsh/lFuqSNoE8aZJlfEhAS524M/kRlc/tRkINiCPhP 0/IUrQcIr6hwy26+hKsedEAHCyObPt7th7/tYBNGUsc/9aLTxmSztILfwtFNYmewQtgu NEcg== X-Gm-Message-State: AOAM530jfFgTtFvp6WN/XhCODpavQdMNAsYWWDpFnidGkdYXJHzAlpBO Q5PcS2xAEH3QCab8jHdBPU/NVOHRYQogtWUMEuE= X-Google-Smtp-Source: ABdhPJzIrNMDfzoJ1jvuSyFIz1s1YBOY4OJd5wzDotrKYpS04LoWrCmfG+WiFaK1h5Rtl5daPdrCOA== X-Received: by 2002:a2e:94cb:: with SMTP id r11mr3461711ljh.116.1628791858168; Thu, 12 Aug 2021 11:10:58 -0700 (PDT) Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com. [209.85.167.45]) by smtp.gmail.com with ESMTPSA id r25sm360191lfm.90.2021.08.12.11.10.54 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Aug 2021 11:10:56 -0700 (PDT) Received: by mail-lf1-f45.google.com with SMTP id n17so14953395lft.13 for ; Thu, 12 Aug 2021 11:10:54 -0700 (PDT) X-Received: by 2002:a05:6512:2091:: with SMTP id t17mr3426901lfr.253.1628791844375; Thu, 12 Aug 2021 11:10:44 -0700 (PDT) MIME-Version: 1.0 References: <20210812084348.6521-1-david@redhat.com> <87o8a2d0wf.fsf@disp2133> <60db2e61-6b00-44fa-b718-e4361fcc238c@www.fastmail.com> <87lf56bllc.fsf@disp2133> In-Reply-To: <87lf56bllc.fsf@disp2133> From: Linus Torvalds Date: Thu, 12 Aug 2021 08:10:28 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE To: "Eric W. Biederman" Cc: Andy Lutomirski , David Hildenbrand , Linux Kernel Mailing List , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Al Viro , Alexey Dobriyan , Steven Rostedt , "Peter Zijlstra (Intel)" , 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 , Michel Lespinasse , 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 , Collin Fijalkovich , Michal Hocko , Miklos Szeredi , Chengguang Xu , =?UTF-8?Q?Christian_K=C3=B6nig?= , linux-unionfs@vger.kernel.org, Linux API , "the arch/x86 maintainers" , linux-fsdevel , Linux-MM Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=fAel4Zlq; dmarc=none; spf=pass (imf01.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.208.182 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org X-Stat-Signature: 4oxhaz9jgnxc1qtp5iobhnhit7jsxtxh X-Rspamd-Queue-Id: 0D55550481FF X-Rspamd-Server: rspam05 X-HE-Tag: 1628791859-281144 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 Thu, Aug 12, 2021 at 7:48 AM Eric W. Biederman wrote: > > Given that MAP_PRIVATE for shared libraries is our strategy for handling > writes to shared libraries perhaps we just need to use MAP_POPULATE or a > new related flag (perhaps MAP_PRIVATE_NOW) No. That would be horrible for the usual bloated GUI libraries. It might help some (dynamic page faults are not cheap either), but it would hurt a lot. This is definitely a "if you overwrite a system library while it's being used, you get to keep both pieces" situation. The kernel ETXTBUSY thing is purely a courtesy feature, and as people have noticed it only really works for the main executable because of various reasons. It's not something user space should even rely on, it's more of a "ok, you're doing something incredibly stupid, and we'll help you avoid shooting yourself in the foot when we notice". Any distro should make sure their upgrade tools don't just truncate/write to random libraries executables. And if they do, it's really not a kernel issue. This patch series basically takes this very historical error return, and simplifies and clarifies the implementation, and in the process might change some very subtle corner case (unmapping the original executable entirely?). I hope (and think) it wouldn't matter exactly because this is a "courtesy error" rather than anything that a sane setup would _depend_ on, but hey, insane setups clearly exist. Linus