mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
LSM: separate LSM_AUDIT_DATA_DENTRY from LSM_AUDIT_DATA_PATH
This patch separates and audit message that only contains a dentry from one that contains a full path. This allows us to make it harder to misuse the interfaces or for the interfaces to be implemented wrong. Signed-off-by: Eric Paris <[email protected]> Acked-by: Casey Schaufler <[email protected]>
This commit is contained in:
parent
f48b739984
commit
a269434d2f
5 changed files with 52 additions and 42 deletions
|
|
@ -316,12 +316,7 @@ static inline void smk_ad_setfield_u_tsk(struct smk_audit_info *a,
|
|||
static inline void smk_ad_setfield_u_fs_path_dentry(struct smk_audit_info *a,
|
||||
struct dentry *d)
|
||||
{
|
||||
a->a.u.path.dentry = d;
|
||||
}
|
||||
static inline void smk_ad_setfield_u_fs_path_mnt(struct smk_audit_info *a,
|
||||
struct vfsmount *m)
|
||||
{
|
||||
a->a.u.path.mnt = m;
|
||||
a->a.u.dentry = d;
|
||||
}
|
||||
static inline void smk_ad_setfield_u_fs_inode(struct smk_audit_info *a,
|
||||
struct inode *i)
|
||||
|
|
|
|||
|
|
@ -383,7 +383,7 @@ static int smack_sb_statfs(struct dentry *dentry)
|
|||
int rc;
|
||||
struct smk_audit_info ad;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
rc = smk_curacc(sbp->smk_floor, MAY_READ, &ad);
|
||||
|
|
@ -425,10 +425,13 @@ static int smack_sb_umount(struct vfsmount *mnt, int flags)
|
|||
{
|
||||
struct superblock_smack *sbp;
|
||||
struct smk_audit_info ad;
|
||||
struct path path;
|
||||
|
||||
path.dentry = mnt->mnt_root;
|
||||
path.mnt = mnt;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, mnt->mnt_root);
|
||||
smk_ad_setfield_u_fs_path_mnt(&ad, mnt);
|
||||
smk_ad_setfield_u_fs_path(&ad, path);
|
||||
|
||||
sbp = mnt->mnt_sb->s_security;
|
||||
return smk_curacc(sbp->smk_floor, MAY_WRITE, &ad);
|
||||
|
|
@ -563,7 +566,7 @@ static int smack_inode_link(struct dentry *old_dentry, struct inode *dir,
|
|||
struct smk_audit_info ad;
|
||||
int rc;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry);
|
||||
|
||||
isp = smk_of_inode(old_dentry->d_inode);
|
||||
|
|
@ -592,7 +595,7 @@ static int smack_inode_unlink(struct inode *dir, struct dentry *dentry)
|
|||
struct smk_audit_info ad;
|
||||
int rc;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
/*
|
||||
|
|
@ -623,7 +626,7 @@ static int smack_inode_rmdir(struct inode *dir, struct dentry *dentry)
|
|||
struct smk_audit_info ad;
|
||||
int rc;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
/*
|
||||
|
|
@ -663,7 +666,7 @@ static int smack_inode_rename(struct inode *old_inode,
|
|||
char *isp;
|
||||
struct smk_audit_info ad;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, old_dentry);
|
||||
|
||||
isp = smk_of_inode(old_dentry->d_inode);
|
||||
|
|
@ -720,7 +723,7 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)
|
|||
*/
|
||||
if (iattr->ia_valid & ATTR_FORCE)
|
||||
return 0;
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
return smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad);
|
||||
|
|
@ -736,10 +739,13 @@ static int smack_inode_setattr(struct dentry *dentry, struct iattr *iattr)
|
|||
static int smack_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
|
||||
{
|
||||
struct smk_audit_info ad;
|
||||
struct path path;
|
||||
|
||||
path.dentry = dentry;
|
||||
path.mnt = mnt;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
smk_ad_setfield_u_fs_path_mnt(&ad, mnt);
|
||||
smk_ad_setfield_u_fs_path(&ad, path);
|
||||
return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad);
|
||||
}
|
||||
|
||||
|
|
@ -784,7 +790,7 @@ static int smack_inode_setxattr(struct dentry *dentry, const char *name,
|
|||
} else
|
||||
rc = cap_inode_setxattr(dentry, name, value, size, flags);
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
if (rc == 0)
|
||||
|
|
@ -845,7 +851,7 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
|
|||
{
|
||||
struct smk_audit_info ad;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
|
||||
return smk_curacc(smk_of_inode(dentry->d_inode), MAY_READ, &ad);
|
||||
|
|
@ -877,7 +883,7 @@ static int smack_inode_removexattr(struct dentry *dentry, const char *name)
|
|||
} else
|
||||
rc = cap_inode_removexattr(dentry, name);
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
|
||||
if (rc == 0)
|
||||
rc = smk_curacc(smk_of_inode(dentry->d_inode), MAY_WRITE, &ad);
|
||||
|
|
@ -1070,7 +1076,7 @@ static int smack_file_lock(struct file *file, unsigned int cmd)
|
|||
{
|
||||
struct smk_audit_info ad;
|
||||
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
|
||||
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
|
||||
smk_ad_setfield_u_fs_path_dentry(&ad, file->f_path.dentry);
|
||||
return smk_curacc(file->f_security, MAY_WRITE, &ad);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue