Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4930743pxv; Tue, 29 Jun 2021 20:36:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfCnUcfvjLBNV9cgZ9xptr9ciXosFIMW+bjwdOMjhbkio+WBEc4OzMq6R0oMm2OlyPDiCW X-Received: by 2002:a17:907:262e:: with SMTP id aq14mr33429354ejc.400.1625024186290; Tue, 29 Jun 2021 20:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625024186; cv=none; d=google.com; s=arc-20160816; b=ACHoITG8uniecos9gwAALeePZBTwM+ewFyuLLmh7HpUpwxL2qw00H0LejzktJOMR4/ mG1y1o+XUDf7J0/dNt8KgPC/0MSRogg+FMTs1ihspc+g20wwCBvkgnObRbLWiHFBncEm +Of+uuVseWru4F+97Ic4HoTV+fPRikpa5c97K3aPvOMu9dGW14hY6Gj1HqxFSWIzEBd7 clhMrBPfET8zAm8BPfzMd6xLIDCDymFCzPqDQSJV8Ys36XZqCPGsrXZ40fqaUJQEJ/Fm G9MGfhgkEJUXGWk9nds6zvMcn8YRxkQ4PnLCcmZ1Ni9BtxVhNAv90CEQxKdKqT7HxXgm QLeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=/4j9zSzgiR5o9dBrvDRjpy5UHlIQLNlyRVTLl62YnG8=; b=fGAGoT9hHpHUGyU/mNJY2xyu4AheqRQnvd3oiQXMjZNqr6q7gXQdeRSWuICFdWZYC3 /k/a9d7lD0guJWE80aeibyzecgqI/shDr0kNSr7ufXJfG8r9/HORfHC/0SEqWXTQ6sQM rrxE51vs3ME2Jz08pl9Ax9m+VWJG5KSt3Y8+jz4B2KSbKm0DF3IkgdrCMiK2UvUAMSsN rErDFRY0hH8H1Fdu+XivYMXDwKyl2+XHKfyJgJn/c7veLAY23uvri5iRPmGwqwXZCY2d JftMNP/VCGkz+zZTFua/BkMp+VywCt9IJbsMCeD9j+heZNfcIBRN4j/e8TOaao8dZDgu QQlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZubH7KLZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hz14si18402578ejc.533.2021.06.29.20.35.52; Tue, 29 Jun 2021 20:36:26 -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=@gmail.com header.s=20161025 header.b=ZubH7KLZ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232373AbhF3DQv (ORCPT + 99 others); Tue, 29 Jun 2021 23:16:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232009AbhF3DQv (ORCPT ); Tue, 29 Jun 2021 23:16:51 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FBC6C061760; Tue, 29 Jun 2021 20:14:23 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id 3so1466794ilj.3; Tue, 29 Jun 2021 20:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/4j9zSzgiR5o9dBrvDRjpy5UHlIQLNlyRVTLl62YnG8=; b=ZubH7KLZ6mjB4pFSL4MvhFzmLK82l4Zi8ifNgP/teFBOutPRUrkwUsTpk2HbPr3EVX /ejjazgSvw582cFHrFddC2mqZeXZVDMPme+Tx364PidcCffgtHXJd+bJAP9/RPawNkvs aJ1w55rljOynqiRxH8anXFMVI0M5u5hmc7tLYW+hjYGlYSb3zj4rl2gpPfQuLBydcMBI NQauMx3Ykr7n+ssI4hpobWHA6QVQ8ZowCKUW3MMgZfLuXPRT+7+1YrEPMgXCs7ZbEP9j bcNwR1sm+obZDBQmM7/NM5llUXOX9xqyD9zjg719czoaHH/lMVeP4/EGvA5nMSgN+kJv xZ1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/4j9zSzgiR5o9dBrvDRjpy5UHlIQLNlyRVTLl62YnG8=; b=uW24/i/uCIAe0tw1ZTHHlA7kL5Nqxk/FTmA4wzKwv51cG1tLEmej/Yy3kqbC41kEol MZmmgDzzNMq5Y4aXQXbqZsdGhTlDsejY+TBvUqII+jJmx28TmxMJpvb4+odhlZxm0Og2 NFj72xfqqExHxYCk8bsSgJk+1YS5hYmnTNPPTtu4klj0QtgT+tCEvbJLV0fkXjHdgi+R GWD/TWGJNVXSQ3e/y/Vsa1PrJ2MNST0/Xr0kdYs9lvjVHfvHqORqsZm5BoIQakDiwjyV NZ4Rvdu30AQeQSP3twWAPlmt5SDPpaU+VewsNkw2MG/Y038pLUfqS8ZQqaM8Emgud/KE 56Qw== X-Gm-Message-State: AOAM531gS6wd86uqld11H8J5j4rtkRbgGVj+rbkFpzwJU/Alp+xO/jCp fHNdxjZvgaoT8n/hIn0dlKxJIabpsZVjpQwaKsE= X-Received: by 2002:a92:dd05:: with SMTP id n5mr13801681ilm.72.1625022862724; Tue, 29 Jun 2021 20:14:22 -0700 (PDT) MIME-Version: 1.0 References: <20210629191035.681913-1-krisman@collabora.com> <20210629191035.681913-4-krisman@collabora.com> In-Reply-To: <20210629191035.681913-4-krisman@collabora.com> From: Amir Goldstein Date: Wed, 30 Jun 2021 06:14:11 +0300 Message-ID: Subject: Re: [PATCH v3 03/15] fanotify: Split fsid check from other fid mode checks To: Gabriel Krisman Bertazi Cc: "Darrick J. Wong" , Theodore Tso , Dave Chinner , Jan Kara , David Howells , Khazhismel Kumykov , linux-fsdevel , Ext4 , kernel@collabora.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Jun 29, 2021 at 10:12 PM 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 > Reviewed-by: Amir Goldstein > --- > 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 >