From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:47830 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751771AbeE3NBh (ORCPT ); Wed, 30 May 2018 09:01:37 -0400 Date: Wed, 30 May 2018 15:01:36 +0200 From: Jan Kara To: henry.wilson@acentic.com Cc: jack@suse.cz, amir73il@gmail.com, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v3 4.17] inotify: Add flag IN_EXCL_ADD for inotify_add_watch() Message-ID: <20180530130136.uaj7akyuyp44mg3c@quack2.suse.cz> References: <20180516104430.1191-1-henry.wilson@acentic.com> <20180530102613.1194-1-henry.wilson@acentic.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180530102613.1194-1-henry.wilson@acentic.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Hello, On Wed 30-05-18 10:26:13, henry.wilson@acentic.com wrote: > From: Henry Wilson > > inotify: Add flag IN_EXCL_ADD for inotify_add_watch() > > The flag IN_EXCL_ADD is introduced as a flag for inotiy_add_watch() which > prevents inotify from modifying any existing watches when invoked. If the > pathname specified in the call has a watched inode associated with it and > IN_EXCL_ADD is specified, fail with an errno of EEXIST. > > RATIONALE > > In the current implementation, there is no way to prevent inotify_add_watch() > from modifying existing watch descriptors. Even if the caller keeps a record of > all watch descriptors collected, this is only sufficient to detect that an > existing watch descriptor may have been modified. > > The assumption that a particular path will map to the same inode over multiple > calls to inotify_add_watch() cannot be made as files can be renamed or deleted. > It is also not possible to assume that two distinct paths do no map to the same > inode, due to hard-links or a dereferenced symbolic link. Further uses of > inotify_add_watch() to revert the change may cause other watch descriptors to > be modified or created, merely compunding the problem. There is currently no > system call such as inotify_modify_watch() to explicity modify a watch > descriptor, which would be able to revert unwanted changes. Thus the caller > cannot guarantee to be able to revert any changes to existing watch decriptors. > > Additionally the caller cannot assume that the events that are associated with a > watch descriptor are within the set requested, as any future calls to > inotify_add_watch() may unintentionally modify a watch descriptor's mask. Thus > it cannot currently be guaranteed that a watch descriptor will only generate > events which have been requested. The program must filter events which come > through its watch descriptor to within its expected range. > > Signed-off-by: Henry Wilson Thanks. The patch looks good. I've added it to my tree. BTW, do you plan on working on a similar addition to fanotify? Honza -- Jan Kara SUSE Labs, CR