[PATCH] vfs: ensure mount source is set to "none" if empty string specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Due to changes from commit 0f89589a8c6f1033cb847a606517998efb0da8ee
mount source devname is no longer getting set to 'none' if an empty
source string is passed. Therefore /proc/<PID>/mountinfo will have a
empty string for source devname instead of 'none'.

This is due to following change in this commit
in vfs_parse_fs_string()

-       if (v_size > 0) {
+       if (value) {
                param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
                if (!param.string)
                        return -ENOMEM;
+               param.type = fs_value_is_string;
        }

That results in fc->source, which is copied from param.string, to point
to an empty string instead of it being NULL. So, alloc_vfsmnt() called
from vfs_create_mount() would be passed the empty string in fc->source
not 'none'.

This patch fix checks if fc->source is an empty string in the call to
alloc_vfsmnt() and passes 'none'.

The issue can be easily reproduced.
 #mount -t tmpfs "" /tmp/tdir
 #grep "/tmp/tdir" /proc/$$/mountinfo

With the fix
506 103 0:48 / /tmp/tdir rw,relatime shared:268 - tmpfs none rw,...

Without the fix
506 103 0:48 / /tmp/tdir rw,relatime shared:268 - tmpfs rw,...

Signed-off-by: Prakash Sangappa <prakash.sangappa@xxxxxxxxxx>
---
 fs/namespace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 5a51315..409b48c 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -1100,7 +1100,8 @@ struct vfsmount *vfs_create_mount(struct fs_context *fc)
 	if (!fc->root)
 		return ERR_PTR(-EINVAL);
 
-	mnt = alloc_vfsmnt(fc->source ?: "none");
+	mnt = alloc_vfsmnt(fc->source && strlen(fc->source) > 0 ?
+			   fc->source : "none");
 	if (!mnt)
 		return ERR_PTR(-ENOMEM);
 
-- 
2.7.4





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux