Commit 3558ebfc authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Move security_d_instantiate hook calls

From: Stephen Smalley <sds@epoch.ncsc.mil>

This patch moves the security_d_instantiate hook calls in d_instantiate and
d_splice_alias after the inode has been attached to the dentry.  This
change is necessary so that security modules can internally call the
getxattr inode operation (which takes a dentry parameter) from this hook to
obtain the inode security label.
parent 57a54189
...@@ -770,12 +770,12 @@ struct dentry * d_alloc(struct dentry * parent, const struct qstr *name) ...@@ -770,12 +770,12 @@ struct dentry * d_alloc(struct dentry * parent, const struct qstr *name)
void d_instantiate(struct dentry *entry, struct inode * inode) void d_instantiate(struct dentry *entry, struct inode * inode)
{ {
if (!list_empty(&entry->d_alias)) BUG(); if (!list_empty(&entry->d_alias)) BUG();
security_d_instantiate(entry, inode);
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (inode) if (inode)
list_add(&entry->d_alias, &inode->i_dentry); list_add(&entry->d_alias, &inode->i_dentry);
entry->d_inode = inode; entry->d_inode = inode;
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(entry, inode);
} }
/** /**
...@@ -903,12 +903,12 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) ...@@ -903,12 +903,12 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
struct dentry *new = NULL; struct dentry *new = NULL;
if (inode && S_ISDIR(inode->i_mode)) { if (inode && S_ISDIR(inode->i_mode)) {
security_d_instantiate(dentry, inode);
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (!list_empty(&inode->i_dentry)) { if (!list_empty(&inode->i_dentry)) {
new = list_entry(inode->i_dentry.next, struct dentry, d_alias); new = list_entry(inode->i_dentry.next, struct dentry, d_alias);
__dget_locked(new); __dget_locked(new);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(dentry, inode);
d_rehash(dentry); d_rehash(dentry);
d_move(new, dentry); d_move(new, dentry);
iput(inode); iput(inode);
...@@ -917,6 +917,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry) ...@@ -917,6 +917,7 @@ struct dentry *d_splice_alias(struct inode *inode, struct dentry *dentry)
list_add(&dentry->d_alias, &inode->i_dentry); list_add(&dentry->d_alias, &inode->i_dentry);
dentry->d_inode = inode; dentry->d_inode = inode;
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
security_d_instantiate(dentry, inode);
d_rehash(dentry); d_rehash(dentry);
} }
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment