Comparing a signed return value against an unsigned nr_pages performs
the comparison as "unsigned", and therefore mistakenly considers
get_user_pages_fast() errors as success.
By passing an invalid pointer to write() to the /proc/lttng-logger
interface, unprivileged user-space processes can trigger a kernel OOPS.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ssize_t lttng_logger_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
- unsigned int nr_pages = 1, i;
+ int nr_pages = 1, i;
unsigned long uaddr = (unsigned long) user_buf;
struct page *pages[2];
ssize_t written;