Re: Bug in caching of mount options

Bill Hawes (whawes@star.net)
Tue, 30 Sep 1997 15:46:16 -0400


This is a multi-part message in MIME format.
--------------CC46170188F67E43E9331002
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Jim Nance wrote:
> I have found a bug in the kernel, which I believe is related to the
> caching of mount options. It shows up under both 2.0.31-pre10 and
> 2.1.57.
>
> If I mount a filesystem with the noexec option, then I (of cousre)
> cant run any binaries on it. If I remount it with:
>
> mount -o remount,exec /mnt/zip
>
> I can still not run binaries which I tried to run before the remount,
> but I CAN run new binaries which I copy into the file system.

Hi Jim,
Could you give the attached patch a try? It shrinks, syncs, and
invalidates before remounting, which should take care of the problem you
noted. (But note that a file still open can't be invalidated ...
shouldn't apply to binaries though.)

If you aren't using the dcache patch I posted a couple of days ago, just
replace the shrink_dcache_sb(sb) with shrink_dcache().

Regards,
Bill
--------------CC46170188F67E43E9331002
Content-Type: text/plain; charset=us-ascii; name="remount_57-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="remount_57-patch"

--- fs/super.c.old Fri Sep 26 08:10:51 1997
+++ fs/super.c Tue Sep 30 15:28:14 1997
@@ -847,6 +847,13 @@
int retval;
struct vfsmount *vfsmnt;

+ /*
+ * Invalidate the inodes, as some mount options may be changed.
+ * N.B. If we are changing media, we should check the return
+ * from invalidate_inodes ... can't allow _any_ open files.
+ */
+ invalidate_inodes(sb);
+
if (!(flags & MS_RDONLY) && sb->s_dev && is_read_only(sb->s_dev))
return -EACCES;
/*flags |= MS_RDONLY;*/
@@ -877,8 +884,14 @@
struct super_block * sb = dentry->d_inode->i_sb;

retval = -EINVAL;
- if (dentry == sb->s_root)
+ if (dentry == sb->s_root) {
+ /*
+ * Shrink the dcache and sync the device.
+ */
+ shrink_dcache_sb(sb);
+ fsync_dev(sb->s_dev);
retval = do_remount_sb(sb, flags, data);
+ }
dput(dentry);
}
return retval;

--------------CC46170188F67E43E9331002--