fanotify: Taint on use of FANOTIFY_ACCESS_PERMISSIONS
authorBen Hutchings <ben@decadent.org.uk>
Wed, 13 Jul 2016 00:37:22 +0000 (01:37 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 28 May 2021 08:31:38 +0000 (09:31 +0100)
Forwarded: not-needed

Various free and proprietary AV products use this feature and users
apparently want it.  But punting access checks to userland seems like
an easy way to deadlock the system, and there will be nothing we can
do about that.  So warn and taint the kernel if this feature is
actually used.

Gbp-Pq: Topic debian
Gbp-Pq: Name fanotify-taint-on-use-of-fanotify_access_permissions.patch

fs/notify/fanotify/fanotify_user.c

index dcab112e1f0012073456c56b52b1ce4ac261d9a4..aec6b2e21eee0590f0f82a14b897e631a4ce5e8e 100644 (file)
@@ -1170,6 +1170,14 @@ static int do_fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
        if (ignored)
                mask &= ~FANOTIFY_EVENT_FLAGS;
 
+#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
+       if (mask & FANOTIFY_PERM_EVENTS) {
+               pr_warn_once("%s (%d): Using fanotify permission checks may lead to deadlock; tainting kernel\n",
+                            current->comm, current->pid);
+               add_taint(TAINT_AUX, LOCKDEP_STILL_OK);
+       }
+#endif
+
        f = fdget(fanotify_fd);
        if (unlikely(!f.file))
                return -EBADF;