linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
@ 2009-04-09 11:18 Tetsuo Handa
  2009-04-09 15:08 ` Johannes Weiner
  2009-04-09 21:03 ` Al Viro
  0 siblings, 2 replies; 5+ messages in thread
From: Tetsuo Handa @ 2009-04-09 11:18 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Is it legal to use '\t' and '\n' in filesystem's name?
If legal, we should use \ooo escape for /proc/filesystems .

----------
[RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.

Registering a filesystem with broken name

  static struct file_system_type dummy_fs_type = {
          .name       = "a\tb\nc",
  };

results in broken output

  # cat /proc/filesystems
  nodev   sysfs
  nodev   rootfs
  nodev   bdev
  nodev   proc
  nodev   debugfs
  nodev   sockfs
  nodev   usbfs
  nodev   pipefs
  nodev   anon_inodefs
  nodev   tmpfs
  nodev   inotifyfs
  nodev   devpts
          ext3
          ext2
          cramfs
  nodev   ramfs
          vfat
          iso9660
  nodev   nfsd
  nodev   smbfs
  nodev   a       b
  c
  nodev   rpc_pipefs

Why not forbid '\t' and '\n'?

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
 fs/filesystems.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

--- linux-2.6.30-rc1.orig/fs/filesystems.c
+++ linux-2.6.30-rc1/fs/filesystems.c
@@ -65,18 +65,21 @@ static struct file_system_type **find_fi
  *	structures and must not be freed until the file system has been
  *	unregistered.
  */
- 
-int register_filesystem(struct file_system_type * fs)
+
+int register_filesystem(struct file_system_type *fs)
 {
+	const char *fsname = fs->name;
 	int res = 0;
-	struct file_system_type ** p;
+	struct file_system_type **p;
 
-	BUG_ON(strchr(fs->name, '.'));
+	BUG_ON(strchr(fsname, '.'));
+	if (strchr(fsname, '\t') || strchr(fsname, '\n'))
+		return -EINVAL;
 	if (fs->next)
 		return -EBUSY;
 	INIT_LIST_HEAD(&fs->fs_supers);
 	write_lock(&file_systems_lock);
-	p = find_filesystem(fs->name, strlen(fs->name));
+	p = find_filesystem(fsname, strlen(fsname));
 	if (*p)
 		res = -EBUSY;
 	else

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

* Re: [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
  2009-04-09 11:18 [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n' Tetsuo Handa
@ 2009-04-09 15:08 ` Johannes Weiner
  2009-04-09 15:47   ` Christoph Hellwig
  2009-04-09 21:03 ` Al Viro
  1 sibling, 1 reply; 5+ messages in thread
From: Johannes Weiner @ 2009-04-09 15:08 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-fsdevel, linux-kernel

On Thu, Apr 09, 2009 at 08:18:20PM +0900, Tetsuo Handa wrote:
> Is it legal to use '\t' and '\n' in filesystem's name?
> If legal, we should use \ooo escape for /proc/filesystems .
> 
> ----------
> [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
> 
> Registering a filesystem with broken name
> 
>   static struct file_system_type dummy_fs_type = {
>           .name       = "a\tb\nc",
>   };
> 
> results in broken output
> 
>   # cat /proc/filesystems
>   nodev   sysfs
>   nodev   rootfs
>   nodev   bdev
>   nodev   proc
>   nodev   debugfs
>   nodev   sockfs
>   nodev   usbfs
>   nodev   pipefs
>   nodev   anon_inodefs
>   nodev   tmpfs
>   nodev   inotifyfs
>   nodev   devpts
>           ext3
>           ext2
>           cramfs
>   nodev   ramfs
>           vfat
>           iso9660
>   nodev   nfsd
>   nodev   smbfs
>   nodev   a       b
>   c
>   nodev   rpc_pipefs
> 
> Why not forbid '\t' and '\n'?

Which filesystem does that?  Shouldn't the filesystem get changed
instead?

	Hannes

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

* Re: [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
  2009-04-09 15:08 ` Johannes Weiner
@ 2009-04-09 15:47   ` Christoph Hellwig
  2009-04-09 21:03     ` Al Viro
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2009-04-09 15:47 UTC (permalink / raw)
  To: Johannes Weiner; +Cc: Tetsuo Handa, linux-fsdevel, linux-kernel

On Thu, Apr 09, 2009 at 05:08:43PM +0200, Johannes Weiner wrote:
> Which filesystem does that?  Shouldn't the filesystem get changed
> instead?

Yeah, if at all we should reject a name with those characters.  But I
feel that's a little over-engineering and we should just make sure no
in-tree fs does stupid things like that by review.


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

* Re: [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
  2009-04-09 11:18 [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n' Tetsuo Handa
  2009-04-09 15:08 ` Johannes Weiner
@ 2009-04-09 21:03 ` Al Viro
  1 sibling, 0 replies; 5+ messages in thread
From: Al Viro @ 2009-04-09 21:03 UTC (permalink / raw)
  To: Tetsuo Handa; +Cc: linux-fsdevel, linux-kernel

On Thu, Apr 09, 2009 at 08:18:20PM +0900, Tetsuo Handa wrote:
> Is it legal to use '\t' and '\n' in filesystem's name?
> If legal, we should use \ooo escape for /proc/filesystems .
> 
> ----------
> [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
> 
> Registering a filesystem with broken name
> 
>   static struct file_system_type dummy_fs_type = {
>           .name       = "a\tb\nc",
>   };
> 
> results in

... rejected patch submission.  End of problem...

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

* Re: [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n'.
  2009-04-09 15:47   ` Christoph Hellwig
@ 2009-04-09 21:03     ` Al Viro
  0 siblings, 0 replies; 5+ messages in thread
From: Al Viro @ 2009-04-09 21:03 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Johannes Weiner, Tetsuo Handa, linux-fsdevel, linux-kernel

On Thu, Apr 09, 2009 at 11:47:26AM -0400, Christoph Hellwig wrote:
> On Thu, Apr 09, 2009 at 05:08:43PM +0200, Johannes Weiner wrote:
> > Which filesystem does that?  Shouldn't the filesystem get changed
> > instead?
> 
> Yeah, if at all we should reject a name with those characters.  But I
> feel that's a little over-engineering and we should just make sure no
> in-tree fs does stupid things like that by review.

Yes.

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

end of thread, other threads:[~2009-04-09 21:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-09 11:18 [RFC PATCH] fs: register_filesystem: Don't allow '\t' and '\n' Tetsuo Handa
2009-04-09 15:08 ` Johannes Weiner
2009-04-09 15:47   ` Christoph Hellwig
2009-04-09 21:03     ` Al Viro
2009-04-09 21:03 ` Al Viro

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).