Commit 11c5ad0ec441 ("eventpoll: switch to ->poll_mask") in v4.18-rc1, made
eventpoll switch from ->poll() to ->poll_mask(), resulting in a null
pointer dereference as vmmon calls the callback directly without checking
its availability.
Rather than calling the callback directly (which would result in null
pointer dereference), use vfs_poll() wrapper. As this wrapper is only
available since 4.18-rc1 cycle as well, provide a copy to use when building
against older kernels.
Note: even if the commit revealing the problem was reverted in 4.18-rc3
(and is unlikely to go back in the same form) so that vmmon no longer
crashes with 4.18 kernel, calling the callback without a check is a bad
practice so let's keep the patch in place.
31 lines
566 B
C
31 lines
566 B
C
#ifndef __COMPAT_POLL_H__
|
|
#define __COMPAT_POLL_H__
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
|
|
|
|
#ifndef __poll_t
|
|
typedef unsigned int __poll_t;
|
|
#endif
|
|
|
|
static inline __poll_t compat_vfs_poll(struct file *file,
|
|
struct poll_table_struct *pt)
|
|
{
|
|
if (unlikely(!file->f_op->poll))
|
|
return DEFAULT_POLLMASK;
|
|
return file->f_op->poll(file, pt);
|
|
}
|
|
|
|
#else
|
|
|
|
static inline __poll_t compat_vfs_poll(struct file *file,
|
|
struct poll_table_struct *pt)
|
|
{
|
|
return vfs_poll(file, pt);
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* __COMPAT_POLL_H__ */
|