Re: [PATCH] init/do_mounts.c: replace sys_mount() to do_mount()

Arnd Bergmann
2010-08-17T13:15:31Z

On Tuesday 17 August 2010, Namhyung Kim wrote:
> static int __init do_mount_root(char *name, char *fs, int flags, void *data)
> {
> - int err = sys_mount(name, "/root", fs, flags, data);
> + int err;
> + unsigned long data_page = 0;
> +
> + if (data) {
> + /* data should be in a page */
> + data_page = __get_free_page(GFP_KERNEL);
> + if (!data_page)
> + return -ENOMEM;
> + strlcpy((char *) data_page, data, PAGE_SIZE);
> + }
> +
> + err = do_mount(name, "/root", fs, flags, (void *) data_page);
> +
> + if (data_page)
> + free_page(data_page);

AFAICT there is no need for the copy at all here. The reason that sys_mount
copies to a separate page is that it gets passed an arbitrary-length user
input.

Arnd