[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1720729462-30935-1-git-send-email-prakash.sangappa@oracle.com>
Date: Thu, 11 Jul 2024 13:24:22 -0700
From: Prakash Sangappa <prakash.sangappa@...cle.com>
To: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: dhowells@...hat.com, viro@...iv.linux.org.uk
Subject: [PATCH] vfs: ensure mount source is set to "none" if empty string specified
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@...cle.com>
---
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
Powered by blists - more mailing lists