cifs: fix pointer initialization and checks in cifs_follow_symlink (try #4)
[safe/jmp/linux-2.6] / fs / namespace.c
index 1e56303..134d494 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/ramfs.h>
 #include <linux/log2.h>
 #include <linux/idr.h>
+#include <linux/fs_struct.h>
 #include <asm/uaccess.h>
 #include <asm/unistd.h>
 #include "pnode.h"
@@ -694,12 +695,16 @@ static inline void mangle(struct seq_file *m, const char *s)
  */
 int generic_show_options(struct seq_file *m, struct vfsmount *mnt)
 {
-       const char *options = mnt->mnt_sb->s_options;
+       const char *options;
+
+       rcu_read_lock();
+       options = rcu_dereference(mnt->mnt_sb->s_options);
 
        if (options != NULL && options[0]) {
                seq_putc(m, ',');
                mangle(m, options);
        }
+       rcu_read_unlock();
 
        return 0;
 }
@@ -720,11 +725,22 @@ EXPORT_SYMBOL(generic_show_options);
  */
 void save_mount_options(struct super_block *sb, char *options)
 {
-       kfree(sb->s_options);
-       sb->s_options = kstrdup(options, GFP_KERNEL);
+       BUG_ON(sb->s_options);
+       rcu_assign_pointer(sb->s_options, kstrdup(options, GFP_KERNEL));
 }
 EXPORT_SYMBOL(save_mount_options);
 
+void replace_mount_options(struct super_block *sb, char *options)
+{
+       char *old = sb->s_options;
+       rcu_assign_pointer(sb->s_options, options);
+       if (old) {
+               synchronize_rcu();
+               kfree(old);
+       }
+}
+EXPORT_SYMBOL(replace_mount_options);
+
 #ifdef CONFIG_PROC_FS
 /* iterator */
 static void *m_start(struct seq_file *m, loff_t *pos)
@@ -1072,9 +1088,7 @@ static int do_umount(struct vfsmount *mnt, int flags)
         */
 
        if (flags & MNT_FORCE && sb->s_op->umount_begin) {
-               lock_kernel();
                sb->s_op->umount_begin(sb);
-               unlock_kernel();
        }
 
        /*
@@ -1376,7 +1390,7 @@ static int attach_recursive_mnt(struct vfsmount *source_mnt,
        if (parent_path) {
                detach_mnt(source_mnt, parent_path);
                attach_mnt(source_mnt, path);
-               touch_mnt_namespace(current->nsproxy->mnt_ns);
+               touch_mnt_namespace(parent_path->mnt->mnt_ns);
        } else {
                mnt_set_mountpoint(dest_mnt, dest_dentry, source_mnt);
                commit_tree(source_mnt);
@@ -1919,8 +1933,9 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
        if (data_page)
                ((char *)data_page)[PAGE_SIZE - 1] = 0;
 
-       /* Default to relatime */
-       mnt_flags |= MNT_RELATIME;
+       /* Default to relatime unless overriden */
+       if (!(flags & MS_NOATIME))
+               mnt_flags |= MNT_RELATIME;
 
        /* Separate the per-mountpoint flags */
        if (flags & MS_NOSUID)