Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3502388pxb; Mon, 18 Oct 2021 17:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxGanMe3l4m2o7VqHuVgqJ9S+30+wEuByc2EqFjA3BbOxFMTOAIJgmTsdxmriUBHwguXAq X-Received: by 2002:a05:6402:1cc1:: with SMTP id ds1mr10160406edb.386.1634601831494; Mon, 18 Oct 2021 17:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634601831; cv=none; d=google.com; s=arc-20160816; b=YzZvQ3K6JK5Dlnowla4pg+Fbfq8QdeGsLdi5L76fcvThLVaUlVQOQsVHPbkWrAT/Cf 9Tx58zRdfGAmao921hya5q8LNjEqBn0L9SDrrS/Fl/IIxcY9TP1Uh9roRr6eG7AMrJxF pBfVXso2Q94/E8UlA4OyBU5xOz+/GHtaUpEKLS0D3yZ1ciidXLtR17DETejdv6FuBRNd F2JWHWsBUxFJ0jT1pS1b2EjqwDoEICaXS9Zyi6uaGR7ClMlpbF90D5HtQRMxTxZeQExY jKun2XHr5fdyAkFhvnscEz9hLhcIlp2T8/9FTznSs8rBRe2Sua0jxbqUaRulyzntGD5V Shmw== 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=9UZWoenyto2DZuP5wf03039c2IwpTJRZMsb5x1tYoQY=; b=FpZVRC4SvHQQ+w58OMkVQrd7K8HTJOjvDruHhf70SAcRVucqY2Db7GsEzdzHDLzuXM h2/pEfx/Ixc7jwNoqQxNI3XMtv4AMiCsViZ3EW3yJCN4CUlSB7tBaBHko3VvaHM9KGqo o+y/fLwUf+m18K+mGpE2VTBsotkVbmuX76fsG0N0FXy9SXqDGR9RVoFXh5WGzCFhGZNA IkyeWsRNpT9/rjaZjnyixM9k4CoSXU/x90RgpT9Ddl2XWj7ZFbMe5issBWPezaaCox3r h02vWIFstL4T7IcGqGU9YM4OURFUv5mjdcmuidNSQbYTucSWp9GzkbidkbKQYacxDUsg +NTw== 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 b17si5870646edd.9.2021.10.18.17.03.28; Mon, 18 Oct 2021 17:03:51 -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 S233969AbhJSAEr (ORCPT + 99 others); Mon, 18 Oct 2021 20:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233931AbhJSAEr (ORCPT ); Mon, 18 Oct 2021 20:04: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 3186DC06161C; Mon, 18 Oct 2021 17:02:35 -0700 (PDT) Received: from localhost (unknown [IPv6:2804:14c:124:8a08::1007]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: krisman) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 73E3C1F411B7; Tue, 19 Oct 2021 01:02:28 +0100 (BST) 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, Jan Kara Subject: [PATCH v8 16/32] fanotify: Require fid_mode for any non-fd event Date: Mon, 18 Oct 2021 20:59:59 -0300 Message-Id: <20211019000015.1666608-17-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211019000015.1666608-1-krisman@collabora.com> References: <20211019000015.1666608-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 Reviewed-by: Amir Goldstein 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 adeae6d65e35..66ee3c2805c7 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1458,14 +1458,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 eec3b7c40811..52d464802d99 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -84,6 +84,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.33.0