Re: [PATCH 2/3] uprobes: __copy_insn() should ensurea_ops->readpage != NULL

From: Srikar Dronamraju
Date: Fri Jun 15 2012 - 02:31:28 EST


* Oleg Nesterov <oleg@xxxxxxxxxx> [2012-06-07 19:00:18]:

> __copy_insn() blindly calls read_mapping_page(), this will crash
> the kernel if ->readpage == NULL, add the necessary check. For
> example, hugetlbfs_aops->readpage is NULL. Perhaps we should change
> read_mapping_page() instead.
>
> Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
> ---
> kernel/events/uprobes.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
> index 48d53af..9c53bc2 100644
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -616,6 +616,8 @@ __copy_insn(struct address_space *mapping, struct vm_area_struct *vma, char *ins
>
> if (!filp)
> return -EINVAL;
> + if (!mapping->a_ops->readpage)
> + return -EIO;

Nit: Should there be a blank line before the if. Ingo had insisted on
these coding style changes.

> idx = (unsigned long)(offset >> PAGE_CACHE_SHIFT);
> off1 = offset &= ~PAGE_MASK;

Acked-by: Srikar Dronamraju <srikar@xxxxxxxxxxxxxxxxxx>

--
Thanks and Regards
Srikar

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/