Revert "do d_instantiate/unlock_new_inode combinations safely"
This reverts commit 03bb758894
.
Causes oops with security smack enabled.
Change-Id: I14fb2b0841c6b71940bd3f08bd4b49b1d7b039a3
Signed-off-by: Gustavo Solaira <gustavos@codeaurora.org>
This commit is contained in:
parent
642d3ae98b
commit
a97cb8dfea
13 changed files with 66 additions and 54 deletions
|
@ -6413,7 +6413,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,
|
|||
goto out_unlock_inode;
|
||||
} else {
|
||||
btrfs_update_inode(trans, root, inode);
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
}
|
||||
|
||||
out_unlock:
|
||||
|
@ -6488,7 +6489,8 @@ static int btrfs_create(struct inode *dir, struct dentry *dentry,
|
|||
goto out_unlock_inode;
|
||||
|
||||
BTRFS_I(inode)->io_tree.ops = &btrfs_extent_io_ops;
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
|
||||
out_unlock:
|
||||
btrfs_end_transaction(trans, root);
|
||||
|
@ -6631,7 +6633,12 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
if (err)
|
||||
goto out_fail_inode;
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
/*
|
||||
* mkdir is special. We're unlocking after we call d_instantiate
|
||||
* to avoid a race with nfsd calling d_instantiate.
|
||||
*/
|
||||
unlock_new_inode(inode);
|
||||
drop_on_err = 0;
|
||||
|
||||
out_fail:
|
||||
|
@ -9782,7 +9789,8 @@ static int btrfs_symlink(struct inode *dir, struct dentry *dentry,
|
|||
goto out_unlock_inode;
|
||||
}
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
|
||||
out_unlock:
|
||||
btrfs_end_transaction(trans, root);
|
||||
|
|
22
fs/dcache.c
22
fs/dcache.c
|
@ -1897,28 +1897,6 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode)
|
|||
|
||||
EXPORT_SYMBOL(d_instantiate_unique);
|
||||
|
||||
/*
|
||||
* This should be equivalent to d_instantiate() + unlock_new_inode(),
|
||||
* with lockdep-related part of unlock_new_inode() done before
|
||||
* anything else. Use that instead of open-coding d_instantiate()/
|
||||
* unlock_new_inode() combinations.
|
||||
*/
|
||||
void d_instantiate_new(struct dentry *entry, struct inode *inode)
|
||||
{
|
||||
BUG_ON(!hlist_unhashed(&entry->d_u.d_alias));
|
||||
BUG_ON(!inode);
|
||||
lockdep_annotate_inode_mutex_key(inode);
|
||||
security_d_instantiate(entry, inode);
|
||||
spin_lock(&inode->i_lock);
|
||||
__d_instantiate(entry, inode);
|
||||
WARN_ON(!(inode->i_state & I_NEW));
|
||||
inode->i_state &= ~I_NEW;
|
||||
smp_mb();
|
||||
wake_up_bit(&inode->i_state, __I_NEW);
|
||||
spin_unlock(&inode->i_lock);
|
||||
}
|
||||
EXPORT_SYMBOL(d_instantiate_new);
|
||||
|
||||
/**
|
||||
* d_instantiate_no_diralias - instantiate a non-aliased dentry
|
||||
* @entry: dentry to complete
|
||||
|
|
|
@ -298,7 +298,8 @@ ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry,
|
|||
ecryptfs_inode_to_lower(ecryptfs_inode),
|
||||
crypt_stat);
|
||||
|
||||
d_instantiate_new(ecryptfs_dentry, ecryptfs_inode);
|
||||
unlock_new_inode(ecryptfs_inode);
|
||||
d_instantiate(ecryptfs_dentry, ecryptfs_inode);
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,8 @@ static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode)
|
|||
{
|
||||
int err = ext2_add_link(dentry, inode);
|
||||
if (!err) {
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
}
|
||||
inode_dec_link_count(inode);
|
||||
|
@ -266,7 +267,8 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
|
|||
if (err)
|
||||
goto out_fail;
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
out:
|
||||
return err;
|
||||
|
||||
|
|
|
@ -2426,7 +2426,8 @@ static int ext4_add_nondir(handle_t *handle,
|
|||
int err = ext4_add_entry(handle, dentry, inode);
|
||||
if (!err) {
|
||||
ext4_mark_inode_dirty(handle, inode);
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
}
|
||||
drop_nlink(inode);
|
||||
|
@ -2665,7 +2666,8 @@ out_clear_inode:
|
|||
err = ext4_mark_inode_dirty(handle, dir);
|
||||
if (err)
|
||||
goto out_clear_inode;
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
if (IS_DIRSYNC(dir))
|
||||
ext4_handle_sync(handle);
|
||||
|
||||
|
|
|
@ -294,7 +294,8 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
|
|||
|
||||
alloc_nid_done(sbi, ino);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
|
||||
if (IS_DIRSYNC(dir))
|
||||
f2fs_sync_fs(sbi->sb, 1);
|
||||
|
@ -593,7 +594,8 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
|
|||
err = page_symlink(inode, disk_link.name, disk_link.len);
|
||||
|
||||
err_out:
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
|
||||
/*
|
||||
* Let's flush symlink data in order to avoid broken symlink as much as
|
||||
|
@ -656,7 +658,8 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
|
||||
alloc_nid_done(sbi, inode->i_ino);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
|
||||
if (IS_DIRSYNC(dir))
|
||||
f2fs_sync_fs(sbi->sb, 1);
|
||||
|
@ -707,7 +710,8 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
|
|||
|
||||
alloc_nid_done(sbi, inode->i_ino);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
|
||||
if (IS_DIRSYNC(dir))
|
||||
f2fs_sync_fs(sbi->sb, 1);
|
||||
|
|
|
@ -207,7 +207,8 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
|
|||
__func__, inode->i_ino, inode->i_mode, inode->i_nlink,
|
||||
f->inocache->pino_nlink, inode->i_mapping->nrpages);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
@ -427,7 +428,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
|
|||
mutex_unlock(&dir_f->sem);
|
||||
jffs2_complete_reservation(c);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
@ -571,7 +573,8 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode
|
|||
mutex_unlock(&dir_f->sem);
|
||||
jffs2_complete_reservation(c);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
@ -742,7 +745,8 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
|
|||
mutex_unlock(&dir_f->sem);
|
||||
jffs2_complete_reservation(c);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
|
|
|
@ -178,7 +178,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode,
|
|||
unlock_new_inode(ip);
|
||||
iput(ip);
|
||||
} else {
|
||||
d_instantiate_new(dentry, ip);
|
||||
unlock_new_inode(ip);
|
||||
d_instantiate(dentry, ip);
|
||||
}
|
||||
|
||||
out2:
|
||||
|
@ -312,7 +313,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, umode_t mode)
|
|||
unlock_new_inode(ip);
|
||||
iput(ip);
|
||||
} else {
|
||||
d_instantiate_new(dentry, ip);
|
||||
unlock_new_inode(ip);
|
||||
d_instantiate(dentry, ip);
|
||||
}
|
||||
|
||||
out2:
|
||||
|
@ -1056,7 +1058,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,
|
|||
unlock_new_inode(ip);
|
||||
iput(ip);
|
||||
} else {
|
||||
d_instantiate_new(dentry, ip);
|
||||
unlock_new_inode(ip);
|
||||
d_instantiate(dentry, ip);
|
||||
}
|
||||
|
||||
out2:
|
||||
|
@ -1440,7 +1443,8 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry,
|
|||
unlock_new_inode(ip);
|
||||
iput(ip);
|
||||
} else {
|
||||
d_instantiate_new(dentry, ip);
|
||||
unlock_new_inode(ip);
|
||||
d_instantiate(dentry, ip);
|
||||
}
|
||||
|
||||
out1:
|
||||
|
|
|
@ -50,7 +50,8 @@ static inline int nilfs_add_nondir(struct dentry *dentry, struct inode *inode)
|
|||
{
|
||||
int err = nilfs_add_link(dentry, inode);
|
||||
if (!err) {
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
return 0;
|
||||
}
|
||||
inode_dec_link_count(inode);
|
||||
|
@ -245,7 +246,8 @@ static int nilfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
goto out_fail;
|
||||
|
||||
nilfs_mark_inode_dirty(inode);
|
||||
d_instantiate_new(dentry, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
out:
|
||||
if (!err)
|
||||
err = nilfs_transaction_commit(dir->i_sb);
|
||||
|
|
|
@ -687,7 +687,8 @@ static int reiserfs_create(struct inode *dir, struct dentry *dentry, umode_t mod
|
|||
reiserfs_update_inode_transaction(inode);
|
||||
reiserfs_update_inode_transaction(dir);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
retval = journal_end(&th);
|
||||
|
||||
out_failed:
|
||||
|
@ -770,7 +771,8 @@ static int reiserfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode
|
|||
goto out_failed;
|
||||
}
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
retval = journal_end(&th);
|
||||
|
||||
out_failed:
|
||||
|
@ -869,7 +871,8 @@ static int reiserfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
|
|||
/* the above add_entry did not update dir's stat data */
|
||||
reiserfs_update_sd(&th, dir);
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
retval = journal_end(&th);
|
||||
out_failed:
|
||||
reiserfs_write_unlock(dir->i_sb);
|
||||
|
@ -1183,7 +1186,8 @@ static int reiserfs_symlink(struct inode *parent_dir,
|
|||
goto out_failed;
|
||||
}
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
retval = journal_end(&th);
|
||||
out_failed:
|
||||
reiserfs_write_unlock(parent_dir->i_sb);
|
||||
|
|
|
@ -611,7 +611,8 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
|
|||
if (fibh.sbh != fibh.ebh)
|
||||
brelse(fibh.ebh);
|
||||
brelse(fibh.sbh);
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -721,7 +722,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
|||
inc_nlink(dir);
|
||||
dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
|
||||
mark_inode_dirty(dir);
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
if (fibh.sbh != fibh.ebh)
|
||||
brelse(fibh.ebh);
|
||||
brelse(fibh.sbh);
|
||||
|
|
|
@ -38,7 +38,8 @@ static inline int ufs_add_nondir(struct dentry *dentry, struct inode *inode)
|
|||
{
|
||||
int err = ufs_add_link(dentry, inode);
|
||||
if (!err) {
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
}
|
||||
inode_dec_link_count(inode);
|
||||
|
@ -190,7 +191,8 @@ static int ufs_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode)
|
|||
if (err)
|
||||
goto out_fail;
|
||||
|
||||
d_instantiate_new(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
d_instantiate(dentry, inode);
|
||||
return 0;
|
||||
|
||||
out_fail:
|
||||
|
|
|
@ -238,7 +238,6 @@ extern seqlock_t rename_lock;
|
|||
* These are the low-level FS interfaces to the dcache..
|
||||
*/
|
||||
extern void d_instantiate(struct dentry *, struct inode *);
|
||||
extern void d_instantiate_new(struct dentry *, struct inode *);
|
||||
extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *);
|
||||
extern int d_instantiate_no_diralias(struct dentry *, struct inode *);
|
||||
extern void __d_drop(struct dentry *dentry);
|
||||
|
|
Loading…
Add table
Reference in a new issue