mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
security: Introduce inode_post_setattr hook
In preparation for moving IMA and EVM to the LSM infrastructure, introduce the inode_post_setattr hook. At inode_setattr hook, EVM verifies the file's existing HMAC value. At inode_post_setattr, EVM re-calculates the file's HMAC based on the modified file attributes and other file metadata. Other LSMs could similarly take some action after successful file attribute change. The new hook cannot return an error and cannot cause the operation to be reverted. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Acked-by: Casey Schaufler <casey@schaufler-ca.com> Acked-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
314a8dc728
commit
77fa6f314f
@ -502,6 +502,7 @@ int notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
|
||||
if (!error) {
|
||||
fsnotify_change(dentry, ia_valid);
|
||||
security_inode_post_setattr(idmap, dentry, ia_valid);
|
||||
ima_inode_post_setattr(idmap, dentry, ia_valid);
|
||||
evm_inode_post_setattr(idmap, dentry, ia_valid);
|
||||
}
|
||||
|
@ -137,6 +137,8 @@ LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
|
||||
LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask)
|
||||
LSM_HOOK(int, 0, inode_setattr, struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
struct iattr *attr)
|
||||
LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, int ia_valid)
|
||||
LSM_HOOK(int, 0, inode_getattr, const struct path *path)
|
||||
LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, const char *name, const void *value,
|
||||
|
@ -361,6 +361,8 @@ int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
|
||||
int security_inode_permission(struct inode *inode, int mask);
|
||||
int security_inode_setattr(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, struct iattr *attr);
|
||||
void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
int ia_valid);
|
||||
int security_inode_getattr(const struct path *path);
|
||||
int security_inode_setxattr(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry, const char *name,
|
||||
@ -879,6 +881,11 @@ static inline int security_inode_setattr(struct mnt_idmap *idmap,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
int ia_valid)
|
||||
{ }
|
||||
|
||||
static inline int security_inode_getattr(const struct path *path)
|
||||
{
|
||||
return 0;
|
||||
|
@ -2222,6 +2222,22 @@ int security_inode_setattr(struct mnt_idmap *idmap,
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(security_inode_setattr);
|
||||
|
||||
/**
|
||||
* security_inode_post_setattr() - Update the inode after a setattr operation
|
||||
* @idmap: idmap of the mount
|
||||
* @dentry: file
|
||||
* @ia_valid: file attributes set
|
||||
*
|
||||
* Update inode security field after successful setting file attributes.
|
||||
*/
|
||||
void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
|
||||
int ia_valid)
|
||||
{
|
||||
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
|
||||
return;
|
||||
call_void_hook(inode_post_setattr, idmap, dentry, ia_valid);
|
||||
}
|
||||
|
||||
/**
|
||||
* security_inode_getattr() - Check if getting file attributes is allowed
|
||||
* @path: file
|
||||
|
Loading…
Reference in New Issue
Block a user