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=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 ECD65C4338F for ; Fri, 20 Aug 2021 12:55:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C70BB61042 for ; Fri, 20 Aug 2021 12:55:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240547AbhHTMzk (ORCPT ); Fri, 20 Aug 2021 08:55:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:40996 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240401AbhHTMzj (ORCPT ); Fri, 20 Aug 2021 08:55:39 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BB3A06101A; Fri, 20 Aug 2021 12:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629464101; bh=aq47G7FYdzVG9JI5vCW3JdtF0Ql8JGW7+wEYumNG7w0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=a/FYE+XmpmUrhaskDVfwprhmXpSwMty4yUBq+SXncTVPNUlIvLIBnmvTnWwggz9iG s4ammRLDPZdPLd+dw89KRsm4iB6PdovqHvDvOdqKIjmTHY99DXaSADQHXb0vFVv0NH qXD0p0atBEqht2kLinJGRlJKZ/MrgRaGAJgnTlAQ/jSgEcJ/PTrnQ6GV02RwKSuSK6 ILPjLo6meDN5gtLC9cJgPFJgUvkYx794rjcRseD+sl8cASPtV9InoEjVyYoecgTGo2 Wg3NKtlbNwAEJ6Rxi9E4kJkoHo1P0utsc5wzjT5paKCoOPAXUQci/3UKhb/Ql3/VoZ wXJZ5nNwc5veg== Message-ID: <6b9e9485846c01d57f53adc35ddd0bfe42398eca.camel@kernel.org> Subject: Re: [PATCH v1 0/7] Remove in-tree usage of MAP_DENYWRITE From: Jeff Layton To: "J. Bruce Fields" , "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 =?ISO-8859-1?Q?K=F6nig?= , "linux-unionfs@vger.kernel.org" , Linux API , the arch/x86 maintainers , "" , Linux-MM , Florian Weimer , Michael Kerrisk Date: Fri, 20 Aug 2021 08:54:55 -0400 In-Reply-To: <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> <20210819143348.GA21090@fieldses.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.4 (3.40.4-1.fc34) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-unionfs@vger.kernel.org On Thu, 2021-08-19 at 10:33 -0400, J. Bruce Fields wrote: > 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.) > Yeah, the locks we're talking about are the locks described in: Documentation/filesystems/mandatory-locking.rst They've always been racy. You have to mount the fs with '-o mand' and set a special mode on the file (setgid bit set, with group execute bit cleared). It's a crazypants interface. > This has nothing to do with Windows share locks which from what I > understand are whole-file locks that are only enforced against opens. > Yep. Those are different. Confusingly, there is also LOCK_MAND|LOCK_READ|LOCK_WRITE for flock(), which are purported to be for emulating Windows share modes. They aren't really mandatory though. > --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 -- Jeff Layton