Re: bugfix in copy_mount_options()?

From: Tigran Aivazian (tigran@veritas.com)
Date: Mon May 08 2000 - 12:06:13 EST


On Thu, 4 May 2000 kernel@kvack.org wrote:
>
> --- super.c.orig Wed May 3 21:10:34 2000
> +++ super.c Thu May 4 16:51:51 2000
> @@ -1097,21 +1097,20 @@
> if (!data)
> return 0;
>
> - vma = find_vma(current->mm, (unsigned long) data);
> - if (!vma || (unsigned long) data < vma->vm_start)
> - return -EFAULT;
> - if (!(vma->vm_flags & VM_READ))
> - return -EFAULT;
> - i = vma->vm_end - (unsigned long) data;
> - if (PAGE_SIZE <= (unsigned long) i)
> - i = PAGE_SIZE-1;
> - if (!(page = __get_free_page(GFP_KERNEL))) {
> + if (!(page = __get_free_page(GFP_KERNEL)))
> return -ENOMEM;
> - }
> - if (copy_from_user((void *) page,data,i)) {
> +
> + /* We only care that *some* data at the address the user
> + * gave us is valid. Just in case, we'll zero
> + * the remainder of the page.
> + */
> + i = copy_from_user((void *) page,data,PAGE_SIZE);
> + if (i == PAGE_SIZE) {
> free_page(page);
> return -EFAULT;
> }
> + if (i)
> + memset((char *)page + PAGE_SIZE - i, 0, i);
> *where = page;
> return 0;
> }
>

Hi Ben,

Ok, now why not also get rid of all three memchr() in do_sys_mount() the
sole purpose of which seems to be to check if there was a 0 in the range
0-PAGE_SIZE which you now do in copy_mount_options? Also, get rid of the
0-initialization of data_page/type_page/dev_page in sys_mount() and the
result should be a nice cleanup patch? Or have you already sent it to
Linus as is?

Regards,
Tigran

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



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:11 EST