linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] vfs: fix a couple of mount table handling problems
@ 2022-06-28  0:30 Ian Kent
  2022-06-28  0:30 ` [PATCH 1/2] vfs: parse: deal with zero length string value Ian Kent
  2022-06-28  0:30 ` [PATCH 2/2] vfs: escape hash as well Ian Kent
  0 siblings, 2 replies; 10+ messages in thread
From: Ian Kent @ 2022-06-28  0:30 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Al Viro, Siddhesh Poyarekar, David Howells, Miklos Szeredi,
	Carlos Maiolino, linux-fsdevel, Kernel Mailing List

First, whenever a mount has an empty "source" (aka mnt_fsname), the
glibc function getmntent incorrectly parses its input, resulting in
reporting incorrect data to the caller.

The problem is that the get_mnt_entry() function in glibc's
misc/mntent_r.c assumes that leading whitespace on a line can always
be discarded because it will always be followed by a # for the case
of a comment or a non-whitespace character that's part of the value
of the first field. However, this assumption is violated when the
value of the first field is an empty string.

This is fixed in the mount API code by simply checking for a pointer
that contains a NULL and treating it as a NULL pointer.

Second, when a filesystem is mounted with a name that starts with
a # the glibc finction getmentent() will interpret the leading #
as a comment so that the mount line will not appear in the output.

This is fixed by adding a # to the to be translated string in
fs/proc_namespace.c:mangle().

Signed-off-by: Ian Kent <raven@themaw.net>
---

Ian Kent (1):
      vfs: parse: deal with zero length string value

Siddhesh Poyarekar (1):
      vfs: escape hash as well


 fs/fs_context.c     | 10 +++++++---
 fs/proc_namespace.c |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

--
Ian


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH 0/2] vfs: fix a couple of mount table handling problems
@ 2022-06-17  5:08 Ian Kent
  2022-06-17  5:09 ` [PATCH 1/2] vfs: parse: deal with zero length string value Ian Kent
  0 siblings, 1 reply; 10+ messages in thread
From: Ian Kent @ 2022-06-17  5:08 UTC (permalink / raw)
  To: Al Viro
  Cc: Siddhesh Poyarekar, David Howells, Miklos Szeredi,
	Carlos Maiolino, linux-fsdevel, Kernel Mailing List

First, whenever a mount has an empty "source" (aka mnt_fsname), the
glibc function getmntent incorrectly parses its input, resulting in
reporting incorrect data to the caller.

The problem is that the get_mnt_entry() function in glibc's
misc/mntent_r.c assumes that leading whitespace on a line can always
be discarded because it will always be followed by a # for the case
of a comment or a non-whitespace character that's part of the value
of the first field. However, this assumption is violated when the
value of the first field is an empty string.

This is fixed in the mount API code by simply checking for a pointer
that contains a NULL and treating it as a NULL pointer.

Second, when a filesystem is mounted with a name that starts with
a # the glibc finction getmentent() will interpret the leading #
as a comment so that the mount line will not appear in the output.

This is fixed by adding a # to the to be translated string in
fs/proc_namespace.c:mangle().

Signed-off-by: Ian Kent <raven@themaw.net>
---

Ian Kent (1):
      vfs: parse: deal with zero length string value

Siddhesh Poyarekar (1):
      vfs: escape hash as well


 fs/fs_context.c     | 10 +++++++---
 fs/proc_namespace.c |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

--
Ian Kent


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH 1/2] vfs: parse: deal with zero length string value
@ 2021-10-25  4:05 Ian Kent
  0 siblings, 0 replies; 10+ messages in thread
From: Ian Kent @ 2021-10-25  4:05 UTC (permalink / raw)
  To: Al Viro
  Cc: David Howells, Miklos Szeredi, Carlos Maiolino, linux-fsdevel,
	Kernel Mailing List

From: Ian Kent <ikent@redhat.com>

Parsing an fs string that has zero length should result in the parameter
being set to NULL so that downstream processing handles it correctly.
For example, the proc mount table processing should print "(none)" in
this case to preserve mount record field count, but if the value points
to the NULL string this doesn't happen.

Signed-off-by: Ian Kent <ikent@redhat.com>
---
 fs/fs_context.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/fs_context.c b/fs/fs_context.c
index b7e43a780a62..a949cceccbfd 100644
--- a/fs/fs_context.c
+++ b/fs/fs_context.c
@@ -175,9 +175,13 @@ int vfs_parse_fs_string(struct fs_context *fc, const char *key,
 	};
 
 	if (value) {
-		param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
-		if (!param.string)
-			return -ENOMEM;
+		if (!v_size)
+			param.string = NULL;
+		else {
+			param.string = kmemdup_nul(value, v_size, GFP_KERNEL);
+			if (!param.string)
+				return -ENOMEM;
+		}
 		param.type = fs_value_is_string;
 	}
 



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-01  6:30 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-28  0:30 [PATCH 0/2] vfs: fix a couple of mount table handling problems Ian Kent
2022-06-28  0:30 ` [PATCH 1/2] vfs: parse: deal with zero length string value Ian Kent
2022-06-28 17:55   ` Al Viro
2022-06-29  1:06     ` Ian Kent
2022-07-01  6:29       ` Ian Kent
2022-06-28  0:30 ` [PATCH 2/2] vfs: escape hash as well Ian Kent
2022-06-28 17:57   ` Al Viro
  -- strict thread matches above, loose matches on Subject: below --
2022-06-17  5:08 [PATCH 0/2] vfs: fix a couple of mount table handling problems Ian Kent
2022-06-17  5:09 ` [PATCH 1/2] vfs: parse: deal with zero length string value Ian Kent
2022-06-28 13:03   ` Christian Brauner
2021-10-25  4:05 Ian Kent

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).