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=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 AB102C4320E for ; Fri, 13 Aug 2021 09:05:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8BC7B610FC for ; Fri, 13 Aug 2021 09:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8BC7B610FC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id E8AFB8D0001; Fri, 13 Aug 2021 05:05:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E14AB6B0071; Fri, 13 Aug 2021 05:05:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB48D8D0001; Fri, 13 Aug 2021 05:05:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id ACF126B006C for ; Fri, 13 Aug 2021 05:05:52 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4B5FA10FD0 for ; Fri, 13 Aug 2021 09:05:52 +0000 (UTC) X-FDA: 78469474944.24.60AF75B Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by imf14.hostedemail.com (Postfix) with ESMTP id AF933601ABDC for ; Fri, 13 Aug 2021 09:05:51 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-193-osqxqi2TPd6TNQ-lyh6w7Q-1; Fri, 13 Aug 2021 10:05:49 +0100 X-MC-Unique: osqxqi2TPd6TNQ-lyh6w7Q-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 13 Aug 2021 10:05:44 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.023; Fri, 13 Aug 2021 10:05:44 +0100 From: David Laight To: "'Eric W. Biederman'" , Linus Torvalds 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 , =?iso-8859-1?Q?Christian_K=F6nig?= , "linux-unionfs@vger.kernel.org" , Linux API , "the arch/x86 maintainers" , linux-fsdevel , Linux-MM Subject: RE: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Thread-Topic: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Thread-Index: AQHXj6qO2FP1eIrarUmjR9CxLZPkE6txIhrA Date: Fri, 13 Aug 2021 09:05:43 +0000 Message-ID: <5b0d7c1e73ca43ef9ce6665fec6c4d7e@AcuMS.aculab.com> References: <20210812084348.6521-1-david@redhat.com> <87o8a2d0wf.fsf@disp2133> <60db2e61-6b00-44fa-b718-e4361fcc238c@www.fastmail.com> <87lf56bllc.fsf@disp2133> <87eeay8pqx.fsf@disp2133> In-Reply-To: <87eeay8pqx.fsf@disp2133> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AF933601ABDC X-Stat-Signature: ts3anzsmzedsey5he6kfbaekk83um9dr Authentication-Results: imf14.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=ACULAB.COM; spf=pass (imf14.hostedemail.com: domain of david.laight@aculab.com designates 185.58.86.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com X-HE-Tag: 1628845551-600709 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: From: Eric W. Biederman > Sent: 12 August 2021 19:47 ... > So today the best advice I can give to userspace is to mark their > executables and shared libraries as read-only and immutable. Otherwise > a change to the executable file can change what is mapped into memory. > MAP_PRIVATE does not help. While 'immutable' might be ok for files installed by distributions it would be a PITA in development. ETXTBUSY is a useful reminder that the file you are copying from machine A to machine B (etc) is still running and probably ought to be killed/stopped before you get confused. I've never really understood why it doesn't stop shared libraries being overwritten - but they do tend to be updated less often. Overwriting an in-use shared library could be really confusing. It is likely that all the code is actually in memory. So everything carries on running as normal. Until the kernel gets under memory pressure and discards a page. Then a page from the new version is faulted in and random programs start getting SEGVs. This could be days after the borked update. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)