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=-3.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 A47BAC4320E for ; Fri, 20 Aug 2021 12:55:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4E562610D2 for ; Fri, 20 Aug 2021 12:55:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4E562610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id A6EEA6B0071; Fri, 20 Aug 2021 08:55:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1FD18D0001; Fri, 20 Aug 2021 08:55:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E5EB6B0073; Fri, 20 Aug 2021 08:55:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id 721AC6B0071 for ; Fri, 20 Aug 2021 08:55:03 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 1FF781814ECA9 for ; Fri, 20 Aug 2021 12:55:03 +0000 (UTC) X-FDA: 78495454086.17.056F646 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP id B646920019C6 for ; Fri, 20 Aug 2021 12:55:02 +0000 (UTC) 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 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="a/FYE+Xm"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of jlayton@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=jlayton@kernel.org X-Stat-Signature: eazoqunxsrcz6tu34qugbrpyr5851xns X-Rspamd-Queue-Id: B646920019C6 X-Rspamd-Server: rspam05 X-HE-Tag: 1629464102-760422 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: > >=20 > > > On Fri, Aug 13, 2021 at 05:49:19PM -0700, Andy Lutomirski wrote: > > > > I=E2=80=99ll bite. How about we attack this in the opposite dire= ction: remove > > > > the deny write mechanism entirely. > > >=20 > > > 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 check= ed, > > > 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. > > >=20 > > > Pavel Shilovsky posted flags adding O_DENY* flags years ago: > > >=20 > > > https://lwn.net/Articles/581005/ > > >=20 > > > I keep thinking I should look back at those some day but will proba= bly > > > never get to it. > > >=20 > > > I've no idea how Windows applications use them, though I'm told it'= s > > > common. > >=20 > > I don't know in any detail. I just have this memory of not being abl= e > > to open or do anything with a file on windows while any application h= as > > it open. > >=20 > > We limit mandatory locks to filesystems that have the proper mount fl= ag > > and files that are sgid but are not executable. Reusing that limit w= e > > could probably allow such a behavior in Linux without causing chaos. >=20 > I'm pretty confused about how we're using the term "mandatory locking". >=20 > 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 w= e > 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.) >=20 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. >=20 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. >=20 > > Without being very strict about which files can participate I can jus= t > > imagine someone hiding their presence by not allowing other applicati= ons > > the ability to write to utmp or a log file. > >=20 > > In the windows world where everything evolved with those kinds of > > restrictions it is probably fine (although super annoying). > >=20 > > Eric --=20 Jeff Layton