b/fs/notify/fanotify/fanotify_user.c
@@ -295,6 +295,17 @@ static ssize_t fanotify_read(struct file *file,
char __user *buf,
}
ret = copy_event_to_user(group, kevent, buf);
+ if (unlikely(ret == -EOPENSTALE)) {
+ /*
+ * We cannot report events with stale fd so drop it.
+ * Setting ret/mask to 0 will continue the event loop
+ * and do the right thing if there are no more events
+ * to read (i.e. return bytes read, -EAGAIN or wait).
+ */
+ kevent->mask = 0;
+ ret = 0;
+ }
+
/*
* Permission events get queued to wait for response. Other