lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 03 Aug 2020 14:37:42 +0100
From:   David Howells <dhowells@...hat.com>
To:     viro@...iv.linux.org.uk
Cc:     dhowells@...hat.com, torvalds@...ux-foundation.org,
        raven@...maw.net, mszeredi@...hat.com, christian@...uner.io,
        jannh@...gle.com, darrick.wong@...cle.com, kzak@...hat.com,
        jlayton@...hat.com, linux-api@...r.kernel.org,
        linux-fsdevel@...r.kernel.org,
        linux-security-module@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 09/18] watch_queue: Mount event counters [ver #21]

Add three event counters to each mount object:

 (1) mnt_topology_changes.

     Counts the number of changes to the mount tree topology, including
     addition of new mount objects, removal of mount objects and mount
     objects being moved about.

 (2) mnt_attr_changes.

     Counts the number of changes to a mount object's attributes, such as
     whether or not the device files it contains are interpretable as such.

 (3) mnt_subtree_notifications.

     Counts the number of events within the mount subtree at this point.

Signed-off-by: David Howells <dhowells@...hat.com>
---

 fs/mount.h        |    3 +++
 fs/mount_notify.c |    4 ++++
 2 files changed, 7 insertions(+)

diff --git a/fs/mount.h b/fs/mount.h
index 1037781be055..9758a9fa8f69 100644
--- a/fs/mount.h
+++ b/fs/mount.h
@@ -83,6 +83,9 @@ struct mount {
 	u64	mnt_unique_id;		/* ID unique over lifetime of kernel */
 #endif
 #ifdef CONFIG_MOUNT_NOTIFICATIONS
+	atomic_long_t mnt_topology_changes;	/* Number of topology changes applied */
+	atomic_long_t mnt_attr_changes;		/* Number of attribute changes applied */
+	atomic_long_t mnt_subtree_notifications; /* Number of notifications in subtree */
 	struct watch_list *mnt_watchers; /* Watches on dentries within this mount */
 #endif
 } __randomize_layout;
diff --git a/fs/mount_notify.c b/fs/mount_notify.c
index d8ba66ed5f77..57eebae51cb1 100644
--- a/fs/mount_notify.c
+++ b/fs/mount_notify.c
@@ -61,6 +61,7 @@ static void post_mount_notification(struct mount *changed,
 			cursor.dentry = READ_ONCE(mnt->mnt_mountpoint);
 			mnt = parent;
 			cursor.mnt = &mnt->mnt;
+			atomic_long_inc(&mnt->mnt_subtree_notifications);
 		} else {
 			cursor.dentry = cursor.dentry->d_parent;
 		}
@@ -96,6 +97,7 @@ void notify_mount(struct mount *trigger,
 	case NOTIFY_MOUNT_EXPIRY:
 	case NOTIFY_MOUNT_READONLY:
 	case NOTIFY_MOUNT_SETATTR:
+		atomic_long_inc(&trigger->mnt_attr_changes);
 		break;
 
 	case NOTIFY_MOUNT_NEW_MOUNT:
@@ -103,6 +105,8 @@ void notify_mount(struct mount *trigger,
 	case NOTIFY_MOUNT_MOVE_FROM:
 	case NOTIFY_MOUNT_MOVE_TO:
 		n.auxiliary_mount = aux->mnt_unique_id;
+		atomic_long_inc(&trigger->mnt_topology_changes);
+		atomic_long_inc(&aux->mnt_topology_changes);
 		break;
 
 	default:


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ