[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <b629cda1-becd-4725-b16c-13208ff478d3@www.fastmail.com>
Date: Fri, 13 Aug 2021 17:49:19 -0700
From: "Andy Lutomirski" <luto@...nel.org>
To: "Linus Torvalds" <torvalds@...ux-foundation.org>,
"Eric W. Biederman" <ebiederm@...ssion.com>
Cc: "David Laight" <David.Laight@...lab.com>,
"David Hildenbrand" <david@...hat.com>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
"Andrew Morton" <akpm@...ux-foundation.org>,
"Thomas Gleixner" <tglx@...utronix.de>,
"Ingo Molnar" <mingo@...hat.com>, "Borislav Petkov" <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>,
"Al Viro" <viro@...iv.linux.org.uk>,
"Alexey Dobriyan" <adobriyan@...il.com>,
"Steven Rostedt" <rostedt@...dmis.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
"Arnaldo Carvalho de Melo" <acme@...nel.org>,
"Mark Rutland" <mark.rutland@....com>,
"Alexander Shishkin" <alexander.shishkin@...ux.intel.com>,
"Jiri Olsa" <jolsa@...hat.com>,
"Namhyung Kim" <namhyung@...nel.org>,
"Petr Mladek" <pmladek@...e.com>,
"Sergey Senozhatsky" <sergey.senozhatsky@...il.com>,
"Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
"Rasmus Villemoes" <linux@...musvillemoes.dk>,
"Kees Cook" <keescook@...omium.org>,
"Greg Ungerer" <gerg@...ux-m68k.org>,
"Geert Uytterhoeven" <geert@...ux-m68k.org>,
"Mike Rapoport" <rppt@...nel.org>,
"Vlastimil Babka" <vbabka@...e.cz>,
"Vincenzo Frascino" <vincenzo.frascino@....com>,
"Chinwen Chang" <chinwen.chang@...iatek.com>,
"Michel Lespinasse" <walken@...gle.com>,
"Catalin Marinas" <catalin.marinas@....com>,
"Matthew Wilcox (Oracle)" <willy@...radead.org>,
"Huang Ying" <ying.huang@...el.com>,
"Jann Horn" <jannh@...gle.com>, "Feng Tang" <feng.tang@...el.com>,
"Kevin Brodsky" <Kevin.Brodsky@....com>,
"Michael Ellerman" <mpe@...erman.id.au>,
"Shawn Anastasio" <shawn@...stas.io>,
"Steven Price" <steven.price@....com>,
"Nicholas Piggin" <npiggin@...il.com>,
"Christian Brauner" <christian.brauner@...ntu.com>,
"Jens Axboe" <axboe@...nel.dk>,
"Gabriel Krisman Bertazi" <krisman@...labora.com>,
"Peter Xu" <peterx@...hat.com>,
"Suren Baghdasaryan" <surenb@...gle.com>,
"Shakeel Butt" <shakeelb@...gle.com>,
"Marco Elver" <elver@...gle.com>,
"Daniel Jordan" <daniel.m.jordan@...cle.com>,
"Nicolas Viennot" <Nicolas.Viennot@...sigma.com>,
"Thomas Cedeno" <thomascedeno@...gle.com>,
"Collin Fijalkovich" <cfijalkovich@...gle.com>,
"Michal Hocko" <mhocko@...e.com>,
"Miklos Szeredi" <miklos@...redi.hu>,
"Chengguang Xu" <cgxu519@...ernel.net>,
Christian König <ckoenig.leichtzumerken@...il.com>,
"linux-unionfs@...r.kernel.org" <linux-unionfs@...r.kernel.org>,
"Linux API" <linux-api@...r.kernel.org>,
"the arch/x86 maintainers" <x86@...nel.org>,
"<linux-fsdevel@...r.kernel.org>" <linux-fsdevel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>,
"Florian Weimer" <fweimer@...hat.com>,
"Michael Kerrisk" <mtk.manpages@...il.com>
Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE
On Fri, Aug 13, 2021, at 5:31 PM, Linus Torvalds wrote:
> On Fri, Aug 13, 2021 at 10:18 AM Eric W. Biederman
> <ebiederm@...ssion.com> wrote:
> >
> > Florian Weimer, would it be possible to get glibc's ld.so implementation to use
> > MAP_SHARED? Just so people reading the code know what to expect of the
> > kernel? As far as I can tell there is not a practical difference
> > between a read-only MAP_PRIVATE and a read-only MAP_SHARED.
>
> There's a huge difference.
>
> For one, you actually don't necessarily want read-only. Doing COW on
> library images is quite common for things like relocation etc (you'd
> _hope_ everything is PC-relative, but no)
>
> So no. Never EVER use MAP_SHARED unless you literally expect to have
> two different mappings that need to be kept in sync and one writes the
> other.
>
> I'll just repeat: stop arguing about this case. If somebody writes to
> a busy library, THAT IS A FUNDAMENTAL BUG, and nobody sane should care
> at all about it apart from the "you get what you deserve".
>
> What's next? Do you think glibc should also map every byte in the user
> address space so that user programs don't get SIGSEGV when they have
> wild pointers?
>
> Again - that's a user BUG and trying to "work around" a wild pointer
> is a worse fix than the problem it tries to fix.
>
> The exact same thing is true for shared library (or executable)
> mappings. Trying to work around people writing to them is *worse* than
> the bug of doing so.
>
> Stop this completely inane discussion already.
>
I’ll bite. How about we attack this in the opposite direction: remove the deny write mechanism entirely.
In my life, I’ve encountered -ETXTBUSY intermittently, and it invariably means that I somehow failed to finish killing a program fast enough for whatever random rebuild I’m doing to succeed. It’s at best erratic — it only applies for static binaries, and it has never once saved me from a problem I care about. If the program I’m recompiling crashes, I don’t care — it’s probably already part way through dying from an unrelated fatal signal. What actually happens is that I see -ETXTBUSY, think “wait, this isn’t Windows, why are there file sharing rules,” then think “wait, Linux has *one* half baked file sharing rule,” and go on with my life. [0]
Seriously, can we deprecate and remove the whole thing?
[0] we have mandatory locks, too. Sigh.
Powered by blists - more mailing lists