From patchwork Fri Oct 29 11:40:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592543 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F02BC433EF for ; Fri, 29 Oct 2021 11:40:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E57B360E90 for ; Fri, 29 Oct 2021 11:40:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231989AbhJ2LnG (ORCPT ); Fri, 29 Oct 2021 07:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231969AbhJ2LnC (ORCPT ); Fri, 29 Oct 2021 07:43:02 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD052C061745 for ; Fri, 29 Oct 2021 04:40:33 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id b2-20020a1c8002000000b0032fb900951eso4154102wmd.4 for ; Fri, 29 Oct 2021 04:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=espOezy5a4LSuBEze/qzpkewNvpn19NpfS0DCjbYONk=; b=IK+dlluqI7uBf8cJsP1RWYwtmHQn5U0ZT4CbgwBpd/N6UO/+KzshGqnoOaArFU+aUe wpIR7vOSp04Dg89sRo4okSoXje/Kxso4C+MNksntIeAuKEts+gjcsRekCCBrS1njMttw k0sjBG/R5ckZCgy0IB0gGTuaeO6AzS+hXm5LhsD1h3LUKZBsD+lXk6JvE7ullxCTEJDU UTrh8qCKMlcVFehcbFTXG6pZ5FEZ8BxW9AQtYAw537uNBgcxaevTH6ziDHIeOC6ZPrAN FJeIHVJozyZP1mRu+7yv99BVAHESwTfZ5WyjwB6Nhp/8fv1DS1KFTdAEu8rfXqIbESS6 0GZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=espOezy5a4LSuBEze/qzpkewNvpn19NpfS0DCjbYONk=; b=JtfGqFRn6Fg60L8l3K37QBe+5GttTnJ9DqkbVOcfOWKqhitoM+Cx6IUrYWZWvhUZZO UxT6BJtbt7XGks79QKnPGQnYCAswrgUaGss0WkMKRapEFoSXL9POCoiMbXy+jMkZUtX7 ehiSV1vcpeEtObHZKey3Ng9/WZjke36XU1Jpk6CkDnPTPZpclsE6tk/PrJJ5K6kc8/Jy I0f1RBycX95lgpE38w1Qxq4o54yEyyTCVFmiHZ16PnxEYb7NzLET3e3/dT5o1IsHH5Ak GaXs6RZib24KZat0AdwbZBlD+/yfuovjzxYPYzjImKfen+Cc1jIjvbkhxjDTiDSYMFSj vyxg== X-Gm-Message-State: AOAM532R218FG2gZt+cVZzhKaJ3CSdASp9YOq3lrW3ckb2HiHbIzZy31 bPJWrNCYh/6Ku35cj9LkLSU6Y6jUX+c= X-Google-Smtp-Source: ABdhPJxnzQtAJxbXqS3J1eqcEbo2L7G6A9tYNZRUwc4x8yTAv4Tu0DWS9jUk59kuznhENcQUbuZl4g== X-Received: by 2002:a1c:29c2:: with SMTP id p185mr18939857wmp.43.1635507632509; Fri, 29 Oct 2021 04:40:32 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:32 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 1/7] fsnotify: pass dentry instead of inode data for move events Date: Fri, 29 Oct 2021 14:40:22 +0300 Message-Id: <20211029114028.569755-2-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org This is needed for reporting the new parent/name with MOVED_FROM events. Signed-off-by: Amir Goldstein --- include/linux/fsnotify.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h index 787545e87eeb..ae7501c80d05 100644 --- a/include/linux/fsnotify.h +++ b/include/linux/fsnotify.h @@ -140,7 +140,6 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, int isdir, struct inode *target, struct dentry *moved) { - struct inode *source = moved->d_inode; u32 fs_cookie = fsnotify_get_cookie(); __u32 old_dir_mask = FS_MOVED_FROM; __u32 new_dir_mask = FS_MOVED_TO; @@ -154,14 +153,14 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, new_dir_mask |= FS_ISDIR; } - fsnotify_name(old_dir_mask, source, FSNOTIFY_EVENT_INODE, + fsnotify_name(old_dir_mask, moved, FSNOTIFY_EVENT_DENTRY, old_dir, old_name, fs_cookie); - fsnotify_name(new_dir_mask, source, FSNOTIFY_EVENT_INODE, + fsnotify_name(new_dir_mask, moved, FSNOTIFY_EVENT_DENTRY, new_dir, new_name, fs_cookie); if (target) fsnotify_link_count(target); - fsnotify_inode(source, FS_MOVE_SELF); + fsnotify_inode(d_inode(moved), FS_MOVE_SELF); audit_inode_child(new_dir, moved, AUDIT_TYPE_CHILD_CREATE); } From patchwork Fri Oct 29 11:40:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592541 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04D6CC4332F for ; Fri, 29 Oct 2021 11:40:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E09FF61177 for ; Fri, 29 Oct 2021 11:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbhJ2LnG (ORCPT ); Fri, 29 Oct 2021 07:43:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231975AbhJ2LnD (ORCPT ); Fri, 29 Oct 2021 07:43:03 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25864C061766 for ; Fri, 29 Oct 2021 04:40:35 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id o4-20020a1c7504000000b0032cab7473caso6278320wmc.1 for ; Fri, 29 Oct 2021 04:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eDdVEl7RYwzPP059buZk/UmFoXcITSgcfDQMfWHjV34=; b=VEkRPbmbY8pWjFjg+SM/PMX952Exy9zoRkcaNw/CmeHWrinHNFUkDjtl6yFRkB898V 6D2locRES6EQ67BGrTSEzVJ5PtEc9ZfcsdoFM3Soy4RsV6tm3RfktCJaPupdM20OPaRQ bwCWyb19Wv2ZbSS5jGeZAZitNA5ukha93c9o48gTWwfrMyeRhIP2fyQ2awPL9QY0qiHU 1XgEW9DRY9G3n3P145LTehRFqlzZN6IyOcigGL64R3VaroyA/LoPst9IV6Q5Nwm4QEG3 /ENaIzS0bUc3XynRhyIXZTv22Ay4jwu2aEzKSuEAiTXaGegA1Ou33rehCGt9uT2mEfan lxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eDdVEl7RYwzPP059buZk/UmFoXcITSgcfDQMfWHjV34=; b=Vs5bTCeBpegjG1dt1SLIuBemQtbWLBGKRY6rb0lKy1H96aUMZojhgzGvWkdqA5U3yJ vezDePZnTYd+0MyfG7IB6IUFKlCMKkmT8S1wb4AjuYMMadOWNP/geqNg0EpdJC2ux7h1 W1QiOpX5vSYnxbA2U3kPI31pXECGCR44SeXTKnbCxwhcn/maLctrb3p/665sLEh1WmVA 9wXeH1OnDpJz6dTGsFaGEkzfo8HwtqVrNyUc64LPaO4lM9kKH+iokxUHuEFAT0RI8R7t FUpSy6WiGdaGJPwOkewRxie9gzA7eQATBz7TiK0pBBxEL/yeAFnztEKYg0N3Crq43eBP aHUw== X-Gm-Message-State: AOAM531v9XF3GLntK4tcuOyg0Sx46amT62MB/o4lbDjzXpdsrg4WB2dT GJTDpLF+WH9IUa15uL6+EWRgWk+fCJs= X-Google-Smtp-Source: ABdhPJxDlnkTTUBBIPnoHkRxZwD11CGBGXy4+u+t4DeYbcfupZNJp+98/+u0FQq6002CyC2cchOwLA== X-Received: by 2002:a7b:c2f7:: with SMTP id e23mr6808166wmk.92.1635507633662; Fri, 29 Oct 2021 04:40:33 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:33 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 2/7] fanotify: introduce group flag FAN_REPORT_TARGET_FID Date: Fri, 29 Oct 2021 14:40:23 +0300 Message-Id: <20211029114028.569755-3-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org FAN_REPORT_FID is ambiguous in that it reports the fid of the child for some events and the fid of the parent for create/delete/move events. The new FAN_REPORT_TARGET_FID flag is an implicit request to report the fid of the target object of the operation (a.k.a the child inode) also in create/delete/move events in addition to the fid of the parent and the name of the child. To reduce the test matrix for uninteresting use cases, the new FAN_REPORT_TARGET_FID flag requires both FAN_REPORT_NAME and FAN_REPORT_FID. The convenience macro FAN_REPORT_ALL_FIDS combines FAN_REPORT_TARGET_FID with all the required flags. The new flag is not yet enabled in this change. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 48 ++++++++++++++++++++++-------- fs/notify/fanotify/fanotify_user.c | 9 ++++++ include/uapi/linux/fanotify.h | 4 +++ 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index b6091775aa6e..9b1641ecfe97 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -458,17 +458,41 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, } /* - * The inode to use as identifier when reporting fid depends on the event. - * Report the modified directory inode on dirent modification events. - * Report the "victim" inode otherwise. + * FAN_REPORT_FID is ambiguous in that it reports the fid of the child for + * some events and the fid of the parent for create/delete/move events. + * + * With the FAN_REPORT_TARGET_FID flag, the fid of the child is reported + * also in create/delete/move events in addition to the fid of the parent + * and the name of the child. + */ +static inline bool fanotify_report_child_fid(unsigned int fid_mode, u32 mask) +{ + if (mask & ALL_FSNOTIFY_DIRENT_EVENTS) + return (fid_mode & FAN_REPORT_TARGET_FID); + + return (fid_mode & FAN_REPORT_FID) && !(mask & FAN_ONDIR); +} + +/* + * The inode to use as identifier when reporting fid depends on the event + * and the group flags. + * + * With the group flag FAN_REPORT_TARGET_FID, always report the child fid. + * + * Without the group flag FAN_REPORT_TARGET_FID, report the modified directory + * fid on dirent events and the child fid otherwise. + * * For example: - * FS_ATTRIB reports the child inode even if reported on a watched parent. - * FS_CREATE reports the modified dir inode and not the created inode. + * FS_ATTRIB reports the child fid even if reported on a watched parent. + * FS_CREATE reports the modified dir fid without FAN_REPORT_TARGET_FID. + * and reports the created child fid with FAN_REPORT_TARGET_FID. */ static struct inode *fanotify_fid_inode(u32 event_mask, const void *data, - int data_type, struct inode *dir) + int data_type, struct inode *dir, + unsigned int fid_mode) { - if (event_mask & ALL_FSNOTIFY_DIRENT_EVENTS) + if ((event_mask & ALL_FSNOTIFY_DIRENT_EVENTS) && + !(fid_mode & FAN_REPORT_TARGET_FID)) return dir; return fsnotify_data_inode(data, data_type); @@ -647,10 +671,11 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, { struct fanotify_event *event = NULL; gfp_t gfp = GFP_KERNEL_ACCOUNT; - struct inode *id = fanotify_fid_inode(mask, data, data_type, dir); + unsigned int fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); + struct inode *id = fanotify_fid_inode(mask, data, data_type, dir, + fid_mode); struct inode *dirid = fanotify_dfid_inode(mask, data, data_type, dir); const struct path *path = fsnotify_data_path(data, data_type); - unsigned int fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); struct mem_cgroup *old_memcg; struct inode *child = NULL; bool name_event = false; @@ -660,11 +685,10 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, if ((fid_mode & FAN_REPORT_DIR_FID) && dirid) { /* - * With both flags FAN_REPORT_DIR_FID and FAN_REPORT_FID, we - * report the child fid for events reported on a non-dir child + * For certain events and group flags, report the child fid * in addition to reporting the parent fid and maybe child name. */ - if ((fid_mode & FAN_REPORT_FID) && id != dirid && !ondir) + if (fanotify_report_child_fid(fid_mode, mask) && id != dirid) child = id; id = dirid; diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 559bc1e9926d..6ec26b124041 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1275,6 +1275,15 @@ SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags) if ((fid_mode & FAN_REPORT_NAME) && !(fid_mode & FAN_REPORT_DIR_FID)) return -EINVAL; + /* + * FAN_REPORT_TARGET_FID requires FAN_REPORT_NAME and FAN_REPORT_FID + * and is used as an indication to report both dir and child fid on all + * dirent events. + */ + if ((fid_mode & FAN_REPORT_TARGET_FID) && + (!(fid_mode & FAN_REPORT_NAME) || !(fid_mode & FAN_REPORT_FID))) + return -EINVAL; + f_flags = O_RDWR | FMODE_NONOTIFY; if (flags & FAN_CLOEXEC) f_flags |= O_CLOEXEC; diff --git a/include/uapi/linux/fanotify.h b/include/uapi/linux/fanotify.h index bd1932c2074d..f9202ce31b0d 100644 --- a/include/uapi/linux/fanotify.h +++ b/include/uapi/linux/fanotify.h @@ -57,9 +57,13 @@ #define FAN_REPORT_FID 0x00000200 /* Report unique file id */ #define FAN_REPORT_DIR_FID 0x00000400 /* Report unique directory id */ #define FAN_REPORT_NAME 0x00000800 /* Report events with name */ +#define FAN_REPORT_TARGET_FID 0x00001000 /* Report dirent target id */ /* Convenience macro - FAN_REPORT_NAME requires FAN_REPORT_DIR_FID */ #define FAN_REPORT_DFID_NAME (FAN_REPORT_DIR_FID | FAN_REPORT_NAME) +/* Convenience macro - FAN_REPORT_TARGET_FID requires all other FID flags */ +#define FAN_REPORT_ALL_FIDS (FAN_REPORT_DFID_NAME | FAN_REPORT_FID | \ + FAN_REPORT_TARGET_FID) /* Deprecated - do not use this in programs and do not add new flags here! */ #define FAN_ALL_INIT_FLAGS (FAN_CLOEXEC | FAN_NONBLOCK | \ From patchwork Fri Oct 29 11:40:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BC1EC433F5 for ; Fri, 29 Oct 2021 11:40:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CE4F61167 for ; Fri, 29 Oct 2021 11:40:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232012AbhJ2LnH (ORCPT ); Fri, 29 Oct 2021 07:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231977AbhJ2LnF (ORCPT ); Fri, 29 Oct 2021 07:43:05 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 440E7C061767 for ; Fri, 29 Oct 2021 04:40:36 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id k7so15662112wrd.13 for ; Fri, 29 Oct 2021 04:40:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=doaEFdEkruCJZPvutxr6JHq6+EhQEfwiw9SykkAMsFY=; b=a1oSi2qq3nGyoDLZ7vf7rNygNPk3OBqHE6NukaVHYjhiaUWT9k25wK48RTbm8KvoQs XQ58GupmiE/52NoiKqzk5U8CabrjcKxDLmZ3dWj0GHyzvsl2PPm56Y5XBfGUMRKmXWUj 1QBriltSW/AtURZ1mZPeTEr+cW7eFbb8HY+ifh0ys548mj7yuM806/IQDtOl2EMpRCay YmBBwQrrTrVLuZpJ3N2IKqFBDtA57hHw5zw8Z6YK+z6+X0shbnKbQaf2HkMqW36WGwKg /LZf3GIzfAHhlcrRds5b9V3LG/XnztGVYqQohteGLZIo2OrPpgT6BCqGo4qnboLk2Uis cvCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=doaEFdEkruCJZPvutxr6JHq6+EhQEfwiw9SykkAMsFY=; b=In9XkhXdJqYlOgUdjHqrvtDcxuU96+V9dqJZ42rtGBKY2OaGzArHQJ4+AIYk9g5CMY k4Ghg4fNw7aFrVNlu02uEErSZuSzfELGD7/COy+mEkwytJwNPn6zyVPfSBKDYUVCmnoM r2On4hfOsPadPKWKyHWQYCuW4K0v+7gsQOvpBZTFB+UJtd0o0trAy/cZyqRieOiZHKw9 xJy4yJEhLGPO+HpKtrqO5yii6TK4KScZ60vyTOsxW6+ZPtHy1jAaVT3pmLqnPq0QuCj8 o28WyP96m7dldFf0mNu9wU2jloB/XWq9rYpf2e7kaLNU0/JKS5yIrtOGuwK6QyChhkTn ecYw== X-Gm-Message-State: AOAM53214IDFK9PWFMh+wGA0npX49Ap03+jGxMz6zXu1VTwtTpZ40Wej OAdXB4inhLINsRPRObpCWVuX88ZlLck= X-Google-Smtp-Source: ABdhPJxiUcecBjXyHHNFBDs1oMv4qKrhO9NwXiR8jwD21cYs3uvk/L1ghFhSP2YBt9ZiDcwFKbXEKw== X-Received: by 2002:a5d:4004:: with SMTP id n4mr13830391wrp.49.1635507634922; Fri, 29 Oct 2021 04:40:34 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:34 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 3/7] fanotify: use macros to get the offset to fanotify_info buffer Date: Fri, 29 Oct 2021 14:40:24 +0300 Message-Id: <20211029114028.569755-4-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org The fanotify_info buffer contains up to two file handles and a name. Use macros to simplify the code that access the different items within the buffer. Add assertions to verify that stored fh len and name len do not overflow the u8 stored value in fanotify_info header. Remove the unused fanotify_info_len() helper. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 2 +- fs/notify/fanotify/fanotify.h | 41 +++++++++++++++++++++++++---------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 9b1641ecfe97..4a812411ae5b 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -411,7 +411,7 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, * be zero in that case if encoding fh len failed. */ err = -ENOENT; - if (fh_len < 4 || WARN_ON_ONCE(fh_len % 4)) + if (fh_len < 4 || WARN_ON_ONCE(fh_len % 4) || fh_len > MAX_HANDLE_SZ) goto out_err; /* No external buffer in a variable size allocated fh */ diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index d25f500bf7e7..dd23ba659e76 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -49,6 +49,22 @@ struct fanotify_info { * (optional) file_fh starts at buf[dir_fh_totlen] * name starts at buf[dir_fh_totlen + file_fh_totlen] */ +#define FANOTIFY_DIR_FH_SIZE(info) ((info)->dir_fh_totlen) +#define FANOTIFY_FILE_FH_SIZE(info) ((info)->file_fh_totlen) +#define FANOTIFY_NAME_SIZE(info) ((info)->name_len + 1) + +#define FANOTIFY_DIR_FH_OFFSET(info) 0 +#define FANOTIFY_FILE_FH_OFFSET(info) \ + (FANOTIFY_DIR_FH_OFFSET(info) + FANOTIFY_DIR_FH_SIZE(info)) +#define FANOTIFY_NAME_OFFSET(info) \ + (FANOTIFY_FILE_FH_OFFSET(info) + FANOTIFY_FILE_FH_SIZE(info)) + +#define FANOTIFY_DIR_FH_BUF(info) \ + ((info)->buf + FANOTIFY_DIR_FH_OFFSET(info)) +#define FANOTIFY_FILE_FH_BUF(info) \ + ((info)->buf + FANOTIFY_FILE_FH_OFFSET(info)) +#define FANOTIFY_NAME_BUF(info) \ + ((info)->buf + FANOTIFY_NAME_OFFSET(info)) } __aligned(4); static inline bool fanotify_fh_has_ext_buf(struct fanotify_fh *fh) @@ -87,7 +103,7 @@ static inline struct fanotify_fh *fanotify_info_dir_fh(struct fanotify_info *inf { BUILD_BUG_ON(offsetof(struct fanotify_info, buf) % 4); - return (struct fanotify_fh *)info->buf; + return (struct fanotify_fh *)FANOTIFY_DIR_FH_BUF(info); } static inline int fanotify_info_file_fh_len(struct fanotify_info *info) @@ -101,32 +117,35 @@ static inline int fanotify_info_file_fh_len(struct fanotify_info *info) static inline struct fanotify_fh *fanotify_info_file_fh(struct fanotify_info *info) { - return (struct fanotify_fh *)(info->buf + info->dir_fh_totlen); + return (struct fanotify_fh *)FANOTIFY_FILE_FH_BUF(info); } -static inline const char *fanotify_info_name(struct fanotify_info *info) +static inline char *fanotify_info_name(struct fanotify_info *info) { - return info->buf + info->dir_fh_totlen + info->file_fh_totlen; + if (!info->name_len) + return NULL; + + return FANOTIFY_NAME_BUF(info); } static inline void fanotify_info_init(struct fanotify_info *info) { + BUILD_BUG_ON(FANOTIFY_FH_HDR_LEN + MAX_HANDLE_SZ > U8_MAX); + BUILD_BUG_ON(NAME_MAX > U8_MAX); + info->dir_fh_totlen = 0; info->file_fh_totlen = 0; info->name_len = 0; } -static inline unsigned int fanotify_info_len(struct fanotify_info *info) -{ - return info->dir_fh_totlen + info->file_fh_totlen + info->name_len; -} - static inline void fanotify_info_copy_name(struct fanotify_info *info, const struct qstr *name) { + if (WARN_ON_ONCE(name->len > NAME_MAX)) + return; + info->name_len = name->len; - strcpy(info->buf + info->dir_fh_totlen + info->file_fh_totlen, - name->name); + strcpy(fanotify_info_name(info), name->name); } /* From patchwork Fri Oct 29 11:40:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D559C433F5 for ; Fri, 29 Oct 2021 11:40:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2674960E90 for ; Fri, 29 Oct 2021 11:40:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231977AbhJ2LnI (ORCPT ); Fri, 29 Oct 2021 07:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231950AbhJ2LnG (ORCPT ); Fri, 29 Oct 2021 07:43:06 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85B4CC061570 for ; Fri, 29 Oct 2021 04:40:37 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id j35-20020a05600c1c2300b0032caeca81b7so6287413wms.0 for ; Fri, 29 Oct 2021 04:40:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7uHdcHLK3HL6YvF7t01X/TPud3lCRN25c62u2gCgvw4=; b=Gw1cek89MrZvjGzIhtNWcJNdX4Tw8TDFJsTw+01hLSnSevN2OAYz9zP9PxXQsaakcW kqAW0ScKL3/VfUnyNoB7H7OG8PCmZi8laxeUwlYt68ams7Vu9JFRqnOMwvDzQbXPIDQ2 VpQy22oKRDUWPD3J5Kigjy1yO05vdgVQNP8vsScPbU5rYzfZHve1dfzus5h5X+ihJ0Rc W601lBnBza9FKNGfttIb7+j8GEaQrUwLcdTWqoqqvp3cnCsECHC35/+ER3/kh8roWfiC x74CzVA8i4pU3Ga0NzajJtDM/kNBY+wNGst7jYrYqY4aIM/TYlFpsEeK6VSQf9Hqc99J U0aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7uHdcHLK3HL6YvF7t01X/TPud3lCRN25c62u2gCgvw4=; b=RDskXAv9y6SzD5CtNYecq0Ir0fDe6U/WDZ08DLG3BxQ1H9OBDGz4AeGXS4obEJZiYn I0yxmdr6ciVz/EXHHLmbR2d6LAiHWxO0pr3uvq3NuSpI016V3TBpFKMl3svOi9efb7wL 65espCEt+Tl0RdhEgZAX2ZuO1uDr72EvbrClsKCde2vIjOwy7/2xTARxEUduj3wurs8o 06Qp0OPdaVQSb3H/CB5+mgk0ql4Ak7wqJ2wWSpOxBlAltWB0Cb0vog+RbaM0yciNnOXb qAOJm+Y8TQLGJ609CR5xX/UvdmXvDVNO2oVu/FD+sy4wUsY5wA1W2XwfHe8v8H4JU+9I mfRg== X-Gm-Message-State: AOAM5308EX7EqxSfhx5Hb1Qi8S4HmFo8c8wPYj0Z4Tg2Rhe8pVNIBGdM 49vXQjdFXyy6/mK+tCbEq745PnecvBE= X-Google-Smtp-Source: ABdhPJzA7GwS3QvUkbfm/9zKLJ9eBHkszL4za75U3DmQ7cdbcBe4tW/uBB5D9HKB/IVXOsCe+2TNqg== X-Received: by 2002:a05:600c:8a4:: with SMTP id l36mr19427836wmp.17.1635507636154; Fri, 29 Oct 2021 04:40:36 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:35 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 4/7] fanotify: support secondary dir fh and name in fanotify_info Date: Fri, 29 Oct 2021 14:40:25 +0300 Message-Id: <20211029114028.569755-5-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Allow storing a secondary dir fh and name tupple in fanotify_info. The secondary dir fh and name can only be stored after storing the primary dir fh and name. This will be used to store the new parent and name information in MOVED_FROM event. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 20 ++++++++--- fs/notify/fanotify/fanotify.h | 57 +++++++++++++++++++++++++++--- fs/notify/fanotify/fanotify_user.c | 3 +- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 4a812411ae5b..795bedcb6f9b 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -76,8 +76,10 @@ static bool fanotify_info_equal(struct fanotify_info *info1, struct fanotify_info *info2) { if (info1->dir_fh_totlen != info2->dir_fh_totlen || + info1->dir2_fh_totlen != info2->dir2_fh_totlen || info1->file_fh_totlen != info2->file_fh_totlen || - info1->name_len != info2->name_len) + info1->name_len != info2->name_len || + info1->name2_len != info2->name2_len) return false; if (info1->dir_fh_totlen && @@ -85,14 +87,24 @@ static bool fanotify_info_equal(struct fanotify_info *info1, fanotify_info_dir_fh(info2))) return false; + if (info1->dir2_fh_totlen && + !fanotify_fh_equal(fanotify_info_dir2_fh(info1), + fanotify_info_dir2_fh(info2))) + return false; + if (info1->file_fh_totlen && !fanotify_fh_equal(fanotify_info_file_fh(info1), fanotify_info_file_fh(info2))) return false; - return !info1->name_len || - !memcmp(fanotify_info_name(info1), fanotify_info_name(info2), - info1->name_len); + if (info1->name_len && + memcmp(fanotify_info_name(info1), fanotify_info_name(info2), + info1->name_len)) + return false; + + return !info1->name2_len || + !memcmp(fanotify_info_name2(info1), fanotify_info_name2(info2), + info1->name2_len); } static bool fanotify_name_event_equal(struct fanotify_name_event *fne1, diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index dd23ba659e76..0864e7efe23c 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -40,31 +40,45 @@ struct fanotify_fh { struct fanotify_info { /* size of dir_fh/file_fh including fanotify_fh hdr size */ u8 dir_fh_totlen; + u8 dir2_fh_totlen; u8 file_fh_totlen; u8 name_len; - u8 pad; + u8 name2_len; + u8 pad[3]; unsigned char buf[]; /* * (struct fanotify_fh) dir_fh starts at buf[0] - * (optional) file_fh starts at buf[dir_fh_totlen] - * name starts at buf[dir_fh_totlen + file_fh_totlen] + * (optional) dir2_fh starts at buf[dir_fh_totlen] + * (optional) file_fh starts at buf[dir_fh_totlen + dir2_fh_totlen] + * name starts at buf[dir_fh_totlen + dir2_fh_totlen + file_fh_totlen] + * ... */ #define FANOTIFY_DIR_FH_SIZE(info) ((info)->dir_fh_totlen) +#define FANOTIFY_DIR2_FH_SIZE(info) ((info)->dir2_fh_totlen) #define FANOTIFY_FILE_FH_SIZE(info) ((info)->file_fh_totlen) #define FANOTIFY_NAME_SIZE(info) ((info)->name_len + 1) +#define FANOTIFY_NAME2_SIZE(info) ((info)->name2_len + 1) #define FANOTIFY_DIR_FH_OFFSET(info) 0 -#define FANOTIFY_FILE_FH_OFFSET(info) \ +#define FANOTIFY_DIR2_FH_OFFSET(info) \ (FANOTIFY_DIR_FH_OFFSET(info) + FANOTIFY_DIR_FH_SIZE(info)) +#define FANOTIFY_FILE_FH_OFFSET(info) \ + (FANOTIFY_DIR2_FH_OFFSET(info) + FANOTIFY_DIR2_FH_SIZE(info)) #define FANOTIFY_NAME_OFFSET(info) \ (FANOTIFY_FILE_FH_OFFSET(info) + FANOTIFY_FILE_FH_SIZE(info)) +#define FANOTIFY_NAME2_OFFSET(info) \ + (FANOTIFY_NAME_OFFSET(info) + FANOTIFY_NAME_SIZE(info)) #define FANOTIFY_DIR_FH_BUF(info) \ ((info)->buf + FANOTIFY_DIR_FH_OFFSET(info)) +#define FANOTIFY_DIR2_FH_BUF(info) \ + ((info)->buf + FANOTIFY_DIR2_FH_OFFSET(info)) #define FANOTIFY_FILE_FH_BUF(info) \ ((info)->buf + FANOTIFY_FILE_FH_OFFSET(info)) #define FANOTIFY_NAME_BUF(info) \ ((info)->buf + FANOTIFY_NAME_OFFSET(info)) +#define FANOTIFY_NAME2_BUF(info) \ + ((info)->buf + FANOTIFY_NAME2_OFFSET(info)) } __aligned(4); static inline bool fanotify_fh_has_ext_buf(struct fanotify_fh *fh) @@ -106,6 +120,20 @@ static inline struct fanotify_fh *fanotify_info_dir_fh(struct fanotify_info *inf return (struct fanotify_fh *)FANOTIFY_DIR_FH_BUF(info); } +static inline int fanotify_info_dir2_fh_len(struct fanotify_info *info) +{ + if (!info->dir2_fh_totlen || + WARN_ON_ONCE(info->dir2_fh_totlen < FANOTIFY_FH_HDR_LEN)) + return 0; + + return info->dir2_fh_totlen - FANOTIFY_FH_HDR_LEN; +} + +static inline struct fanotify_fh *fanotify_info_dir2_fh(struct fanotify_info *info) +{ + return (struct fanotify_fh *)FANOTIFY_DIR2_FH_BUF(info); +} + static inline int fanotify_info_file_fh_len(struct fanotify_info *info) { if (!info->file_fh_totlen || @@ -128,14 +156,24 @@ static inline char *fanotify_info_name(struct fanotify_info *info) return FANOTIFY_NAME_BUF(info); } +static inline char *fanotify_info_name2(struct fanotify_info *info) +{ + if (!info->name_len || !info->name2_len) + return NULL; + + return FANOTIFY_NAME2_BUF(info); +} + static inline void fanotify_info_init(struct fanotify_info *info) { BUILD_BUG_ON(FANOTIFY_FH_HDR_LEN + MAX_HANDLE_SZ > U8_MAX); BUILD_BUG_ON(NAME_MAX > U8_MAX); info->dir_fh_totlen = 0; + info->dir2_fh_totlen = 0; info->file_fh_totlen = 0; info->name_len = 0; + info->name2_len = 0; } static inline void fanotify_info_copy_name(struct fanotify_info *info, @@ -148,6 +186,17 @@ static inline void fanotify_info_copy_name(struct fanotify_info *info, strcpy(fanotify_info_name(info), name->name); } +static inline void fanotify_info_copy_name2(struct fanotify_info *info, + const struct qstr *name) +{ + if (WARN_ON_ONCE(name->len > NAME_MAX) || + WARN_ON_ONCE(!info->name_len)) + return; + + info->name2_len = name->len; + strcpy(fanotify_info_name2(info), name->name); +} + /* * Common structure for fanotify events. Concrete structs are allocated in * fanotify_handle_event() and freed when the information is retrieved by diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 6ec26b124041..d973f36676a9 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -332,11 +332,10 @@ static int process_access_response(struct fsnotify_group *group, static size_t copy_error_info_to_user(struct fanotify_event *event, char __user *buf, int count) { - struct fanotify_event_info_error info; + struct fanotify_event_info_error info = { }; struct fanotify_error_event *fee = FANOTIFY_EE(event); info.hdr.info_type = FAN_EVENT_INFO_TYPE_ERROR; - info.hdr.pad = 0; info.hdr.len = FANOTIFY_ERROR_INFO_LEN; if (WARN_ON(count < info.hdr.len)) From patchwork Fri Oct 29 11:40:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34B37C433EF for ; Fri, 29 Oct 2021 11:40:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2105260F0F for ; Fri, 29 Oct 2021 11:40:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232020AbhJ2LnK (ORCPT ); Fri, 29 Oct 2021 07:43:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231994AbhJ2LnH (ORCPT ); Fri, 29 Oct 2021 07:43:07 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3069C061570 for ; Fri, 29 Oct 2021 04:40:38 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id b2-20020a1c8002000000b0032fb900951eso4154262wmd.4 for ; Fri, 29 Oct 2021 04:40:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Nh4M5doDETZWPsDs2yDOOfeG8GPsy197cicy5UH9BXs=; b=nivWkd7DctgIJf6R0o8GnDqZgqlhvnRloUtDVPmnOLjpFIuJoncm7swcnCjwLzQdpH Pavny5ZT+k8Vdo/T+ZA1jzV8i9YpiiVtwi83cPRsIBSPge4BNXWI1wjPETSQ5jw/1W2w uWiD66bmmvCFKE+DDUs+sPWTctyjGIwAoPapnJaqIMZ5fHYnyBPx/ZUiyilj0tFGe4CZ 9byYS0gHa4nGFxmU0qya6A51938LYDngjff8pnpA9Lt8a6p3H2ds4xMpbfE5xiDOVGnN aBE2pK29fyqWyXQMhk42OZUZUF7ra1Po0LuC6OMB1UZo1M4Wkw5giqwajOenJCTqCeuD 8GLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Nh4M5doDETZWPsDs2yDOOfeG8GPsy197cicy5UH9BXs=; b=sGHc/uJeGOPfbeMProCG1NR6VIlAgegALXYkdViMkut61LIg7L8HJRSOsnol1rUDOz +xs4axFxdgDoVwnU18tWZnJD+98Dh7IoRGx9xPqRloMXU8sZpHBT85hsxs9igt+8hVqd ZdxcTB2V4Rqs7lZZeVstnbIUGuYE3GoDNInmH/bQphLhrC7ZkXbawTMoAuPzmC4nGVnX mTi0R+Hjz7umfnOskBqOS5vxbQJa1KiJX0EiEtC9tdvh5bodJjO8NhNgo4rjT2vBZxWq kHiPzTtgfXE/M2o6cWBANeSNdrCg6H5wx8+yEurKf0MHelDpRcMv3h8NQRU7+91YMu31 8JSw== X-Gm-Message-State: AOAM533nQP0FKUiOaXIS4oybgpExACUwq7mKD3hUUzWrpGAxj8EVhnY7 bHCyIiNj3ALqykg0fFML3ns= X-Google-Smtp-Source: ABdhPJxZTvc3SV1/fPC5oiKnNa07Oz2SjaojRSGcsH4GaK/8d7rTBCiL7vMp02LXg0EslPZ6sK4VeA== X-Received: by 2002:a05:600c:5117:: with SMTP id o23mr10789101wms.81.1635507637315; Fri, 29 Oct 2021 04:40:37 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:36 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 5/7] fanotify: record new parent and name in MOVED_FROM event Date: Fri, 29 Oct 2021 14:40:26 +0300 Message-Id: <20211029114028.569755-6-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In the special case of MOVED_FROM event, if we are recording the child fid due to FAN_REPORT_TARGET_FID init flag, we also record the new parent and name. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.c | 40 ++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 795bedcb6f9b..d1adcb3437c5 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -592,21 +592,30 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *id, __kernel_fsid_t *fsid, const struct qstr *name, struct inode *child, + struct dentry *moved, unsigned int *hash, gfp_t gfp) { struct fanotify_name_event *fne; struct fanotify_info *info; struct fanotify_fh *dfh, *ffh; + struct inode *dir2 = moved ? d_inode(moved->d_parent) : NULL; + const struct qstr *name2 = moved ? &moved->d_name : NULL; unsigned int dir_fh_len = fanotify_encode_fh_len(id); + unsigned int dir2_fh_len = fanotify_encode_fh_len(dir2); unsigned int child_fh_len = fanotify_encode_fh_len(child); unsigned int size; size = sizeof(*fne) + FANOTIFY_FH_HDR_LEN + dir_fh_len; + if (dir2_fh_len) + size += FANOTIFY_FH_HDR_LEN + dir2_fh_len; if (child_fh_len) size += FANOTIFY_FH_HDR_LEN + child_fh_len; - if (name) + if (name) { size += name->len + 1; + if (name2) + size += name2->len + 1; + } fne = kmalloc(size, gfp); if (!fne) return NULL; @@ -618,6 +627,11 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *id, fanotify_info_init(info); dfh = fanotify_info_dir_fh(info); info->dir_fh_totlen = fanotify_encode_fh(dfh, id, dir_fh_len, hash, 0); + if (dir2_fh_len) { + dfh = fanotify_info_dir2_fh(info); + info->dir2_fh_totlen = fanotify_encode_fh(dfh, dir2, + dir2_fh_len, hash, 0); + } if (child_fh_len) { ffh = fanotify_info_file_fh(info); info->file_fh_totlen = fanotify_encode_fh(ffh, child, @@ -628,12 +642,26 @@ static struct fanotify_event *fanotify_alloc_name_event(struct inode *id, fanotify_info_copy_name(info, name); *hash ^= full_name_hash((void *)salt, name->name, name->len); + + /* name2 can only be stored after valid name1 */ + if (name2) { + salt = name2->len; + fanotify_info_copy_name2(info, name2); + *hash ^= full_name_hash((void *)salt, name2->name, + name2->len); + } } pr_debug("%s: ino=%lu size=%u dir_fh_len=%u child_fh_len=%u name_len=%u name='%.*s'\n", __func__, id->i_ino, size, dir_fh_len, child_fh_len, info->name_len, info->name_len, fanotify_info_name(info)); + if (dir2_fh_len) { + pr_debug("%s: dir2_fh_len=%u name2_len=%u name2='%.*s'\n", + __func__, dir2_fh_len, info->name2_len, + info->name2_len, fanotify_info_name2(info)); + } + return &fne->fae; } @@ -689,6 +717,7 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, struct inode *dirid = fanotify_dfid_inode(mask, data, data_type, dir); const struct path *path = fsnotify_data_path(data, data_type); struct mem_cgroup *old_memcg; + struct dentry *moved = NULL; struct inode *child = NULL; bool name_event = false; unsigned int hash = 0; @@ -699,9 +728,14 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, /* * For certain events and group flags, report the child fid * in addition to reporting the parent fid and maybe child name. + * In the special case of MOVED_FROM event, if we are reporting + * the child fid we are also reporting the new parent and name. */ - if (fanotify_report_child_fid(fid_mode, mask) && id != dirid) + if (fanotify_report_child_fid(fid_mode, mask) && id != dirid) { child = id; + if (mask & FAN_MOVED_FROM) + moved = fsnotify_data_dentry(data, data_type); + } id = dirid; @@ -747,7 +781,7 @@ static struct fanotify_event *fanotify_alloc_event(struct fsnotify_group *group, data_type, &hash); } else if (name_event && (file_name || child)) { event = fanotify_alloc_name_event(id, fsid, file_name, child, - &hash, gfp); + moved, &hash, gfp); } else if (fid_mode) { event = fanotify_alloc_fid_event(id, fsid, &hash, gfp); } else { From patchwork Fri Oct 29 11:40:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592553 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39CD2C433FE for ; Fri, 29 Oct 2021 11:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22CB760E90 for ; Fri, 29 Oct 2021 11:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232033AbhJ2LnM (ORCPT ); Fri, 29 Oct 2021 07:43:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232014AbhJ2LnI (ORCPT ); Fri, 29 Oct 2021 07:43:08 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9928C061570 for ; Fri, 29 Oct 2021 04:40:39 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id g13so329818wmg.2 for ; Fri, 29 Oct 2021 04:40:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2q8KNM34vrGnsSuHsXvSArX1nN2zm2pfj7JnKEoh3b4=; b=R2A7Q3hVN6t6+ijk2EKgKGR35VY2f49ADmZuQ0ODihNyOgiL+yTrtgIT82Mqp9kmCQ ni7X1ZZKWt8rWTZn+99GeD6EApZF+5GU0YO52RNPJ95ci8HIzrgk/dmR255qFRxBrCSc XGue13xvIBYvHZJKtllrUVKDgekAxBExsIVYSfo35ZMO6TnvjLw+COdUN68StgFqS0hU Z1wQOoN5Kq+/xAhMT18JKaRB5FA0ceKK47EvAN6R/xVF7HpVu3nayHrXGL0mKkfLZ+Fn hdcI4/pqwnAkmVotYmxZYGdHHBSNN09GLU4bQH4UgiwADvGQNL8i3xVpJu43nOAjNS/g 6u9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2q8KNM34vrGnsSuHsXvSArX1nN2zm2pfj7JnKEoh3b4=; b=VA0jLjljva62v9+ybAwj7PRMRZrzMYea6g9Nwu7QpDkFA9KirgZBdQfij+XGvx+yO6 p0FP/ifypVyxdEead5/fa4M6m85JHjo7w+KQ3fvlp+HyPSD0rwW9nU+l1gj+CZPtzlpq P2w83w87pMHCxF/6zeTHnfEDc5ekEckXBnApYpVtD/W6ZZQn+MmyfnQas9lUF5w4n/PR CxCc47U/WUKOSPboD6xt0i/yxXA8UOzTMDgHvzf7XD0gM5z5tpmFGmAWEoMUOvWAcXOz g2QZ1eHjTMewGEafkKYb5r9AD8dqIslFqHjqR8HBgGrreNBAYK5LzN+P9H9Sf+5Ur4LA ESUQ== X-Gm-Message-State: AOAM531qXX/mzHYEuH33XgOG7mSsWo7LmacIHDqs6nLTpoe05cxL+Eye ljm1kZa+/prpPnlbexqQot0= X-Google-Smtp-Source: ABdhPJxCrG3Wqv6z7Nx9uyA53Zp27zoiAhfzZ4an0jk3O+29CXZCQL0X/Fh8tFauy9PveOb5DTc1fA== X-Received: by 2002:a05:600c:1c23:: with SMTP id j35mr10643257wms.1.1635507638521; Fri, 29 Oct 2021 04:40:38 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:38 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 6/7] fanotify: report new parent and name in MOVED_FROM event Date: Fri, 29 Oct 2021 14:40:27 +0300 Message-Id: <20211029114028.569755-7-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org In the special case of MOVED_FROM event, if we are reporting the child fid due to FAN_REPORT_TARGET_FID init flag, we also report the new parent and name. The new parent and name are reported using a new info record of type FAN_EVENT_INFO_TYPE_DFID_NAME2 that follows the info record of type FAN_EVENT_INFO_TYPE_DFID_NAME with the old parent and name. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify.h | 17 +++++++++++++++++ fs/notify/fanotify/fanotify_user.c | 29 +++++++++++++++++++++++++++-- include/uapi/linux/fanotify.h | 1 + 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.h b/fs/notify/fanotify/fanotify.h index 0864e7efe23c..26d471aab054 100644 --- a/fs/notify/fanotify/fanotify.h +++ b/fs/notify/fanotify/fanotify.h @@ -339,6 +339,13 @@ static inline int fanotify_event_dir_fh_len(struct fanotify_event *event) return info ? fanotify_info_dir_fh_len(info) : 0; } +static inline int fanotify_event_dir2_fh_len(struct fanotify_event *event) +{ + struct fanotify_info *info = fanotify_event_info(event); + + return info ? fanotify_info_dir2_fh_len(info) : 0; +} + static inline bool fanotify_event_has_object_fh(struct fanotify_event *event) { /* For error events, even zeroed fh are reported. */ @@ -352,6 +359,16 @@ static inline bool fanotify_event_has_dir_fh(struct fanotify_event *event) return fanotify_event_dir_fh_len(event) > 0; } +/* For MOVED_FROM event with FAN_REPORT_TARGET_FID */ +static inline bool fanotify_event_has_two_names(struct fanotify_event *event) +{ + struct fanotify_info *info = fanotify_event_info(event); + + return info && info->name_len && info->name2_len && + fanotify_info_dir_fh_len(info) > 0 && + fanotify_info_dir2_fh_len(info) > 0; +} + struct fanotify_path_event { struct fanotify_event fae; struct path path; diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index d973f36676a9..d6420e10740d 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -134,7 +134,7 @@ static size_t fanotify_event_len(unsigned int info_mode, { size_t event_len = FAN_EVENT_METADATA_LEN; struct fanotify_info *info; - int dir_fh_len; + int dir_fh_len, dir2_fh_len; int fh_len; int dot_len = 0; @@ -149,6 +149,11 @@ static size_t fanotify_event_len(unsigned int info_mode, if (fanotify_event_has_dir_fh(event)) { dir_fh_len = fanotify_event_dir_fh_len(event); event_len += fanotify_fid_info_len(dir_fh_len, info->name_len); + if (fanotify_event_has_two_names(event)) { + dir2_fh_len = fanotify_event_dir2_fh_len(event); + event_len += fanotify_fid_info_len(dir2_fh_len, + info->name2_len); + } } else if ((info_mode & FAN_REPORT_NAME) && (event->mask & FAN_ONDIR)) { /* @@ -379,6 +384,7 @@ static int copy_fid_info_to_user(__kernel_fsid_t *fsid, struct fanotify_fh *fh, return -EFAULT; break; case FAN_EVENT_INFO_TYPE_DFID_NAME: + case FAN_EVENT_INFO_TYPE_DFID_NAME2: if (WARN_ON_ONCE(!name || !name_len)) return -EFAULT; break; @@ -478,7 +484,10 @@ static int copy_info_records_to_user(struct fanotify_event *event, unsigned int pidfd_mode = info_mode & FAN_REPORT_PIDFD; /* - * Event info records order is as follows: dir fid + name, child fid. + * Event info records order is as follows: + * 1. dir fid + name + * 2. (optional) new dir fid + new name + * 3. (optional) child fid */ if (fanotify_event_has_dir_fh(event)) { info_type = info->name_len ? FAN_EVENT_INFO_TYPE_DFID_NAME : @@ -496,6 +505,22 @@ static int copy_info_records_to_user(struct fanotify_event *event, total_bytes += ret; } + /* New dir fid + name can only be reported after old dir fid + name */ + if (info_type && fanotify_event_has_two_names(event)) { + info_type = FAN_EVENT_INFO_TYPE_DFID_NAME2; + ret = copy_fid_info_to_user(fanotify_event_fsid(event), + fanotify_info_dir2_fh(info), + info_type, + fanotify_info_name2(info), + info->name2_len, buf, count); + if (ret < 0) + return ret; + + buf += ret; + count -= ret; + total_bytes += ret; + } + if (fanotify_event_has_object_fh(event)) { const char *dot = NULL; int dot_len = 0; diff --git a/include/uapi/linux/fanotify.h b/include/uapi/linux/fanotify.h index f9202ce31b0d..1ac31a912cea 100644 --- a/include/uapi/linux/fanotify.h +++ b/include/uapi/linux/fanotify.h @@ -131,6 +131,7 @@ struct fanotify_event_metadata { #define FAN_EVENT_INFO_TYPE_DFID 3 #define FAN_EVENT_INFO_TYPE_PIDFD 4 #define FAN_EVENT_INFO_TYPE_ERROR 5 +#define FAN_EVENT_INFO_TYPE_DFID_NAME2 6 /* For FAN_MOVED_FROM */ /* Variable length info record following event metadata */ struct fanotify_event_info_header { From patchwork Fri Oct 29 11:40:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 12592551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3CBFC4332F for ; Fri, 29 Oct 2021 11:40:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B96060E90 for ; Fri, 29 Oct 2021 11:40:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231990AbhJ2LnN (ORCPT ); Fri, 29 Oct 2021 07:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232019AbhJ2LnK (ORCPT ); Fri, 29 Oct 2021 07:43:10 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0358FC061714 for ; Fri, 29 Oct 2021 04:40:41 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id u18so15757737wrg.5 for ; Fri, 29 Oct 2021 04:40:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JiVsObHOj86M/JRQXD1Lj2K+Z/yh5CnYWlRs5cfCeEM=; b=jK3y+ZTIdMGaUqjiHib4BCiPOEcRvebSCTLyyd85Kd927HGgi/Muj2C7qUKNR2321j o5VlIZG7EUbC1D5t5UrVzap6nJItVklfVxvRXBwilrwax0nW/jVRvDMpO1PmSDRO2vBd caAfw8hciGHGWQIfn3TuLLlh97+g4tgBdQijCRxGvOJAxtzEqKjIoGLCJYvRP6ybBjNJ VX+CEy1+LfkqA0EvC76lRfp+DgVX8HXxdEwj82EmibBpNXuKWeG4hmvWdGXiMQCfU05M Y61A1zcWk6eeig7h/eO8nzUrvRygJmYssBKmf9vSY4sIjsvrM5+hMPo8XH+F7vy9J6yt TgJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JiVsObHOj86M/JRQXD1Lj2K+Z/yh5CnYWlRs5cfCeEM=; b=mz3K4Mt9wI5HaBQtZLEVIdTbmqloI4+Xg/mU2RtCQGCYGdAZ6gFA+7I0Kfr0w4UZ8C G9Jpotlg4xIOQxzwsvie5+EAzaYSBsPjn+EvdHt1qxojkevyXdGSUNLCU41BBN7gjWLu 2SYrCjCothwVr18nKjo6JtrkGJ11xa/fD9ERJ/lOpSSPcNkk/3d2zWe36ipPxIdLLpe8 XDlHNLnliexvpFqkDosDpkefnaZYcR2YgEb8af0frXL08AeYMsa5BgFH3zyD5UkIOLZu mJIiFZf4fanK9Atw7T1W8CbkGzY5v/mI8bwJQeEbSVYaVA7vrIDvh8bE7h4qC3ebV4F3 3bcA== X-Gm-Message-State: AOAM530BKL72e10ayAAfpCnFZyfKtc+v7x8JKAHli6vWRZEbvT/Hors0 ejRfTqill244ZyJ/lelXj+5UI1n8uzM= X-Google-Smtp-Source: ABdhPJxaUxTaA3fl8KHpp9TmhQClCvPYHEPkYuAKkVM4ZIfh/5XHR04vorPGGeRatoHR21WUERhHTQ== X-Received: by 2002:adf:fb04:: with SMTP id c4mr13342099wrr.39.1635507639651; Fri, 29 Oct 2021 04:40:39 -0700 (PDT) Received: from localhost.localdomain ([82.114.46.186]) by smtp.gmail.com with ESMTPSA id t3sm8178643wma.38.2021.10.29.04.40.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 04:40:39 -0700 (PDT) From: Amir Goldstein To: Jan Kara Cc: Matthew Bobrowski , linux-fsdevel@vger.kernel.org Subject: [PATCH 7/7] fanotify: enable the FAN_REPORT_TARGET_FID flag Date: Fri, 29 Oct 2021 14:40:28 +0300 Message-Id: <20211029114028.569755-8-amir73il@gmail.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211029114028.569755-1-amir73il@gmail.com> References: <20211029114028.569755-1-amir73il@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org That will result in reporting of self inode fid in dirent events and destination dir+name in MOVED_FROM event. Signed-off-by: Amir Goldstein --- fs/notify/fanotify/fanotify_user.c | 2 +- include/linux/fanotify.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index d6420e10740d..b62218d4aea2 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1700,7 +1700,7 @@ static int __init fanotify_user_setup(void) FANOTIFY_DEFAULT_MAX_USER_MARKS); BUILD_BUG_ON(FANOTIFY_INIT_FLAGS & FANOTIFY_INTERNAL_GROUP_FLAGS); - BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 11); + BUILD_BUG_ON(HWEIGHT32(FANOTIFY_INIT_FLAGS) != 12); BUILD_BUG_ON(HWEIGHT32(FANOTIFY_MARK_FLAGS) != 9); fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index 616af2ea20f3..25c1894510a0 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -25,7 +25,7 @@ extern struct ctl_table fanotify_table[]; /* for sysctl */ #define FANOTIFY_CLASS_BITS (FAN_CLASS_NOTIF | FANOTIFY_PERM_CLASSES) -#define FANOTIFY_FID_BITS (FAN_REPORT_FID | FAN_REPORT_DFID_NAME) +#define FANOTIFY_FID_BITS (FAN_REPORT_ALL_FIDS | FAN_REPORT_NAME) #define FANOTIFY_INFO_MODES (FANOTIFY_FID_BITS | FAN_REPORT_PIDFD)