Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933460AbdCUQlb (ORCPT ); Tue, 21 Mar 2017 12:41:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:40342 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933442AbdCUQl2 (ORCPT ); Tue, 21 Mar 2017 12:41:28 -0400 Date: Tue, 21 Mar 2017 17:41:22 +0100 From: Jan Kara To: "J. Bruce Fields" Cc: Jan Kara , Amir Goldstein , Filip =?utf-8?B?xaB0xJtkcm9uc2vDvQ==?= , linux-fsdevel , linux-kernel , Alexander Viro , Marko Rauhamaa Subject: Re: [RFC 2/2] fanotify: emit FAN_MODIFY_DIR on filesystem changes Message-ID: <20170321164122.GA18402@quack2.suse.cz> References: <20170319101943.GA1844@quack2.suse.cz> <20170321153849.GA15402@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20170321153849.GA15402@fieldses.org> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2638 Lines: 59 On Tue 21-03-17 11:38:49, J. Bruce Fields wrote: > On Sun, Mar 19, 2017 at 11:19:43AM +0100, Jan Kara wrote: > > On Tue 14-03-17 13:18:01, Amir Goldstein wrote: > > > On Tue, Mar 14, 2017 at 1:03 AM, Filip Štědronský wrote: > > > > Besause fanotify requires `struct path`, the event cannot be generated > > > > directly in `fsnotify_move` and friends because they only get the inode > > > > (and their callers, `vfs_rename`&co. cannot supply any better info). > > > > So instead it needs to be generated higher in the call chain, i.e. in > > > > the callers of functions like `vfs_rename`. > > > > > > > > This leads to some code duplication. Currently, there are several places > > > > whence functions like `vfs_rename` or `vfs_unlink` are called: > > > > > > > > * syscall handlers (done) > > > > * NFS server (done) > > > > * stacked filesystems > > > > - ecryptfs (done) > > > > - overlayfs > > > > (Currently doesn't report even ordinary fanotify events, because > > > > it internally clones the upper mount; not sure about the > > > > rationale. One can always watch the overlay mount instead.) > > > > * few rather minor things > > > > - devtmpfs > > > > (its internal changes are not tied to any vfsmount so it cannot > > > > emit mount-scoped events) > > > > - cachefiles (done) > > > > - ipc/mqueue.c (done) > > > > - fs/nfsd/nfs4recover.c (done) > > > > - kernel/bpf/inode.c (done) > > > > net/unix/af_unix.c (done) > > > > > > > > (grep -rE '\bvfs_(rename|unlink|mknod|whiteout|create|mkdir|rmdir|symlink|link)\(') > > > > > > > > Signed-off-by: Filip Štědronský > > > > > > > > --- > > > > > > > > An alternative might be to create wrapper functions like > > > > vfs_path_(rename|unlink|...). They could also take care of calling > > > > security_path_(rename|unlink|...), which is currently also up to > > > > the indvidual callers (possibly with a flag because it might not > > > > be always desired). > > > > > > That's an interesting idea. There is some duplicity between security/audit > > > hook and fsnotify hooks. It should be interesting to try and deduplicate > > > some of this code. > > > > Yeah, but ecryptfs or nfsd don't actually call these security hooks AFAICT. > > We don't? E.g. nfsd_unlink calls vfs_unlink which calls > security_inode_unlink(). OK, I have not been specific enough :). ecryptfs or nfsd don't call *path* security hooks AFAICT - e.g. security_path_unlink() from nfsd_unlink(). Honza -- Jan Kara SUSE Labs, CR