diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-04-11 00:53:26 -0400 |
---|---|---|
committer | Jaehoon Chung <jh80.chung@samsung.com> | 2019-01-29 11:25:42 +0900 |
commit | 5ae96114fce338f93a68220fdf71b03d5f031dbe (patch) | |
tree | 9974c17245c0d37f9d80a87e772a5f21e3375adc /fs | |
parent | 7ad9cd018c431a64798599523a9d98b39556ae91 (diff) | |
download | linux-artik7-5ae96114fce338f93a68220fdf71b03d5f031dbe.tar.gz linux-artik7-5ae96114fce338f93a68220fdf71b03d5f031dbe.tar.bz2 linux-artik7-5ae96114fce338f93a68220fdf71b03d5f031dbe.zip |
security_d_instantiate(): move to the point prior to attaching dentry to inode
commit b96809173e94ea2fa8c19c2e40e8545a1821bf57 upstream.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
[sw0312.kim: backport from mainline to resolve smack crash issue during getxattr]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: If386ad04e7e1abdd9213df87daf17648eb9f42fd
Diffstat (limited to 'fs')
-rw-r--r-- | fs/dcache.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/fs/dcache.c b/fs/dcache.c index 141651b0c766..4192b8642cfa 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1814,12 +1814,12 @@ static void __d_instantiate(struct dentry *dentry, struct inode *inode) void d_instantiate(struct dentry *entry, struct inode * inode) { BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); + security_d_instantiate(entry, inode); if (inode) spin_lock(&inode->i_lock); __d_instantiate(entry, inode); if (inode) spin_unlock(&inode->i_lock); - security_d_instantiate(entry, inode); } EXPORT_SYMBOL(d_instantiate); @@ -1880,16 +1880,15 @@ struct dentry *d_instantiate_unique(struct dentry *entry, struct inode *inode) BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); + security_d_instantiate(entry, inode); if (inode) spin_lock(&inode->i_lock); result = __d_instantiate_unique(entry, inode); if (inode) spin_unlock(&inode->i_lock); - if (!result) { - security_d_instantiate(entry, inode); + if (!result) return NULL; - } BUG_ON(!d_unhashed(result)); iput(inode); @@ -1933,6 +1932,7 @@ int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) { BUG_ON(!hlist_unhashed(&entry->d_u.d_alias)); + security_d_instantiate(entry, inode); spin_lock(&inode->i_lock); if (S_ISDIR(inode->i_mode) && !hlist_empty(&inode->i_dentry)) { spin_unlock(&inode->i_lock); @@ -1941,7 +1941,6 @@ int d_instantiate_no_diralias(struct dentry *entry, struct inode *inode) } __d_instantiate(entry, inode); spin_unlock(&inode->i_lock); - security_d_instantiate(entry, inode); return 0; } @@ -2017,6 +2016,7 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected) goto out_iput; } + security_d_instantiate(tmp, inode); spin_lock(&inode->i_lock); res = __d_find_any_alias(inode); if (res) { @@ -2039,13 +2039,10 @@ static struct dentry *__d_obtain_alias(struct inode *inode, int disconnected) hlist_bl_unlock(&tmp->d_sb->s_anon); spin_unlock(&tmp->d_lock); spin_unlock(&inode->i_lock); - security_d_instantiate(tmp, inode); return tmp; out_iput: - if (res && !IS_ERR(res)) - security_d_instantiate(res, inode); iput(inode); return res; } @@ -2842,6 +2839,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) __d_instantiate(dentry, NULL); goto out; } + security_d_instantiate(dentry, inode); spin_lock(&inode->i_lock); if (S_ISDIR(inode->i_mode)) { struct dentry *new = __d_find_any_alias(inode); @@ -2869,7 +2867,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) } else { __d_move(new, dentry, false); write_sequnlock(&rename_lock); - security_d_instantiate(new, inode); } iput(inode); return new; @@ -2879,7 +2876,6 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) __d_instantiate(dentry, inode); spin_unlock(&inode->i_lock); out: - security_d_instantiate(dentry, inode); d_rehash(dentry); return NULL; } |