Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp263959pxb; Thu, 12 Aug 2021 16:03:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbxajYQrT0Y9q7gB3LhpKqvFOxjoaAB4UxTzyQpynpKTQCBhMTs7r0W4wJbvE5NRhsa9lM X-Received: by 2002:a17:906:ed1:: with SMTP id u17mr5797527eji.304.1628809429302; Thu, 12 Aug 2021 16:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628809429; cv=none; d=google.com; s=arc-20160816; b=qHIOkAmQ488Lq6Pb0Qeopy3ea6P9YR6uI231V9TE02/hAcu/0nMvGmCKhI64c07xtn 432h9C8Dmk+QeVyCqkUyPqmGBj+ZCMRqSOobHw1o8+kQER2MJ6U+yq3ttktZE0NKZzUA oSlnKF9dpXwP6ElcuEVckuOeqm8TY4+ZHEjD4pZbR5Oxy4arI/BZtmAuloQ9/dhxwhXZ 9SeDlCmWx74gw5U1y/dq4qCKZDxiARE6/rUC+Zc5Exxs/NFl6NNcoIRv+iA17zM+j845 hSJ0vKrVooy+g+hlJGTxOzTBv5r7HaheqJPqEiVyPD75ZnbYcpeDjzTByuc66styzGsI fUcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cnLd1eDhlkIb4xhbpUzkEmHz85MTYJq6m5WVI75WnXY=; b=L7vPaBholUFEdQATenA+AoQnnUDTHJqvMMveNDAqN+Ea0OVjCU1NHyASdv4JCqDXsT Sc6sjyc9IgZMHyriWLwwWiz9LkjJqyDKLoeqXp+tI3twsOoinbytoqn5S+YLhIqSLu/J 0u4n6h6S6TNNNDaQ1EOslF37yRO1e2Leje9VKTGnJiGF51hcj4cngf3G1caGdKw8gRqy FzcgOXL5UJoGXMqVArwIPo1PZe4IEuHKIIX2f8q2Wix21qH1gqiEFhIMkGkBfmn/4QEb YnBqMuQPXK2iz2yoYYVkIY97zJl/H9S5JYCZjXg9pgatqK+rP1RkXOTfNL/9B3N01M6C oNrQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp6si3802963ejc.477.2021.08.12.16.03.24; Thu, 12 Aug 2021 16:03:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237996AbhHLVlp (ORCPT + 99 others); Thu, 12 Aug 2021 17:41:45 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:45842 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbhHLVlp (ORCPT ); Thu, 12 Aug 2021 17:41:45 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 3C0221F41890 From: Gabriel Krisman Bertazi To: amir73il@gmail.com, jack@suse.com Cc: linux-api@vger.kernel.org, linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, khazhy@google.com, dhowells@redhat.com, david@fromorbit.com, tytso@mit.edu, djwong@kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com, Jan Kara Subject: [PATCH v6 13/21] fanotify: Require fid_mode for any non-fd event Date: Thu, 12 Aug 2021 17:40:02 -0400 Message-Id: <20210812214010.3197279-14-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210812214010.3197279-1-krisman@collabora.com> References: <20210812214010.3197279-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Like inode events, FAN_FS_ERROR will require fid mode. Therefore, convert the verification during fanotify_mark(2) to require fid for any non-fd event. This means fid_mode will not only be required for inode events, but for any event that doesn't provide a descriptor. Suggested-by: Amir Goldstein Reviewed-by: Jan Kara Signed-off-by: Gabriel Krisman Bertazi --- changes since v5: - Fix condition to include FANOTIFY_EVENT_FLAGS. (me) - Fix comment identation (jan) --- fs/notify/fanotify/fanotify_user.c | 12 ++++++------ include/linux/fanotify.h | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 4cacea5fcaca..54107f1533d5 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1387,14 +1387,14 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, goto fput_and_out; /* - * Events with data type inode do not carry enough information to report - * event->fd, so we do not allow setting a mask for inode events unless - * group supports reporting fid. - * inode events are not supported on a mount mark, because they do not - * carry enough information (i.e. path) to be filtered by mount point. + * Events that do not carry enough information to report + * event->fd require a group that supports reporting fid. Those + * events are not supported on a mount mark, because they do not + * carry enough information (i.e. path) to be filtered by mount + * point. */ fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); - if (mask & FANOTIFY_INODE_EVENTS && + if (mask & ~(FANOTIFY_FD_EVENTS|FANOTIFY_EVENT_FLAGS) && (!fid_mode || mark_type == FAN_MARK_MOUNT)) goto fput_and_out; diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index a16dbeced152..c05d45bde8b8 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -81,6 +81,9 @@ extern struct ctl_table fanotify_table[]; /* for sysctl */ */ #define FANOTIFY_DIRENT_EVENTS (FAN_MOVE | FAN_CREATE | FAN_DELETE) +/* Events that can be reported with event->fd */ +#define FANOTIFY_FD_EVENTS (FANOTIFY_PATH_EVENTS | FANOTIFY_PERM_EVENTS) + /* Events that can only be reported with data type FSNOTIFY_EVENT_INODE */ #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \ FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF) -- 2.32.0