Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98a2139f authored by Jan Kara's avatar Jan Kara Committed by Trond Myklebust
Browse files

nfs: Enclose hostname in brackets when needed in nfs_do_root_mount



When hostname contains colon (e.g. when it is an IPv6 address) it needs
to be enclosed in brackets to make parsing of NFS device string possible.
Fix nfs_do_root_mount() to enclose hostname properly when needed. NFS code
actually does not need this as it does not parse the string passed by
nfs_do_root_mount() but the device string is exposed to userspace in
/proc/mounts.

CC: Josh Boyer <jwboyer@redhat.com>
CC: Trond Myklebust <Trond.Myklebust@netapp.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 8ccd271f
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -2767,10 +2767,14 @@ static struct vfsmount *nfs_do_root_mount(struct file_system_type *fs_type,
	char *root_devname;
	size_t len;

	len = strlen(hostname) + 3;
	len = strlen(hostname) + 5;
	root_devname = kmalloc(len, GFP_KERNEL);
	if (root_devname == NULL)
		return ERR_PTR(-ENOMEM);
	/* Does hostname needs to be enclosed in brackets? */
	if (strchr(hostname, ':'))
		snprintf(root_devname, len, "[%s]:/", hostname);
	else
		snprintf(root_devname, len, "%s:/", hostname);
	root_mnt = vfs_kern_mount(fs_type, flags, root_devname, data);
	kfree(root_devname);