kernel/fork: always deny write access to current MM exe_file
[linux-2.6-microblaze.git] / fs / fs-writeback.c
index 8c7e9e5..4c33705 100644 (file)
@@ -521,6 +521,9 @@ static bool inode_prepare_wbs_switch(struct inode *inode,
         */
        smp_mb();
 
+       if (IS_DAX(inode))
+               return false;
+
        /* while holding I_WB_SWITCH, no one else can update the association */
        spin_lock(&inode->i_lock);
        if (!(inode->i_sb->s_flags & SB_ACTIVE) ||
@@ -567,9 +570,14 @@ static void inode_switch_wbs(struct inode *inode, int new_wb_id)
        /* find and pin the new wb */
        rcu_read_lock();
        memcg_css = css_from_id(new_wb_id, &memory_cgrp_subsys);
-       if (memcg_css)
-               isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
+       if (memcg_css && !css_tryget(memcg_css))
+               memcg_css = NULL;
        rcu_read_unlock();
+       if (!memcg_css)
+               goto out_free;
+
+       isw->new_wb = wb_get_create(bdi, memcg_css, GFP_ATOMIC);
+       css_put(memcg_css);
        if (!isw->new_wb)
                goto out_free;