grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Ignore symlink traversal failures in grub-mount readdir
@ 2012-10-12 16:09 Colin Watson
  2012-10-15 15:08 ` Dave Vasilevsky
  2013-03-09 16:47 ` Andrey Borzenkov
  0 siblings, 2 replies; 6+ messages in thread
From: Colin Watson @ 2012-10-12 16:09 UTC (permalink / raw)
  To: grub-devel

This is very much a temporary hack, so I'm sending it here for
discussion rather than just committing it even though it's quite simple.

r3036.1.15 introduced support for filling in the attributes of files in
fuse_readdir.  However, symlinks to directories are passed to call_fill
with info.dir unset; call_fill will then try to open them with
grub_file_open, and get GRUB_ERR_BAD_FILE_TYPE because it's ultimately a
directory not a regular file.  It then causes the whole readdir call to
fail.  The net effect is that if you, for example, have a symlink
anywhere in the top level of a filesystem, then the entire filesystem
appears empty in grub-mount.  This is the root cause of
https://bugs.launchpad.net/bugs/1051306.

I think that the proper solution is to pass the full
grub_fshelp_filetype to dirhook functions, which would permit
implementing true symlink support in grub-mount.  That would be a fairly
large change that I don't have time for at the moment.  As a stopgap, I
suggest that we ignore errors from individual grub_file_open calls
during fuse_readdir.  How does this patch look?

2012-10-12  Colin Watson  <cjwatson@ubuntu.com>

=== modified file 'util/grub-mount.c'
--- util/grub-mount.c	2012-03-08 18:09:05 +0000
+++ util/grub-mount.c	2012-10-12 16:08:39 +0000
@@ -292,7 +292,20 @@ fuse_readdir (const char *path, void *bu
 	file = grub_file_open (tmp);
 	free (tmp);
 	if (! file)
-	  return translate_error ();
+	  {
+	    /* We cannot handle symlinks properly yet, and symlinks to
+	       directories will cause us to reach here.  Symlink loops or
+	       dangling symlinks will also cause an error.  For the
+	       meantime, while treating these as zero-length files is wrong,
+	       it's better than failing the whole readdir call by returning
+	       translate_error ().
+
+	       Ultimately, we should be able to tell from the
+	       grub_dirhook_info that this is a symlink, and fill in the
+	       attributes of the symlink rather than its target.  */
+	    grub_errno = GRUB_ERR_NONE;
+	    return 0;
+	  }
 	st.st_size = file->size;
 	grub_file_close (file);
       }

Thanks,

-- 
Colin Watson                                       [cjwatson@ubuntu.com]


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

end of thread, other threads:[~2013-11-28 13:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 16:09 [PATCH] Ignore symlink traversal failures in grub-mount readdir Colin Watson
2012-10-15 15:08 ` Dave Vasilevsky
2013-03-09 16:47 ` Andrey Borzenkov
2013-03-10 13:01   ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-03-10 13:02     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-28 13:30     ` Andrey Borzenkov

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