From: Ben Hutchings Date: Wed, 13 Jul 2016 00:37:22 +0000 (+0100) Subject: fanotify: Taint on use of FANOTIFY_ACCESS_PERMISSIONS X-Git-Tag: archive/raspbian/4.9.82-1+deb9u3+rpi1_jessie~8^2~104 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=b593bccf0a323a3725240fe75fd9da72bd9d5fe4;p=linux-4.9.git fanotify: Taint on use of FANOTIFY_ACCESS_PERMISSIONS 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 --- diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 258e8f635148..d9ecaf8ee69f 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -868,6 +868,14 @@ SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags, #endif return -EINVAL; +#ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS + if (mask & FAN_ALL_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_USER, LOCKDEP_STILL_OK); + } +#endif + f = fdget(fanotify_fd); if (unlikely(!f.file)) return -EBADF;