Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2537045imu; Thu, 29 Nov 2018 06:33:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/Wn9hdJwZvPt4YSeKSlmsJk+NAl929b7Kb6G0Ohbk5wehrZblfrtgw7xzna6T6uiksq3tIl X-Received: by 2002:a63:9402:: with SMTP id m2mr1380013pge.93.1543502032045; Thu, 29 Nov 2018 06:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502032; cv=none; d=google.com; s=arc-20160816; b=E2v5CYii6Qerz7qszErNYMDjxSMyTC3A00t4haPwlsjReQPVyaz3IA43hVbLST866+ 37JwuTJIIdvDW0YPYHyDpt41blpAzYhGhZSHS/WH4voVVF9krMt51DsdLvHOrc/HCrq6 zLgT+HHwdmXd6A/WNsTvMAPeR3dl5nEmCftnvUJKeNDIOFezxxrweNVijSpZSu1gfGGq MB8YBob6nrFc9WBHaBkEyI2R306DPRAfKQM18H5OIsi666GPUHuH5InIqXyz1TkFPGXT jtdUvJsOVIeI3ZGORN94Qr3/viCv349Eq+E6jC3dEH5jky+mk/lgGctIZWqiMiVctS5/ qdBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DCvfvNz+VMCqhQdZxAptP1IC3nVcfY8Tk9lSVna775s=; b=QWotRW2Lp7fy7R/eDJmzE9XhzMjvwKSrUvuRrbYzuTNTqw3+3j+a5tpjUQr/+CFvPU hMwdeWV8A+wI1vaV4Q9hWge8spPa+rWlkDSXlah2zsyOCHpsviTqbBg2blr+4Yy7JpWc 7uk9IhVgsJ6i2hwlrNnR8wfghl4sQ+vd//oy5shDkODOVtvnrakKL6C+M+A7s7eXD6AQ O0ZQbyLqPOsqIMOv/kKpi2rvF7W4ZkGZKieL97xP+loU/Pft6ksnDUQdlplErFDfpdAj Jjw8HyXmQlB8MW2Z1xdSSVw7KdYxtpLzbu1rEoslWhDEH6o+IecKNMCmxj6bqL1u0IhN UOXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z3YjCSr5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q24si2470321pls.325.2018.11.29.06.33.36; Thu, 29 Nov 2018 06:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=z3YjCSr5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389335AbeK3Bhh (ORCPT + 99 others); Thu, 29 Nov 2018 20:37:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:40646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732374AbeK3Bhg (ORCPT ); Thu, 29 Nov 2018 20:37:36 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C55F4213A2; Thu, 29 Nov 2018 14:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543501923; bh=Rg8vS4vubc6PUEg2Sd0sAGZrvdMFA3au/UrElaoB9t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z3YjCSr5BQ/c357EKJ/Mq5LFtDFIGuL2DMCZqY2r/WxH1pJlET7JLvcygtCj+Zzxk QOc4lRmSV037trZRFk/3YsamR/jQBwsCWTE1IDzX9ly3cEYR9nrJ85xP1HGfaVHt53 J2diZB3ao7XWYrX7UmsJel+D8KAwQq6F7/qXVv30= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Amir Goldstein , Jan Kara Subject: [PATCH 4.19 063/110] fsnotify: generalize handling of extra event flags Date: Thu, 29 Nov 2018 15:12:34 +0100 Message-Id: <20181129135923.798155157@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181129135921.231283053@linuxfoundation.org> References: <20181129135921.231283053@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Amir Goldstein commit 007d1e8395eaa59b0e7ad9eb2b53a40859446a88 upstream. FS_EVENT_ON_CHILD gets a special treatment in fsnotify() because it is not a flag specifying an event type, but rather an extra flags that may be reported along with another event and control the handling of the event by the backend. FS_ISDIR is also an "extra flag" and not an "event type" and therefore desrves the same treatment. With inotify/dnotify backends it was never possible to set FS_ISDIR in mark masks, so it did not matter. With fanotify backend, mark adding code jumps through hoops to avoid setting the FS_ISDIR in the commulative object mask. Separate the constant ALL_FSNOTIFY_EVENTS to ALL_FSNOTIFY_FLAGS and ALL_FSNOTIFY_EVENTS, so the latter can be used to test for specific event types. Signed-off-by: Amir Goldstein Signed-off-by: Jan Kara Signed-off-by: Greg Kroah-Hartman --- fs/notify/fsnotify.c | 7 +++---- include/linux/fsnotify_backend.h | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) --- a/fs/notify/fsnotify.c +++ b/fs/notify/fsnotify.c @@ -193,7 +193,7 @@ static int send_to_group(struct inode *t struct fsnotify_iter_info *iter_info) { struct fsnotify_group *group = NULL; - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); __u32 marks_mask = 0; __u32 marks_ignored_mask = 0; struct fsnotify_mark *mark; @@ -324,8 +324,7 @@ int fsnotify(struct inode *to_tell, __u3 struct fsnotify_iter_info iter_info = {}; struct mount *mnt; int ret = 0; - /* global tests shouldn't care about events on child only the specific event */ - __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD); + __u32 test_mask = (mask & ALL_FSNOTIFY_EVENTS); if (data_is == FSNOTIFY_EVENT_PATH) mnt = real_mount(((const struct path *)data)->mnt); @@ -389,7 +388,7 @@ static __init int fsnotify_init(void) { int ret; - BUG_ON(hweight32(ALL_FSNOTIFY_EVENTS) != 23); + BUG_ON(hweight32(ALL_FSNOTIFY_BITS) != 23); ret = init_srcu_struct(&fsnotify_mark_srcu); if (ret) --- a/include/linux/fsnotify_backend.h +++ b/include/linux/fsnotify_backend.h @@ -68,15 +68,20 @@ #define ALL_FSNOTIFY_PERM_EVENTS (FS_OPEN_PERM | FS_ACCESS_PERM) +/* Events that can be reported to backends */ #define ALL_FSNOTIFY_EVENTS (FS_ACCESS | FS_MODIFY | FS_ATTRIB | \ FS_CLOSE_WRITE | FS_CLOSE_NOWRITE | FS_OPEN | \ FS_MOVED_FROM | FS_MOVED_TO | FS_CREATE | \ FS_DELETE | FS_DELETE_SELF | FS_MOVE_SELF | \ FS_UNMOUNT | FS_Q_OVERFLOW | FS_IN_IGNORED | \ - FS_OPEN_PERM | FS_ACCESS_PERM | FS_EXCL_UNLINK | \ - FS_ISDIR | FS_IN_ONESHOT | FS_DN_RENAME | \ + FS_OPEN_PERM | FS_ACCESS_PERM | FS_DN_RENAME) + +/* Extra flags that may be reported with event or control handling of events */ +#define ALL_FSNOTIFY_FLAGS (FS_EXCL_UNLINK | FS_ISDIR | FS_IN_ONESHOT | \ FS_DN_MULTISHOT | FS_EVENT_ON_CHILD) +#define ALL_FSNOTIFY_BITS (ALL_FSNOTIFY_EVENTS | ALL_FSNOTIFY_FLAGS) + struct fsnotify_group; struct fsnotify_event; struct fsnotify_mark;