Re: [PATCH v2 1/2] fs: Improve and simplify copy_mount_options

Linus Torvalds
2016-06-16T05:59:02Z

On Wed, Jun 15, 2016 at 7:45 PM, Willy Tarreau <w@1wt.eu> wrote:
>
> Well, strncpy() would make the function behave differently depending on
> the FS being used if called from the kernel for the reason Al mentionned.
> OK devtmpfsd() passes a string, but if it's the FS itself which decides
> to stop on a zero when parsing mount options, we'd probably rather use
> memcpy() instead to ensure a consistent behaviour, like this maybe ?

.. but that is exactly what Andy considers to be a problem: now it
copies random kernel memory that is possibly security-critical.

The kernel users that use this just pass in a string - it doesn't
matter what the filesystem thinks it is getting, the uses were all
kernel strings,, so the "copy_mount_options": should copy that string
(and zero-fill the page that the filesystem may think it is getting).

Linus