@@ -1037,11 +1037,13 @@ static void evm_file_release(struct file *file)
static void evm_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
{
struct inode *inode = d_backing_inode(dentry);
- struct evm_iint_cache *iint = evm_iint_inode(inode);
+ struct evm_iint_cache *iint;
- if (!S_ISREG(inode->i_mode))
+ /* path_post_mknod hook might pass dentries without attached inode. */
+ if (!inode || !S_ISREG(inode->i_mode))
return;
+ iint = evm_iint_inode(inode);
if (iint)
iint->flags |= EVM_NEW_FILE;
}
@@ -719,10 +719,11 @@ static void ima_post_create_tmpfile(struct mnt_idmap *idmap,
static void ima_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
{
struct ima_iint_cache *iint;
- struct inode *inode = dentry->d_inode;
+ struct inode *inode = d_backing_inode(dentry);
int must_appraise;
- if (!ima_policy_flag || !S_ISREG(inode->i_mode))
+ /* path_post_mknod hook might pass dentries without attached inode. */
+ if (!ima_policy_flag || !inode || !S_ISREG(inode->i_mode))
return;
must_appraise = ima_must_appraise(idmap, inode, MAY_ACCESS,
@@ -1801,7 +1801,10 @@ EXPORT_SYMBOL(security_path_mknod);
*/
void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
{
- if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
+ struct inode *inode = d_backing_inode(dentry);
+
+ /* Not all dentries have an inode attached after mknod. */
+ if (inode && unlikely(IS_PRIVATE(inode)))
return;
call_void_hook(path_post_mknod, idmap, dentry);
}