Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp605318pxb; Fri, 13 Aug 2021 02:10:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/LK0w2ymudHhVPQZvW90zHebYYWm4uz1Alx0xzUl7LyMGyRDtc1ld8SWmvpiir6Z6aHOI X-Received: by 2002:aa7:c799:: with SMTP id n25mr1770479eds.16.1628845819112; Fri, 13 Aug 2021 02:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628845819; cv=none; d=google.com; s=arc-20160816; b=DI4wEnfNS/yMadnoJlD8AS/YBGqZJzKxi2OfqA4V9YLEktWaJDJjcIbPHJHG3JyNgM 7ASL4t/8krIzlh2CeKUVXkDQ7VmYWe14gw7e43mnGC3lO2Z7ZWbncffD7Xshj7Kr+tml eVxfuTZJx6o9SXioR731t+VQTJ1Ff09rvIZeJkKxiquMPkBnSkMnF+SDOrs3IrCd3aXE rVAhizFOcwR0APF2myUDTjHajhUpfebItxutmk+pAKxGHEBTAjSmVCuZZvMwY+G/9yDI R3sS0rMTU587HNVPNB/AbZdKh2194YyKtsVKL+jJPSXf55ecSdVmHXwtXKpoh4Xnuplg 4bwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=CWW1ybXN+9BNM0g900iUL+t6ZvM7Ubgk6MYSn5CXAjg=; b=UBk6MTaft7RCNBzDYJnZlh7hnPrEOeIKmMBRhkxguPo47BNhFYw5DyiL0agCQQD6VC YWmrnW2Xl0itmguIqzl7xF4djAGD9ILeEbYbtMBcmGuOthF624kQp56Ofrihijy+RWB8 s9CZS0/eaj8EaWA0K0oVynyC/H0LoGj1MF9kq2UbVrI2NQBpvJv9L8S4NqEuCn+Ip6aS LtnMCdSrGeVjkH4dT8Y3M4ZZjabvuBOxyFQOYAPZk9oIsg+YVkSO8CxU+MKo6DzC/tlh 1VcAVqg0itzU0m++0kp50atS9wgqemkWqrKg6ydcj7GE7f88QuZ2Tnoon/Sw3a5u/j4r C2kw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g24si1188927edj.498.2021.08.13.02.09.56; Fri, 13 Aug 2021 02:10:19 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239865AbhHMJGT convert rfc822-to-8bit (ORCPT + 99 others); Fri, 13 Aug 2021 05:06:19 -0400 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]:41181 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239686AbhHMJGR (ORCPT ); Fri, 13 Aug 2021 05:06:17 -0400 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)