]> www.infradead.org Git - users/hch/block.git/commitdiff
watch_queue: Add security hooks to rule on setting mount watches
authorDavid Howells <dhowells@redhat.com>
Mon, 24 Jun 2019 14:27:50 +0000 (15:27 +0100)
committerDavid Howells <dhowells@redhat.com>
Mon, 27 Jul 2020 20:47:09 +0000 (21:47 +0100)
Add a security hook that will allow an LSM to rule on whether or not a
watch may be set on a mount.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: James Morris <jamorris@linux.microsoft.com>
cc: Casey Schaufler <casey@schaufler-ca.com>
cc: Stephen Smalley <sds@tycho.nsa.gov>
cc: linux-security-module@vger.kernel.org

include/linux/lsm_hook_defs.h
include/linux/lsm_hooks.h
include/linux/security.h
security/security.c

index af998f93d256073e03e8adef0fc3d69a8cc9ecd8..f6eaf8bd617b20d1ec9a78b2677e29fafef67f89 100644 (file)
@@ -264,6 +264,9 @@ LSM_HOOK(int, 0, post_notification, const struct cred *w_cred,
 #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
 LSM_HOOK(int, 0, watch_key, struct key *key)
 #endif /* CONFIG_SECURITY && CONFIG_KEY_NOTIFICATIONS */
+#ifdef CONFIG_MOUNT_NOTIFICATIONS
+LSM_HOOK(int, 0, watch_mount, struct watch *watch, struct path *path)
+#endif
 
 #ifdef CONFIG_SECURITY_NETWORK
 LSM_HOOK(int, 0, unix_stream_connect, struct sock *sock, struct sock *other,
index 95b7c1d320621824a4b4f8c73edc5718a0c89c8d..56275145b91d60ec1d025107fa690b9d0aca1a31 100644 (file)
  *     from a key or keyring.
  *     @key: The key to watch.
  *
+ * @watch_mount:
+ *     Check to see if a process is allowed to watch for mount topology change
+ *     notifications on a mount subtree.
+ *     @watch: The watch object
+ *     @path: The root of the subtree to watch.
+ *
  * Security hooks for using the eBPF maps and programs functionalities through
  * eBPF syscalls.
  *
index 0a0a03b36a3bb178c5ff62cfd96cc7973c4412cb..318fdfe7f4d69491c0ec450b55b8a3e2e0242f6a 100644 (file)
@@ -1314,6 +1314,14 @@ static inline int security_watch_key(struct key *key)
        return 0;
 }
 #endif
+#if defined(CONFIG_SECURITY) && defined(CONFIG_MOUNT_NOTIFICATIONS)
+int security_watch_mount(struct watch *watch, struct path *path);
+#else
+static inline int security_watch_mount(struct watch *watch, struct path *path)
+{
+       return 0;
+}
+#endif
 
 #ifdef CONFIG_SECURITY_NETWORK
 
index 70a7ad357bc6ab35aa4c7b6f7616222a8b88c805..3cdf5039f727619a39ac7dd285e65edbed8f2d10 100644 (file)
@@ -2067,6 +2067,13 @@ int security_watch_key(struct key *key)
 }
 #endif
 
+#ifdef CONFIG_MOUNT_NOTIFICATIONS
+int security_watch_mount(struct watch *watch, struct path *path)
+{
+       return call_int_hook(watch_mount, 0, watch, path);
+}
+#endif
+
 #ifdef CONFIG_SECURITY_NETWORK
 
 int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk)