Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp1229285pxb; Fri, 13 Aug 2021 17:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzT/BYmgjPfLnMZ2gur3qVZzDEf+24AMsIdo0qesK3F+yUbuwQ9raWnmJiifzlKnh2OH9m9 X-Received: by 2002:a5d:9253:: with SMTP id e19mr4100289iol.35.1628901670772; Fri, 13 Aug 2021 17:41:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628901670; cv=none; d=google.com; s=arc-20160816; b=a2s8NpsvV37ZlJ5VoIjrSR1WwyUqARGvL/C+7AZ3VrXvyeXLGpT1kQNr/SptemlnCy HsAK4zTH0BBKdW8fSJ798+mptxoLpwlAXpx2gRRBUj5Il3hworn3e7jv7YOm1Kunkdrx pUGfv8p1MYkI6TpmdHFfW8b63L8ZvkGBnAQaD6Txt8sDR+mm2WDWvUYJTxCdJeMipp66 gjVdMMH3SXuLVFQZDaaKKpSwcHO5OBCk/vEqeX+574vnFT9Utb9BwBqLHNYXzEwuX4Lk U8nY6UBSYNKl93M4zwealNCCDyy4dBWZtfji/AGkmOdySZIdAybVSWo+XGb8Pd+yxlIo twFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=IjaD5q8QKwN+jVDLQ1RW7mDtRCj+6oZDCsHq9KfG01Y=; b=Mekj5mdDdZ6dIQQomyx5J+2jPfF4/ZuQ9Bl9jlsymc8651GJOySDxfjnMwChbah4vv hrlyVWPSFEqwVsqX1v8F4ORtSbl+a42S+9CDD9tVLPhWhNJv95Em0Clf8pIHHsyAJrRm yMIjl/Cv0+k+jFQXdRfpW/CJ3rCHls+h/bZ7DPXwipCDB9b0XVRJCI+uE7md5GtQ0UcV kDfpsu1FfFyfa/PP19qffwICTeTIfEZTOFGzbtC707UL7hieeUNS/rltv8fTfUSb0D2B pl8prgvDq9bKXfXNsa5exw2lL5h5SgvxGIcEQCIaKCvemK2ejmNH1ZZ1mVHF5VmTNcq4 4qOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=YpOsIIGW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si3026128ilq.142.2021.08.13.17.40.56; Fri, 13 Aug 2021 17:41:10 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=YpOsIIGW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235877AbhHNAkd (ORCPT + 99 others); Fri, 13 Aug 2021 20:40:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235330AbhHNAkc (ORCPT ); Fri, 13 Aug 2021 20:40:32 -0400 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF118C061756 for ; Fri, 13 Aug 2021 17:40:04 -0700 (PDT) Received: by mail-ej1-x62e.google.com with SMTP id hs10so21470339ejc.0 for ; Fri, 13 Aug 2021 17:40:04 -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=IjaD5q8QKwN+jVDLQ1RW7mDtRCj+6oZDCsHq9KfG01Y=; b=YpOsIIGWVbrxvz1V+JMlOsSqwlXM3DAd2BzbAfkLqR4kAf3OBmXelOKWLmXLhmfuGJ GCgWpJKZXGVCvc3L1o2SMTScR6NM9a1dV9DxbX2yx8cNWio3lx9uqdF+TNZfvO08YgDr +4aalKdiJdLNJEYdvsumzmmrrfihiRB2cpXmE= 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=IjaD5q8QKwN+jVDLQ1RW7mDtRCj+6oZDCsHq9KfG01Y=; b=K6/68SpzzEstPWBVblNcpoR0xvZVuj5fYjIr1azFt7ritzgNkTTu1BxRE7SQVqFb3B Q6Fqj4pL7H8Ud1cOcmtX1XoHg88Ji3q5Tx54xftqqVCpuGG2y3q4DAh7KyBojysUFP+x 0SAfwDedw0xRDrptxvXiqlY2K3KrmQ8o1UPCqPLY40CW/fC9EomH8kvA97iMxzD74tq5 5M+6BIvpRGFSgk1QmqKIdv4wfnibzAE4hyu4k8IzQXaBISwb2DDWXwmi2npalM5Q+ewG SQioVXiHNbrpOe18wy7SYAFemQ8JaYaSVDsclu3VG60Pljrnd3tNdlAbD2+12lqVAYxF EgeQ== X-Gm-Message-State: AOAM532Anw79UAddWeHOhN9dkJ32AVXeka140EOHPKWLehRUbaOGs7iR mlVmNl9ZgV/G5xYV7z8likI0YWqy9bsewJ//7Vk= X-Received: by 2002:a17:906:4ad8:: with SMTP id u24mr5148041ejt.186.1628901603283; Fri, 13 Aug 2021 17:40:03 -0700 (PDT) Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com. [209.85.208.42]) by smtp.gmail.com with ESMTPSA id c8sm1156476ejp.124.2021.08.13.17.40.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Aug 2021 17:40:03 -0700 (PDT) Received: by mail-ed1-f42.google.com with SMTP id i6so17913258edu.1 for ; Fri, 13 Aug 2021 17:40:03 -0700 (PDT) X-Received: by 2002:a05:6512:1290:: with SMTP id u16mr3294932lfs.487.1628901124175; Fri, 13 Aug 2021 17:32:04 -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> <87eeay8pqx.fsf@disp2133> <5b0d7c1e73ca43ef9ce6665fec6c4d7e@AcuMS.aculab.com> <87h7ft2j68.fsf@disp2133> In-Reply-To: <87h7ft2j68.fsf@disp2133> From: Linus Torvalds Date: Fri, 13 Aug 2021 14:31:46 -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: David Laight , 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-MM , Florian Weimer , "Michael Kerrisk (man-pages)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 13, 2021 at 10:18 AM Eric W. Biederman 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. Linus