Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp5106731pxb; Thu, 14 Oct 2021 19:37:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzB5k/mJUBppVZdYM97I1/LX+0ZKGjeWvEUKm4/dHzW2guc/hw+nRhV3wGAzY457xuNMzm3 X-Received: by 2002:aa7:ca0d:: with SMTP id y13mr13804214eds.335.1634265477237; Thu, 14 Oct 2021 19:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634265477; cv=none; d=google.com; s=arc-20160816; b=yoFoxCG8/WqMjUi1a0AavVByQ6x4E+rqShDAL19O8Y8br0R0iAPM0SALzk1YqEVsnZ DDsyJHRvIvtaPJgIksKAA+yTXktYhK2nybHeXpuCBGe+/jN4UihvGQo/179VBjeJyWzE E5+oj9SRfNIn5gcPfVp8cbj06CpUOs1TpRFtO/1lEJwX7hY8CATE7mu7JddWThti/bYP /PxgL/kr0Y2iC64tE3fMtDPuKttvTj3ewWI+0xD02HmgozcmRwj35YGiOcU4dEWTxO4f MlTu8KESIKpnlTIBKi3Yh9XlMywxeB9mGe1hmIrW2uFQehDKbqjvWL12yoqDjaD0/5q2 uOwQ== 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=Vs+BNah3vDT2+cpB5IzoNaH/FoibDKVp1L+6IhfODUA=; b=Kkmr7l3QpSW4RjihrlVzv5yYh7PWd0faJLYgXPlo/NMRmBp5lZkc/inFYsQNtfLXBy pDnnhYayVVi8CRK5x+Z6+lZW79ESPCmZfJUo2zWhGN5iEnxKZ0V8JMoru6RCc3jLuuRp ZbPsaegE+ilLoPG0/VcQ7Wnr/cW7baoRoRTSLh94UwCrbU+3W7lV0EgUeTK0xbD3nhia rEFodXtZdGHMWuD2JWhmIf9O8YRE2W6a12WkXEv5hOreozPw1S0hb3rNQdOyQi2yxsCN tWbfBPLEJ+f/kJFu2fOa8unVYh+iBSPsDUtx6Qs6ncBgQlFxGHuIfFw54sqFg4G5y7Ow 6ROg== 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 y89si6027705ede.267.2021.10.14.19.37.20; Thu, 14 Oct 2021 19:37:57 -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 S233712AbhJNVmB (ORCPT + 99 others); Thu, 14 Oct 2021 17:42:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230422AbhJNVmB (ORCPT ); Thu, 14 Oct 2021 17:42:01 -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 36439C061570; Thu, 14 Oct 2021 14:39:56 -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 72A9D1F415A6; Thu, 14 Oct 2021 22:39:54 +0100 (BST) From: Gabriel Krisman Bertazi To: jack@suse.com, amir73il@gmail.com Cc: djwong@kernel.org, tytso@mit.edu, dhowells@redhat.com, khazhy@google.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-api@vger.kernel.org, repnop@google.com, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH v7 25/28] fanotify: Allow users to request FAN_FS_ERROR events Date: Thu, 14 Oct 2021 18:36:43 -0300 Message-Id: <20211014213646.1139469-26-krisman@collabora.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211014213646.1139469-1-krisman@collabora.com> References: <20211014213646.1139469-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Wire up the FAN_FS_ERROR event in the fanotify_mark syscall, allowing user space to request the monitoring of FAN_FS_ERROR events. These events are limited to filesystem marks, so check it is the case in the syscall handler. Signed-off-by: Gabriel Krisman Bertazi --- fs/notify/fanotify/fanotify.c | 2 +- fs/notify/fanotify/fanotify_user.c | 5 +++++ include/linux/fanotify.h | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index 47e28f418711..d449a23d603f 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -827,7 +827,7 @@ static int fanotify_handle_event(struct fsnotify_group *group, u32 mask, BUILD_BUG_ON(FAN_OPEN_EXEC_PERM != FS_OPEN_EXEC_PERM); BUILD_BUG_ON(FAN_FS_ERROR != FS_ERROR); - BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 19); + BUILD_BUG_ON(HWEIGHT32(ALL_FANOTIFY_EVENT_BITS) != 20); mask = fanotify_group_event_mask(group, iter_info, mask, data, data_type, dir); diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 8f7c2f4ce674..5edfd7e3f356 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -1585,6 +1585,11 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask, fsid = &__fsid; } + if (mask & FAN_FS_ERROR && mark_type != FAN_MARK_FILESYSTEM) { + ret = -EINVAL; + goto path_put_and_out; + } + /* inode held in place by reference to path; group by fget on fd */ if (mark_type == FAN_MARK_INODE) inode = path.dentry->d_inode; diff --git a/include/linux/fanotify.h b/include/linux/fanotify.h index 52d464802d99..616af2ea20f3 100644 --- a/include/linux/fanotify.h +++ b/include/linux/fanotify.h @@ -91,9 +91,13 @@ extern struct ctl_table fanotify_table[]; /* for sysctl */ #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \ FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF) +/* Events that can only be reported with data type FSNOTIFY_EVENT_ERROR */ +#define FANOTIFY_ERROR_EVENTS (FAN_FS_ERROR) + /* Events that user can request to be notified on */ #define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \ - FANOTIFY_INODE_EVENTS) + FANOTIFY_INODE_EVENTS | \ + FANOTIFY_ERROR_EVENTS) /* Events that require a permission response from user */ #define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \ -- 2.33.0