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=-7.3 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,USER_AGENT_SANE_1 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 EA8F8C432BE for ; Thu, 19 Aug 2021 14:33:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D354B610FA for ; Thu, 19 Aug 2021 14:33:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240476AbhHSOe0 (ORCPT ); Thu, 19 Aug 2021 10:34:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238547AbhHSOeZ (ORCPT ); Thu, 19 Aug 2021 10:34:25 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24918C061575; Thu, 19 Aug 2021 07:33:49 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 0EA147C77; Thu, 19 Aug 2021 10:33:48 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 0EA147C77 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1629383628; bh=jzbjzvXyQlf+H2UBIwSlz7fpA+3D5JHeP2MlM5sXDjI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LdI6RHpG6vWkbMJHx+T8sGp2HTIBMl8C6Y3I9MxMQf3OieaHH+54hTCP7w7HTcJYZ XoYA2s2NbzkXfX+sO+YgAEfITt5y2E/zJ58O83BiSUVh63ChGJvf5V2NsNQRmjXRkG SFh7CeCUmCNKPRCezs2FufWRHgsvgV65tLcV4278= Date: Thu, 19 Aug 2021 10:33:48 -0400 From: "J. Bruce Fields" To: "Eric W. Biederman" Cc: Andy Lutomirski , Linus Torvalds , David Laight , 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 , Christian =?utf-8?B?S8O2bmln?= , "linux-unionfs@vger.kernel.org" , Linux API , the arch/x86 maintainers , "" , Linux-MM , Florian Weimer , Michael Kerrisk Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE Message-ID: <20210819143348.GA21090@fieldses.org> References: <60db2e61-6b00-44fa-b718-e4361fcc238c@www.fastmail.com> <87lf56bllc.fsf@disp2133> <87eeay8pqx.fsf@disp2133> <5b0d7c1e73ca43ef9ce6665fec6c4d7e@AcuMS.aculab.com> <87h7ft2j68.fsf@disp2133> <20210818154217.GB24115@fieldses.org> <87bl5tv8pn.fsf@disp2133> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87bl5tv8pn.fsf@disp2133> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 19, 2021 at 08:56:52AM -0500, Eric W. Biederman wrote: > bfields@fieldses.org (J. Bruce Fields) writes: > > > On Fri, Aug 13, 2021 at 05:49:19PM -0700, Andy Lutomirski wrote: > >> I’ll bite. How about we attack this in the opposite direction: remove > >> the deny write mechanism entirely. > > > > For what it's worth, Windows has open flags that allow denying read or > > write opens. They also made their way into the NFSv4 protocol, but > > knfsd enforces them only against other NFSv4 clients. Last I checked, > > Samba attempted to emulate them using flock (and there's a comment to > > that effect on the flock syscall in fs/locks.c). I don't know what Wine > > does. > > > > Pavel Shilovsky posted flags adding O_DENY* flags years ago: > > > > https://lwn.net/Articles/581005/ > > > > I keep thinking I should look back at those some day but will probably > > never get to it. > > > > I've no idea how Windows applications use them, though I'm told it's > > common. > > I don't know in any detail. I just have this memory of not being able > to open or do anything with a file on windows while any application has > it open. > > We limit mandatory locks to filesystems that have the proper mount flag > and files that are sgid but are not executable. Reusing that limit we > could probably allow such a behavior in Linux without causing chaos. I'm pretty confused about how we're using the term "mandatory locking". The locks you're thinking of are basically ordinary posix byte-range locks which we attempt to enforce as mandatory under certain conditions (e.g. in fs/read_write.c:rw_verify_area). That means we have to check them on ordinary reads and writes, which is a pain in the butt. (And we don't manage to do it correctly--the code just checks for the existence of a conflicting lock before performing IO, ignoring the obvious time-of-check/time-of-use race.) This has nothing to do with Windows share locks which from what I understand are whole-file locks that are only enforced against opens. --b. > Without being very strict about which files can participate I can just > imagine someone hiding their presence by not allowing other applications > the ability to write to utmp or a log file. > > In the windows world where everything evolved with those kinds of > restrictions it is probably fine (although super annoying). > > Eric