From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757361AbXIRSjz (ORCPT ); Tue, 18 Sep 2007 14:39:55 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754371AbXIRSjr (ORCPT ); Tue, 18 Sep 2007 14:39:47 -0400 Received: from extu-mxob-1.symantec.com ([216.10.194.28]:37475 "EHLO extu-mxob-1.symantec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753526AbXIRSjq (ORCPT ); Tue, 18 Sep 2007 14:39:46 -0400 Date: Tue, 18 Sep 2007 19:38:52 +0100 (BST) From: Hugh Dickins X-X-Sender: hugh@blonde.wat.veritas.com To: "J. Bruce Fields" cc: Trond Myklebust , Pavel Emelyanov , Andrew Morton , Linux Kernel Mailing List , devel@openvz.org Subject: Re: [PATCH] Wake up mandatory locks waiter on chmod (v2) In-Reply-To: <20070918174016.GF18476@fieldses.org> Message-ID: References: <46EE3724.80200@openvz.org> <1190037331.6700.14.camel@heimdal.trondhjem.org> <46EE8C52.80503@openvz.org> <1190044850.6700.81.camel@heimdal.trondhjem.org> <46EF7136.7080308@openvz.org> <20070918151957.GA18476@fieldses.org> <1190132095.6656.12.camel@heimdal.trondhjem.org> <20070918165220.GE18476@fieldses.org> <1190134496.6656.22.camel@heimdal.trondhjem.org> <20070918174016.GF18476@fieldses.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 18 Sep 2007, J. Bruce Fields wrote: > On Tue, Sep 18, 2007 at 12:54:56PM -0400, Trond Myklebust wrote: > > > > It gets even better when you throw mmap() into the mix :-) > > Hm. Documentation/mandatory.txt claims that it mandatory locks and > mmap() with MAP_SHARED exclude each other, but I can't see where that's > enfoced. That file doesn't make any mention of the above race. I believe the locks_verify_locked() call from mm/mmap.c prevents mmap'ing shared-write a file with mandatory locks in force; and the mapping_writably_mapped() calls from fs/locks.c prevent mandatory locking on a file while it's mmap'ed shared-write. Though I think there's no lock to prevent those checks racing, so it's not quite watertight. Hugh