Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp208662pxt; Wed, 4 Aug 2021 09:09:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxC9iO77OiLy94vTN6P9IG5eFrBd2QTsEUYYuYKHQ+E9oAo9jfULXWKhtDmCSUMB9E8Vue6 X-Received: by 2002:a05:6e02:143:: with SMTP id j3mr333194ilr.62.1628093341716; Wed, 04 Aug 2021 09:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628093341; cv=none; d=google.com; s=arc-20160816; b=e9/qkgVSiMpfCLbGRsKeHA2eVONhaRJo64SFZ1qcrhvUiw8td70Hlz+5sdZPv/rOvE PU5SipXUfOcdiM9t4k1cpTqX4cex1GiLsgs1GhyhMkMfVrOBh9WyqXtPP0Lueu/39jjM RP8+5hVVzlVu9rF9URq0tNJCi9K6/JPG9qoE3OZnTnsjvA2dpFYR5mhblnhm7d/N+YUV aRuTMRvG97OR78Cpy8yT0DdrtK9+j2vXo0ibjFuaLuW/l8c10jRca5TiWP49SMwOLb+E X2szkpkObpnDnITGLUQkqd1OvvjIjWrDegE+WBQQu2SW6tioewA8gV/oLaeUNSQVlldz 8+EQ== 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=gK4LxaaJZ9RIfOzfjlI4JEUt6NiN83dlLbRb+oUxO0k=; b=TgGj1zVl3WT60+A2LUeECsRguJVU7XHxUJQCVAD12HURPqRCsA6uOt/tMHJS3oc6/d LCXTJWrKBR72nemf33PMppg6W2YWrsdOVAO9ye2nMw5WFN5iqPLSuPpnMEwi6QRJ8wto ICgkTTquKymfHzTcv8sYHxlAqB5UJLOh9x6X0BGcPcvO61V3tUX+TVWa8rg8ML7l7UeA bt0chq2IdXlAm9BUIVQvLu5mxlK/FfNEMycEJzLCDCAPIpWcMXretlKAnWEls80ModV4 oBEvMaMxvXe4VM5Vt6BMLtKrJ9o/xFGCOFeGiLnSEsqfpjvLl+3zFXI1Dmo19lshgTuR bBlQ== 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 d24si2517702iob.3.2021.08.04.09.08.45; Wed, 04 Aug 2021 09:09:01 -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 S232814AbhHDQHu (ORCPT + 99 others); Wed, 4 Aug 2021 12:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232614AbhHDQHr (ORCPT ); Wed, 4 Aug 2021 12:07:47 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A4C6C0613D5; Wed, 4 Aug 2021 09:07:35 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 1DD2F1F4080F From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, david@fromorbit.com, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v5 15/23] fanotify: Require fid_mode for any non-fd event Date: Wed, 4 Aug 2021 12:06:04 -0400 Message-Id: <20210804160612.3575505-16-krisman@collabora.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210804160612.3575505-1-krisman@collabora.com> References: <20210804160612.3575505-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 Signed-off-by: Gabriel Krisman Bertazi --- changes since v5: - Fix condition to include FANOTIFY_EVENT_FLAGS. (me) --- fs/notify/fanotify/fanotify_user.c | 14 +++++++------- include/linux/fanotify.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 0696f2121781..6dad2a00e337 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1382,14 +1382,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