Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp5868022pxv; Wed, 7 Jul 2021 13:41:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6JA8sRhp48t3kme84nCuhw8JfN3ryW8VEfWdDHoI2eAlrIWv9b7MowtAvruVNkofnrvlR X-Received: by 2002:a6b:187:: with SMTP id 129mr14399604iob.188.1625690519649; Wed, 07 Jul 2021 13:41:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625690519; cv=none; d=google.com; s=arc-20160816; b=YPon0IdM5LJZBx0Xisqo8pyMlggvLupYYcQxAJ1yluZRHt8cWF7Nv9Lk/DScmH+0Jz TP3sPgO+k0DO9RZhbTAGxxQhe3ySYnR43ytFI6STaTevzLZMSEXFEz4E6oQwxF0FnA3b fuYtBHhwZf/JwmrqSeFlfiqfpBgiriW5BVss/C+6DQcu9eucDk88a/FTqMnVz8UqM2nJ cu3wgEiJeXTAzzpXs3W9Zx6KPrn9vskZMeSZ/7TyEwpLT16JnIB6gOL7ttPxtRUo8zN0 gVDvFSxDtfjiez65MEvlC3ndIPekYXRZyv0kXFr4w1OPCTrA3OHRqJxv3iajs7GucK3V mTDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=1/jzQ4eougwpQsFFhw7UoJdFuHPsU9zjSMn7cH0iGQA=; b=qavTNeN9tD0UQL9x/Pa7/TGjHlS2b4q+uaZEsoSijqk9mR4WpVcBRsFqssRDhLfjII JpinDkp+KtpFWSI8o1w5mI4GxD6GpUytECjVGuk0ruqKqB2bpoWD86jlRd+TR7KuFUDd 1AQourl6PrGqvlXeE/vhkUvYg8ZsG3eAoqWbtRxj7u/3OSuIV5eQp5hTc2OenikrS/Yn GzIWdffNSgUnDDVJRj7TJbY3rDDIA+E7baF8C1mJpNGfZ3AtBITPRwVr0DHXGjc7/Drn 51uyOhWydaHZ5WoeVKtwnjTuXZpmKzE+I6MgvXboSi6HMkiVcn0pszTNWUzPNM/lian5 +JUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=h9PqXGjW; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si15560637iod.32.2021.07.07.13.41.48; Wed, 07 Jul 2021 13:41:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=h9PqXGjW; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbhGGT1K (ORCPT + 99 others); Wed, 7 Jul 2021 15:27:10 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:55992 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbhGGT1I (ORCPT ); Wed, 7 Jul 2021 15:27:08 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D168322046; Wed, 7 Jul 2021 19:24:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1625685866; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1/jzQ4eougwpQsFFhw7UoJdFuHPsU9zjSMn7cH0iGQA=; b=h9PqXGjW5MCF7Dc7VRT4BzUj2/od+pz3dF4CSW3fX5a039yRhyzPFEsFfh+kMz+rDbnlad QbUcIqe5lX1I2KjZQ/QdANNx1ahm6jsoJOHL8bwQosYeBHVem7ywDAFadNg7izKq4dP5Ed /DxPJ5wJPOPQztGyblSBwITyYmTft8Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1625685866; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1/jzQ4eougwpQsFFhw7UoJdFuHPsU9zjSMn7cH0iGQA=; b=MDc8jJB4060Qbei30xTgBl4eLiSpqcTAaFMHJouLfK2VnNS0Et+OseU0DdWeJYRtVT2QcG cxA3cR9RtOQxYXCg== Received: from quack2.suse.cz (unknown [10.163.43.118]) by relay2.suse.de (Postfix) with ESMTP id B7DE0A3BA3; Wed, 7 Jul 2021 19:24:26 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 924701F2CD7; Wed, 7 Jul 2021 21:24:26 +0200 (CEST) Date: Wed, 7 Jul 2021 21:24:26 +0200 From: Jan Kara To: Gabriel Krisman Bertazi Cc: amir73il@gmail.com, djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, jack@suse.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v3 03/15] fanotify: Split fsid check from other fid mode checks Message-ID: <20210707192426.GE18396@quack2.suse.cz> References: <20210629191035.681913-1-krisman@collabora.com> <20210629191035.681913-4-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210629191035.681913-4-krisman@collabora.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue 29-06-21 15:10:23, Gabriel Krisman Bertazi wrote: > FAN_FS_ERROR will require fsid, but not necessarily require the > filesystem to expose a file handle. Split those checks into different > functions, so they can be used separately when setting up an event. > > While there, update a comment about tmpfs having 0 fsid, which is no > longer true. > > Signed-off-by: Gabriel Krisman Bertazi Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > > --- > Changes since v2: > - FAN_ERROR -> FAN_FS_ERROR (Amir) > - Update comment (Amir) > > Changes since v1: > (Amir) > - Sort hunks to simplify diff. > Changes since RFC: > (Amir) > - Rename fanotify_check_path_fsid -> fanotify_test_fsid. > - Use dentry directly instead of path. > --- > fs/notify/fanotify/fanotify_user.c | 27 ++++++++++++++++++--------- > 1 file changed, 18 insertions(+), 9 deletions(-) > > diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c > index 68a53d3534f8..67b18dfe0025 100644 > --- a/fs/notify/fanotify/fanotify_user.c > +++ b/fs/notify/fanotify/fanotify_user.c > @@ -1192,16 +1192,15 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) > return fd; > } > > -/* Check if filesystem can encode a unique fid */ > -static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid) > +static int fanotify_test_fsid(struct dentry *dentry, __kernel_fsid_t *fsid) > { > __kernel_fsid_t root_fsid; > int err; > > /* > - * Make sure path is not in filesystem with zero fsid (e.g. tmpfs). > + * Make sure dentry is not of a filesystem with zero fsid (e.g. fuse). > */ > - err = vfs_get_fsid(path->dentry, fsid); > + err = vfs_get_fsid(dentry, fsid); > if (err) > return err; > > @@ -1209,10 +1208,10 @@ static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid) > return -ENODEV; > > /* > - * Make sure path is not inside a filesystem subvolume (e.g. btrfs) > + * Make sure dentry is not of a filesystem subvolume (e.g. btrfs) > * which uses a different fsid than sb root. > */ > - err = vfs_get_fsid(path->dentry->d_sb->s_root, &root_fsid); > + err = vfs_get_fsid(dentry->d_sb->s_root, &root_fsid); > if (err) > return err; > > @@ -1220,6 +1219,12 @@ static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid) > root_fsid.val[1] != fsid->val[1]) > return -EXDEV; > > + return 0; > +} > + > +/* Check if filesystem can encode a unique fid */ > +static int fanotify_test_fid(struct dentry *dentry) > +{ > /* > * We need to make sure that the file system supports at least > * encoding a file handle so user can use name_to_handle_at() to > @@ -1227,8 +1232,8 @@ static int fanotify_test_fid(struct path *path, __kernel_fsid_t *fsid) > * objects. However, name_to_handle_at() requires that the > * filesystem also supports decoding file handles. > */ > - if (!path->dentry->d_sb->s_export_op || > - !path->dentry->d_sb->s_export_op->fh_to_dentry) > + if (!dentry->d_sb->s_export_op || > + !dentry->d_sb->s_export_op->fh_to_dentry) > return -EOPNOTSUPP; > > return 0; > @@ -1379,7 +1384,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, > } > > if (fid_mode) { > - ret = fanotify_test_fid(&path, &__fsid); > + ret = fanotify_test_fsid(path.dentry, &__fsid); > + if (ret) > + goto path_put_and_out; > + > + ret = fanotify_test_fid(path.dentry); > if (ret) > goto path_put_and_out; > > -- > 2.32.0 > -- Jan Kara SUSE Labs, CR